<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - x86_64 backend sometimes generates 'leaq (%rsp), %x' rather than 'movq %rsp, %x'"
   href="https://llvm.org/bugs/show_bug.cgi?id=29022">29022</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>x86_64 backend sometimes generates 'leaq (%rsp), %x' rather than 'movq %rsp, %x'
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Backend: X86
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>richard-llvm@metafoo.co.uk
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, mkuper@google.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>.cpp source:

#include <string>
int f() {
  int a = std::string().size();
  int b = std::string().size();
  return a + b;
}

IR:

; ModuleID = '-'
source_filename = "-"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.std::basic_string" = type { i8* }

; Function Attrs: nounwind uwtable
define i32 @_Z1fv() local_unnamed_addr {
entry:
  %temp.lvalue = alloca %"class.std::basic_string", align 8
  %temp.lvalue1 = alloca %"class.std::basic_string", align 8
  call void @_ZNSsC2Ev(%"class.std::basic_string"* nonnull %temp.lvalue)
  %call = call i64 @_ZNKSs4sizeEv(%"class.std::basic_string"* nonnull
%temp.lvalue)
  %conv = trunc i64 %call to i32
  call void @_ZNSsD2Ev(%"class.std::basic_string"* nonnull %temp.lvalue)
  call void @_ZNSsC2Ev(%"class.std::basic_string"* nonnull %temp.lvalue1)
  %call2 = call i64 @_ZNKSs4sizeEv(%"class.std::basic_string"* nonnull
%temp.lvalue1)
  %conv3 = trunc i64 %call2 to i32
  call void @_ZNSsD2Ev(%"class.std::basic_string"* nonnull %temp.lvalue1)
  %add = add nsw i32 %conv3, %conv
  ret i32 %add
}

; Function Attrs: nounwind uwtable
declare void @_ZNSsC2Ev(%"class.std::basic_string"* %this) unnamed_addr

; Function Attrs: norecurse nounwind uwtable
declare i64 @_ZNKSs4sizeEv(%"class.std::basic_string"* %this)
local_unnamed_addr

; Function Attrs: nounwind uwtable
declare void @_ZNSsD2Ev(%"class.std::basic_string"* %this) unnamed_addr


This generates the following instruction:

        leaq    (%rsp), %r15

That seems silly; we should use a movq instead.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>