Skip to content

Commit 33f3ebc

Browse files
authored
[AMDGPU][LTO] Assume closed world after linking (#105845)
1 parent 1c46fc0 commit 33f3ebc

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,10 @@ static bool runImpl(Module &M, AnalysisGetter &AG, TargetMachine &TM,
10661066

10671067
Attributor A(Functions, InfoCache, AC);
10681068

1069+
LLVM_DEBUG(dbgs() << "Module " << M.getName() << " is "
1070+
<< (AC.IsClosedWorldModule ? "" : "not ")
1071+
<< "assumed to be a closed world.\n");
1072+
10691073
for (Function &F : M) {
10701074
if (F.isIntrinsic())
10711075
continue;

llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -760,8 +760,12 @@ void AMDGPUTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
760760
// module is partitioned for codegen.
761761
if (EnableLowerModuleLDS)
762762
PM.addPass(AMDGPULowerModuleLDSPass(*this));
763-
if (EnableAMDGPUAttributor && Level != OptimizationLevel::O0)
764-
PM.addPass(AMDGPUAttributorPass(*this));
763+
764+
if (EnableAMDGPUAttributor && Level != OptimizationLevel::O0) {
765+
AMDGPUAttributorOptions Opts;
766+
Opts.IsClosedWorld = true;
767+
PM.addPass(AMDGPUAttributorPass(*this, Opts));
768+
}
765769
});
766770

767771
PB.registerRegClassFilterParsingCallback(
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
; RUN: opt -O3 -debug-only=amdgpu-attributor -S -o - %s 2>&1 | FileCheck %s --check-prefix=PRE-LINK
2+
; RUN: opt -passes="lto<O3>" -debug-only=amdgpu-attributor -S -o - %s 2>&1 | FileCheck %s --check-prefix=POST-LINK
3+
4+
target triple = "amdgcn-amd-amdhsa"
5+
6+
; PRE-LINK: Module {{.*}} is not assumed to be a closed world.
7+
; POST-LINK: Module {{.*}} is assumed to be a closed world.
8+
define hidden noundef i32 @_Z3foov() {
9+
ret i32 1
10+
}

0 commit comments

Comments
 (0)