[llvm-branch-commits] [llvm] Attributor: Don't report a change when no functions are internalized (PR #244976)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sat Nov 21 17:28:59 PST 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Matt Arsenault (arsenm)
<details>
<summary>Changes</summary>
internalizeFunctions returned true for an empty set, so this reported
a change for every module and invalidated all function analyses even
when it did nothing.
Co-authored-by: Claude Opus 5.5 <noreply@<!-- -->anthropic.com>
---
Full diff: https://github.com/llvm/llvm-project/pull/244976.diff
2 Files Affected:
- (modified) llvm/lib/Transforms/IPO/Attributor.cpp (+3)
- (added) llvm/test/Transforms/OpenMP/no-change-preserve-analyses.ll (+21)
``````````diff
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index 46dfd50040b3f..ad42b2a4e4046 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -2791,6 +2791,9 @@ Function *Attributor::internalizeFunction(Function &F, bool Force) {
bool Attributor::internalizeFunctions(SmallPtrSetImpl<Function *> &FnSet,
DenseMap<Function *, Function *> &FnMap) {
+ if (FnSet.empty())
+ return false;
+
for (Function *F : FnSet)
if (!Attributor::isInternalizable(*F))
return false;
diff --git a/llvm/test/Transforms/OpenMP/no-change-preserve-analyses.ll b/llvm/test/Transforms/OpenMP/no-change-preserve-analyses.ll
new file mode 100644
index 0000000000000..bc48dbd247937
--- /dev/null
+++ b/llvm/test/Transforms/OpenMP/no-change-preserve-analyses.ll
@@ -0,0 +1,21 @@
+; RUN: opt -disable-output -debug-pass-manager -passes='function(require<domtree>,require<lazy-value-info>),openmp-opt,function(require<domtree>,require<lazy-value-info>)' %s 2>&1 | FileCheck %s
+; REQUIRES: amdgpu-registered-target
+
+; OpenMPOpt does not change this device module, so no analyses should be
+; invalidated.
+
+; CHECK: Running pass: OpenMPOptPass on [module]{{$}}
+; CHECK-NEXT: Running pass: RequireAnalysisPass<{{.*}}DominatorTreeAnalysis{{.*}}> on f (1 instruction){{$}}
+; CHECK-NEXT: Running pass: RequireAnalysisPass<{{.*}}LazyValueAnalysis{{.*}}> on f (1 instruction){{$}}
+; CHECK-NEXT: Running pass: VerifierPass on [module]{{$}}
+
+target triple = "amdgpu9-amd-amdhsa"
+
+define void @f() {
+ ret void
+}
+
+!llvm.module.flags = !{!0, !1}
+
+!0 = !{i32 7, !"openmp", i32 50}
+!1 = !{i32 7, !"openmp-device", i32 50}
``````````
</details>
https://github.com/llvm/llvm-project/pull/244976
More information about the llvm-branch-commits
mailing list