[lld] [lld] Merge equivalent symbols found during ICF (PR #134342)
Hans Wennborg via llvm-commits
llvm-commits at lists.llvm.org
Fri May 9 09:44:10 PDT 2025
zmodem wrote:
This has some UB, but I think it illustrates the core of our problem:
```
$ cat /tmp/x.c
const int x = 1;
const int y = 2;
extern const int __attribute__((alias("y"))) alias;
int f() { return *(&x + 1); }
int g() { return alias; }
int h() { return alias * 10; }
#include <stdio.h>
int main() {
printf("%d %d %d\n", f(), g(), h());
return 0;
}
```
Before the ICF change:
```
$ build/bin/clang /tmp/x.c -ffunction-sections -fuse-ld=lld -Wl,--icf=all && ./a.out
2 2 20
```
After:
```
$ build/bin/clang /tmp/x.c -ffunction-sections -fuse-ld=lld -Wl,--icf=all && ./a.out
2 2 10
```
https://github.com/llvm/llvm-project/pull/134342
More information about the llvm-commits
mailing list