[llvm-bugs] [Bug 29022] New: x86_64 backend sometimes generates 'leaq (%rsp), %x' rather than 'movq %rsp, %x'

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Aug 17 13:09:00 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=29022

            Bug ID: 29022
           Summary: x86_64 backend sometimes generates 'leaq (%rsp), %x'
                    rather than 'movq %rsp, %x'
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: richard-llvm at metafoo.co.uk
                CC: llvm-bugs at lists.llvm.org, mkuper at google.com
    Classification: Unclassified

.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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160817/c519ff5d/attachment.html>


More information about the llvm-bugs mailing list