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.
Fixed in r204865 For more details, refer to the Crucible review: http://reviews.llvm.org/D2970