Last active
August 29, 2015 14:02
-
-
Save scriptum/57ae4d2524d42fccb494 to your computer and use it in GitHub Desktop.
LTO gcc test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "a.hpp" | |
#include "stdio.h" | |
void A::set(int a, int b) | |
{ | |
x = a; | |
y = b; | |
} | |
void A::get() | |
{ | |
printf("%d %d\n", x, y); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A { | |
private: | |
int x, y; | |
public: | |
void set(int a, int b); | |
void get(); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "a.hpp" | |
int main() | |
{ | |
A a; | |
a.set(10, 15); | |
a.get(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
g++ -c -O2 -flto -g test.cpp a.cpp && g++ -O2 -g test.o a.o | |
objdump -S a.out | grep 'int main' -A15 | |
# Optimized output: | |
# | |
# int main() | |
# { | |
# 400550: 48 83 ec 08 sub $0x8,%rsp | |
# x = a; | |
# y = b; | |
# } | |
# void A::get() | |
# { | |
# printf("%d %d\n", x, y); | |
# 400554: ba 0f 00 00 00 mov $0xf,%edx | |
# 400559: be 0a 00 00 00 mov $0xa,%esi | |
# 40055e: bf 04 07 40 00 mov $0x400704,%edi | |
# 400563: 31 c0 xor %eax,%eax | |
# 400565: e8 b6 ff ff ff callq 400520 <printf@plt> | |
# A a; | |
# a.set(10,15); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment