Skip to content

Commit d4b8e5b

Browse files
committed
[AMDGPU][LTO] Assume closed world after linking
Change-Id: I7d8fa4251c80a6f815f55a0998677d18ade25b72
1 parent 6e78aef commit d4b8e5b

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: clang -x hip -O3 -fgpu-rdc %s -mllvm -debug-only=amdgpu-attributor -o - | FileCheck %s
2+
3+
// CHECK: Module {{.*}} is not assumed to be a closed world
4+
// CHECK: Module ld-temp.o is assumed to be a closed world
5+
6+
__attribute__((device)) int foo() {
7+
return 1;
8+
}
9+
10+
int main() {
11+
return 0;
12+
}

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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,8 @@ void AMDGPUTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
761761
if (EnableLowerModuleLDS)
762762
PM.addPass(AMDGPULowerModuleLDSPass(*this));
763763
if (EnableAMDGPUAttributor && Level != OptimizationLevel::O0)
764-
PM.addPass(AMDGPUAttributorPass(*this));
764+
PM.addPass(
765+
AMDGPUAttributorPass(*this, AMDGPUAttributorOptions{true}));
765766
});
766767

767768
PB.registerRegClassFilterParsingCallback(

0 commit comments

Comments
 (0)