[llvm-branch-commits] [llvm] Attributor: Don't report a change when no functions are internalized (PR #244976)
Matt Arsenault via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sat Nov 21 16:38:46 PST 2026
https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/244976
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 at anthropic.com>
>From 258f237b7f687b371bfac74ea757cb5190029aba Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Sat, 21 Nov 2026 19:26:11 -0500
Subject: [PATCH] Attributor: Don't report a change when no functions are
internalized
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 at anthropic.com>
---
llvm/lib/Transforms/IPO/Attributor.cpp | 3 +++
.../OpenMP/no-change-preserve-analyses.ll | 21 +++++++++++++++++++
2 files changed, 24 insertions(+)
create mode 100644 llvm/test/Transforms/OpenMP/no-change-preserve-analyses.ll
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}
More information about the llvm-branch-commits
mailing list