Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

another example of different code generation at -O2 -g and -O2 #19425

Closed
llvmbot opened this issue Mar 5, 2014 · 1 comment
Closed

another example of different code generation at -O2 -g and -O2 #19425

llvmbot opened this issue Mar 5, 2014 · 1 comment
Labels
bugzilla Issues migrated from bugzilla llvm:codegen

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Mar 5, 2014

Bugzilla Link 19051
Resolution FIXED
Resolved on Mar 23, 2015 15:25
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @echristo,@hfinkel

Extended Description

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.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Mar 23, 2015

Fixed in r204865

For more details, refer to the Crucible review:
http://reviews.llvm.org/D2970

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 9, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla llvm:codegen
Projects
None yet
Development

No branches or pull requests

1 participant