[llvm] [MergeFuncs] Don't introduce calls to {linkonce,weak}_odr functions. (PR #125050)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 31 08:52:42 PST 2025


fhahn wrote:

The scenario below should hopefully better illustrate what is causing the issue. It would be great to confirm if I am not missing anything that makes the scenario invalid.

Module X
```
define linkonce_odr void @"A"() {
  call void @"foo"()
}

define linkonce_odr void @"B"() {
  call void @"foo"()
}
```

Module Y
```
global @"g" = @"B"

define linkonce_odr void @"A"() {
  %l = load @"g"
  call void %l()
}

define linkonce_odr void @"B"() {
  call void @"foo"()
}
```

`@"A"` and `@"B"` in both modules should be semantically equivalent

Module X after function merging:

```
define linkonce_odr void @"A"() {
  call void @"foo"()
}

define linkonce_odr void @"B"() {
  call void @"A"()
}
```
Module Y is unchanged.

Then the linker picks @"A" from module Y and @"B" from module X. Now there's an infinite call cycle

https://github.com/llvm/llvm-project/pull/125050


More information about the llvm-commits mailing list