Open llvmbot opened 7 years ago
LTO will apply the Constant Merging pass, but ThinLTO can't apply this optimization right now.
Test case:
// a.c const char *x = "blah";
// b.c
extern const char x; const char b = "blah";
int main(void) { puts(x); puts(b); }
//////////////////////
$ ../build/bin/clang a.c b.c --for-linker=-mllvm --for-linker=-stats -flto=thin \ -fuse-ld=lld -o out &>&1 | grep "constmerge"
$ ../build/bin/clang a.c b.c --for-linker=-mllvm --for-linker=-stats -flto \ -fuse-ld=lld -o out &>&1 | grep "constmerge"
1 constmerge - Number of global constants merged
Is this actually important? The strings will get merged by the linker.
Extended Description
LTO will apply the Constant Merging pass, but ThinLTO can't apply this optimization right now.
Test case:
// a.c const char *x = "blah";
// b.c
include
extern const char x; const char b = "blah";
int main(void) { puts(x); puts(b); }
//////////////////////
== THINLTO ==
$ ../build/bin/clang a.c b.c --for-linker=-mllvm --for-linker=-stats -flto=thin \ -fuse-ld=lld -o out &>&1 | grep "constmerge"
nothing
== LTO ==
$ ../build/bin/clang a.c b.c --for-linker=-mllvm --for-linker=-stats -flto \ -fuse-ld=lld -o out &>&1 | grep "constmerge"
1 constmerge - Number of global constants merged