Skip to content

Commit 52a8bed

Browse files
authored
[DebugInfo][RemoveDIs] Adjust AMDGPU passes to work with DPValues (#78736)
This patch tweaks two AMDGPU passes to use iterators rather than instruction pointers for expressing an insertion point. This is needed to accurately support DPValues, the non-instruction storage object for debug-info. Two tests were sensitive to this change (variable assignments were being put in the wrong place), and I've added extra run-lines with the "try new debug-info..." flag. These get tested on our public buildbot to ensure they continue to work accurately.
1 parent 70823fe commit 52a8bed

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

llvm/lib/Target/AMDGPU/AMDGPULowerKernelArguments.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static bool lowerKernelArguments(Function &F, const TargetMachine &TM) {
106106
LLVMContext &Ctx = F.getParent()->getContext();
107107
const DataLayout &DL = F.getParent()->getDataLayout();
108108
BasicBlock &EntryBlock = *F.begin();
109-
IRBuilder<> Builder(&*getInsertPt(EntryBlock));
109+
IRBuilder<> Builder(&EntryBlock, getInsertPt(EntryBlock));
110110

111111
const Align KernArgBaseAlign(16); // FIXME: Increase if necessary
112112
const uint64_t BaseOffset = ST.getExplicitKernelArgOffset();

llvm/lib/Target/AMDGPU/SIAnnotateControlFlow.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,15 +329,16 @@ bool SIAnnotateControlFlow::closeControlFlow(BasicBlock *BB) {
329329
}
330330

331331
Value *Exec = popSaved();
332-
Instruction *FirstInsertionPt = &*BB->getFirstInsertionPt();
332+
BasicBlock::iterator FirstInsertionPt = BB->getFirstInsertionPt();
333333
if (!isa<UndefValue>(Exec) && !isa<UnreachableInst>(FirstInsertionPt)) {
334334
Instruction *ExecDef = cast<Instruction>(Exec);
335335
BasicBlock *DefBB = ExecDef->getParent();
336336
if (!DT->dominates(DefBB, BB)) {
337337
// Split edge to make Def dominate Use
338-
FirstInsertionPt = &*SplitEdge(DefBB, BB, DT, LI)->getFirstInsertionPt();
338+
FirstInsertionPt = SplitEdge(DefBB, BB, DT, LI)->getFirstInsertionPt();
339339
}
340-
IRBuilder<>(FirstInsertionPt).CreateCall(EndCf, {Exec});
340+
IRBuilder<>(FirstInsertionPt->getParent(), FirstInsertionPt)
341+
.CreateCall(EndCf, {Exec});
341342
}
342343

343344
return true;

llvm/test/CodeGen/AMDGPU/llvm.dbg.value.ll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
; RUN: llc -O0 -mtriple=amdgcn-unknown-amdhsa -verify-machineinstrs < %s | FileCheck -check-prefixes=GCN,NOOPT %s
22
; RUN: llc -mtriple=amdgcn-unknown-amdhsa -verify-machineinstrs < %s | FileCheck -check-prefixes=GCN,OPT %s
33

4+
; RUN: llc -O0 -mtriple=amdgcn-unknown-amdhsa -verify-machineinstrs < %s --try-experimental-debuginfo-iterators | FileCheck -check-prefixes=GCN,NOOPT %s
5+
; RUN: llc -mtriple=amdgcn-unknown-amdhsa -verify-machineinstrs < %s --try-experimental-debuginfo-iterators | FileCheck -check-prefixes=GCN,OPT %s
6+
47
; GCN-LABEL: {{^}}test_debug_value:
58
; NOOPT: .loc 1 1 42 prologue_end ; /tmp/test_debug_value.cl:1:42
69
; NOOPT-NEXT: s_load_dwordx2 s[4:5], s[6:7], 0x0

llvm/test/CodeGen/AMDGPU/si-annotate-dbg-info.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
22
; RUN: opt -mtriple=amdgcn-- -S -structurizecfg -si-annotate-control-flow %s | FileCheck -check-prefix=OPT %s
3+
; RUN: opt -mtriple=amdgcn-- -S -structurizecfg -si-annotate-control-flow %s --try-experimental-debuginfo-iterators | FileCheck -check-prefix=OPT %s
34

45
define amdgpu_ps i32 @if_else(i32 %0) !dbg !5 {
56
; OPT-LABEL: define amdgpu_ps i32 @if_else(

0 commit comments

Comments
 (0)