[LLVMbugs] [Bug 19051] New: another example of different code generation at -O2 -g and -O2

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Mar 4 22:08:43 PST 2014


http://llvm.org/bugs/show_bug.cgi?id=19051

            Bug ID: 19051
           Summary: another example of different code generation at -O2 -g
                    and -O2
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedbugs at nondot.org
          Reporter: katya_romanova at playstation.sony.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Code motion is noticed when running tests with and without the debug info at
O2.
I've triaged this bug, and it's not a duplicate of BZ #18590. 


========Testcase==================
 extern void foo(char *dst,unsigned siz,const char *src);
 extern const char * i2str(int);

 struct AAA3 {
  AAA3(const char *value) { foo(text,sizeof(text),value);}
  void operator=(const char *value) { foo(text,sizeof(text),value);}
  operator const char*() const { return text;}
  char text[4];
 };

 void bar (int param1,int param2)  {
   const char * temp(0);

   if (param2) {
     temp = i2str(param2);
   }
   AAA3 var1("");
   AAA3 var2("");

   if (param1)
     var2 = "+";
   else
     var2 = "-";
   var1 = "";
 }
==============================================


clang -c -g -O2 test.cpp -o test.g.o
clang -c -O2 test.cpp -o test.o

objdump -d test.g.o > test.g.txt
objdump -d test.o > test.txt

diff test.txt test.g.txt
2c2
< test.o:     file format elf64-x86-64
---
> test.g.o:     file format elf64-x86-64
23,25c23,25
<   39: 48 8d 3c 24             lea    (%rsp),%rdi
<   3d: be 04 00 00 00          mov    $0x4,%esi
<   42: 85 db                   test   %ebx,%ebx
---
>   39: 85 db                   test   %ebx,%ebx
>   3b: 48 8d 3c 24             lea    (%rsp),%rdi
>   3f: be 04 00 00 00          mov    $0x4,%esi


Katya.

-- 
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/20140305/3e8a5eb7/attachment.html>


More information about the llvm-bugs mailing list