llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.75k stars 11.89k forks source link

ThinLTO doesn't apply interprocedural ConstMerge optimization #32977

Open llvmbot opened 7 years ago

llvmbot commented 7 years ago
Bugzilla Link 33630
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor

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

efriedma-quic commented 7 years ago

Is this actually important? The strings will get merged by the linker.