Skip to content

Commit 8d3736d

Browse files
committed
[AMDGPU] Only run AMDGPUPrintfRuntimeBindingPass at non-prelink phase
The pass is registered in a pipeline that will run at none LTO, LTO prelink, as well as LTO postlink phase. It uses the _current_ number of metadata operands as unique id for printf handling. However, if two TUs both have `printf`, their unique id will be starting with 1. After they are linked together, the id is no longer unique anymore. To resolve this issue, the pass should not run at LTO pre link stage.
1 parent e5b2be3 commit 8d3736d

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,8 @@ void AMDGPUTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
791791
PB.registerPipelineEarlySimplificationEPCallback(
792792
[](ModulePassManager &PM, OptimizationLevel Level,
793793
ThinOrFullLTOPhase Phase) {
794-
PM.addPass(AMDGPUPrintfRuntimeBindingPass());
794+
if (!isLTOPreLink(Phase))
795+
PM.addPass(AMDGPUPrintfRuntimeBindingPass());
795796

796797
if (Level == OptimizationLevel::O0)
797798
return;

llvm/test/CodeGen/AMDGPU/print-pipeline-passes.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
; PRE-NOT: internalize
1616
; PRE-NOT: amdgpu-attributor
17+
; PRE-NOT: printfToRuntime
1718

1819
define amdgpu_kernel void @kernel() {
1920
entry:

0 commit comments

Comments
 (0)