https://github.com/gandhi56 updated https://github.com/llvm/llvm-project/pull/105845
>From d4b8e5b213b4ea9b5b615354d264b71ed76508d5 Mon Sep 17 00:00:00 2001 From: Anshil Gandhi <anshil.gan...@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 | 4 ++++ llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp | 3 ++- 3 files changed, 18 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..53ee3e42eef4c8 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp @@ -1066,6 +1066,10 @@ 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..869afdcc62dbf6 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp @@ -761,7 +761,8 @@ 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( _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits