[all-commits] [llvm/llvm-project] f10e0f: [MergeFuncs] Don't introduce calls to (linkonce, we...

Florian Hahn via All-commits all-commits at lists.llvm.org
Tue Feb 25 07:55:48 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f10e0f7321b34693697a0bf895d440f82b32ba54
      https://github.com/llvm/llvm-project/commit/f10e0f7321b34693697a0bf895d440f82b32ba54
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2025-02-25 (Tue, 25 Feb 2025)

  Changed paths:
    M clang/test/CodeGenCXX/merge-functions.cpp
    M llvm/lib/Transforms/IPO/MergeFunctions.cpp
    M llvm/test/Transforms/MergeFunc/comdat.ll
    M llvm/test/Transforms/MergeFunc/linkonce_odr.ll
    M llvm/test/Transforms/MergeFunc/merge-linkonce-odr-used.ll
    M llvm/test/Transforms/MergeFunc/merge-linkonce-odr-weak-odr-mixed-used.ll
    M llvm/test/Transforms/MergeFunc/merge-linkonce-odr.ll
    M llvm/test/Transforms/MergeFunc/merge-weak-odr-used.ll
    M llvm/test/Transforms/MergeFunc/merge-weak-odr.ll

  Log Message:
  -----------
  [MergeFuncs] Don't introduce calls to (linkonce,weak)_odr functions. (#125050)

Avoid creating new calls to linkonce_odr/weak_odr functions when
merging 2 functions, as this may introduce an infinite call
cycle.

Consider 2 functions below, both present in 2 modules. 

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 are 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


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



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list