[PATCH] D30365: ELF ICF: Merge only functions.

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 26 12:33:22 PST 2017


Rui Ueyama via Phabricator via llvm-commits
<llvm-commits at lists.llvm.org> writes:

> ruiu created this revision.
>
> 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).

So, I would like to still have a way to merge all constants. It doesn't
have to be the dafault.

The above example would still show a bug if you were comparing the address of two
functions. The issue is that we have to figure out an ELF extension to
propagate unnamed_addr to the linker to do this properly.

Cheers,
Rafael


More information about the llvm-commits mailing list