[llvm] Make functions always renamable (PR #115226)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 6 14:07:38 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lto
Author: Simone Campanoni (scampanoni)
<details>
<summary>Changes</summary>
Functions with non-default sections are currently non renamable. This blocks ThinLTO to optimize code between modules.
It is unclear why functions with non-default sections should not be renamable. This patch makes them always renamable.
Perhaps, we need to block functions with non-default sections to be non renamable for some object formats (please see the RFC "Allow ThinLTO to Rename Local Functions with Sections" for a longer description on this topic).
If that is the case, then we should perhaps make this list of object formats that require special treatment explicit.
---
Full diff: https://github.com/llvm/llvm-project/pull/115226.diff
2 Files Affected:
- (modified) llvm/lib/Analysis/ModuleSummaryAnalysis.cpp (+3)
- (modified) llvm/test/Bitcode/thinlto-summary-section.ll (+3-3)
``````````diff
diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
index 04670f2e2d6351..63ea8af1d013a4 100644
--- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -175,6 +175,9 @@ static CalleeInfo::HotnessType getHotness(uint64_t ProfileCount,
}
static bool isNonRenamableLocal(const GlobalValue &GV) {
+ if (isa<Function>(&GV)) {
+ return false;
+ }
return GV.hasSection() && GV.hasLocalLinkage();
}
diff --git a/llvm/test/Bitcode/thinlto-summary-section.ll b/llvm/test/Bitcode/thinlto-summary-section.ll
index 5a2c02e4ac2972..397cf8d8f5f905 100644
--- a/llvm/test/Bitcode/thinlto-summary-section.ll
+++ b/llvm/test/Bitcode/thinlto-summary-section.ll
@@ -4,10 +4,10 @@
; RUN: llvm-lto -thinlto -o %t2 %t.o
; RUN: llvm-bcanalyzer -dump %t2.thinlto.bc | FileCheck %s --check-prefix=COMBINED
-; Flags should be 0x57 (87) for local linkage (0x3), dso_local (0x40) and not being importable
+; Flags should be 0x47 (71) for local linkage (0x3), dso_local (0x40) and being importable
; (0x10) due to local linkage plus having a section.
-; CHECK: <PERMODULE_PROFILE {{.*}} op1=87
-; COMBINED-DAG: <COMBINED_PROFILE {{.*}} op2=87
+; CHECK: <PERMODULE_PROFILE {{.*}} op1=71
+; COMBINED-DAG: <COMBINED_PROFILE {{.*}} op2=71
define internal void @functionWithSection() section "some_section" {
ret void
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/115226
More information about the llvm-commits
mailing list