Skip to content

Commit

Permalink
[AMDGPU][LTO] Assume closed world after linking (llvm#105845)
Browse files Browse the repository at this point in the history
  • Loading branch information
gandhi56 authored Aug 25, 2024
1 parent 1c46fc0 commit 33f3ebc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 6 additions & 2 deletions llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,8 +760,12 @@ void AMDGPUTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
// module is partitioned for codegen.
if (EnableLowerModuleLDS)
PM.addPass(AMDGPULowerModuleLDSPass(*this));
if (EnableAMDGPUAttributor && Level != OptimizationLevel::O0)
PM.addPass(AMDGPUAttributorPass(*this));

if (EnableAMDGPUAttributor && Level != OptimizationLevel::O0) {
AMDGPUAttributorOptions Opts;
Opts.IsClosedWorld = true;
PM.addPass(AMDGPUAttributorPass(*this, Opts));
}
});

PB.registerRegClassFilterParsingCallback(
Expand Down
10 changes: 10 additions & 0 deletions llvm/test/LTO/AMDGPU/gpu-rdc-amdgpu-attrs.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
; RUN: opt -O3 -debug-only=amdgpu-attributor -S -o - %s 2>&1 | FileCheck %s --check-prefix=PRE-LINK
; RUN: opt -passes="lto<O3>" -debug-only=amdgpu-attributor -S -o - %s 2>&1 | FileCheck %s --check-prefix=POST-LINK

target triple = "amdgcn-amd-amdhsa"

; PRE-LINK: Module {{.*}} is not assumed to be a closed world.
; POST-LINK: Module {{.*}} is assumed to be a closed world.
define hidden noundef i32 @_Z3foov() {
ret i32 1
}

0 comments on commit 33f3ebc

Please sign in to comment.