[clang] [llvm] [AMDGPU][LTO] Assume closed world after linking (PR #105845)
Anshil Gandhi via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 23 08:27:12 PDT 2024
https://github.com/gandhi56 created https://github.com/llvm/llvm-project/pull/105845
Change-Id: I7d8fa4251c80a6f815f55a0998677d18ade25b72
>From 8830b6f390039c9a952a86ea52e8fe9559900448 Mon Sep 17 00:00:00 2001
From: Anshil Gandhi <Anshil.Gandhi at amd.com>
Date: Thu, 22 Aug 2024 18:57:33 +0000
Subject: [PATCH] [AMDGPU][LTO] Assume closed world after linking
Change-Id: I7d8fa4251c80a6f815f55a0998677d18ade25b72
---
clang/test/CodeGenCUDA/gpu-rdc-amdgpu-attrs.cu | 12 ++++++++++++
llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp | 3 +++
llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp | 2 +-
3 files changed, 16 insertions(+), 1 deletion(-)
create mode 100644 clang/test/CodeGenCUDA/gpu-rdc-amdgpu-attrs.cu
diff --git a/clang/test/CodeGenCUDA/gpu-rdc-amdgpu-attrs.cu b/clang/test/CodeGenCUDA/gpu-rdc-amdgpu-attrs.cu
new file mode 100644
index 00000000000000..614917aecc0d60
--- /dev/null
+++ b/clang/test/CodeGenCUDA/gpu-rdc-amdgpu-attrs.cu
@@ -0,0 +1,12 @@
+// RUN: clang -x hip -O3 -fgpu-rdc %s -mllvm -debug-only=amdgpu-attributor -o - | FileCheck %s
+
+// CHECK: Module {{.*}} is not assumed to be a closed world
+// CHECK: Module ld-temp.o is assumed to be a closed world
+
+__attribute__((device)) int foo() {
+ return 1;
+}
+
+int main() {
+ return 0;
+}
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp b/llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp
index d65e0ae92308e6..c78fc66e41ec58 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp
@@ -1066,6 +1066,9 @@ static bool runImpl(Module &M, AnalysisGetter &AG, TargetMachine &TM,
Attributor A(Functions, InfoCache, AC);
+ LLVM_DEBUG(dbgs() << "Module " << M.getName() << " is " << (AC.IsClosedWorldModule ? "" : "not ")
+ << "assumed to be a closed world\n");
+
for (Function &F : M) {
if (F.isIntrinsic())
continue;
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
index 7ac7b3315bb972..a4898366a21ee1 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -761,7 +761,7 @@ void AMDGPUTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
if (EnableLowerModuleLDS)
PM.addPass(AMDGPULowerModuleLDSPass(*this));
if (EnableAMDGPUAttributor && Level != OptimizationLevel::O0)
- PM.addPass(AMDGPUAttributorPass(*this));
+ PM.addPass(AMDGPUAttributorPass(*this, AMDGPUAttributorOptions{true} ));
});
PB.registerRegClassFilterParsingCallback(
More information about the llvm-commits
mailing list