This is an archive of the discontinued LLVM Phabricator instance.

ELF ICF: Merge only functions.
ClosedPublic

Authored by ruiu on Feb 24 2017, 5:06 PM.

Details

Summary

Previously, LLD merged all read-only sections. So the following
program prints out "true" if -icf=all is specified.

static const int foo = 1;
static const int bar = 1;
int main() { printf("%s\n", &foo == &bar ? "true" : "false"); }

This is somewhat counter-intuitive, and it actually caused nasty issues.
One example is https://bugs.chromium.org/p/chromium/issues/detail?id=682773#c24.

This patch changes the way how it works. Now ICF merges only functions
(i.e. executable sections).

Diff Detail

Repository
rL LLVM

Event Timeline

ruiu created this revision.Feb 24 2017, 5:06 PM
ruiu updated this revision to Diff 89755.Feb 24 2017, 5:09 PM
  • Updated the test to be more realistic -- now it is a data section rather than a text section without x bit.
rnk accepted this revision.Feb 26 2017, 7:58 AM
rnk added a subscriber: rnk.

lgtm

Thanks! I think experience has shown that this isn't worth it.

This revision is now accepted and ready to land.Feb 26 2017, 7:58 AM
krasin accepted this revision.Feb 27 2017, 8:33 AM

Thank you, Rui!

Do we wait for anything or anybody? If not, let's submit the CL. That should fix ThinLTO bot in Chrome.

This revision was automatically updated to reflect the committed changes.