Skip to content

Commit 981aa6f

Browse files
authored
[AMDGPU] Fix incorrect stepping in gdb for amdgcn.end.cf intrinsic. (#83010)
After #73958 gdb.rocm/lane-execution.exp test started to fail due to incorrect debug location. This is kind of a revert patch.
1 parent 2252c5c commit 981aa6f

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

llvm/lib/Target/AMDGPU/SIAnnotateControlFlow.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,12 @@ bool SIAnnotateControlFlow::closeControlFlow(BasicBlock *BB) {
336336
// Split edge to make Def dominate Use
337337
FirstInsertionPt = SplitEdge(DefBB, BB, DT, LI)->getFirstInsertionPt();
338338
}
339-
IRBuilder<>(FirstInsertionPt->getParent(), FirstInsertionPt)
340-
.CreateCall(EndCf, {Exec});
339+
IRBuilder<> IRB(FirstInsertionPt->getParent(), FirstInsertionPt);
340+
// TODO: StructurizeCFG 'Flow' blocks have debug locations from the
341+
// condition, for now just avoid copying these DebugLocs so that stepping
342+
// out of the then/else block in a debugger doesn't step to the condition.
343+
IRB.SetCurrentDebugLocation(DebugLoc());
344+
IRB.CreateCall(EndCf, {Exec});
341345
}
342346

343347
return true;

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ define amdgpu_ps i32 @if_else(i32 %0) !dbg !5 {
2323
; OPT-NEXT: br label [[FLOW]], !dbg [[DBG16:![0-9]+]]
2424
; OPT: exit:
2525
; OPT-NEXT: [[RET:%.*]] = phi i32 [ [[TMP5]], [[FLOW]] ], [ 42, [[TRUE]] ], !dbg [[DBG17:![0-9]+]]
26-
; OPT-NEXT: call void @llvm.amdgcn.end.cf.i64(i64 [[TMP8]]), !dbg [[DBG18:![0-9]+]]
26+
; OPT-NEXT: call void @llvm.amdgcn.end.cf.i64(i64 [[TMP8]])
2727
; OPT-NEXT: tail call void @llvm.dbg.value(metadata i32 [[RET]], metadata [[META11:![0-9]+]], metadata !DIExpression()), !dbg [[DBG17]]
28-
; OPT-NEXT: ret i32 [[RET]], !dbg [[DBG18]]
28+
; OPT-NEXT: ret i32 [[RET]], !dbg [[DBG18:![0-9]+]]
2929
;
3030
%c = icmp eq i32 %0, 0, !dbg !13
3131
tail call void @llvm.dbg.value(metadata i1 %c, metadata !9, metadata !DIExpression()), !dbg !13
@@ -65,13 +65,13 @@ define amdgpu_ps void @loop_if_break(i32 %n) !dbg !19 {
6565
; OPT: Flow:
6666
; OPT-NEXT: [[TMP3]] = phi i32 [ [[I_NEXT]], [[LOOP_BODY]] ], [ undef, [[LOOP]] ]
6767
; OPT-NEXT: [[TMP4:%.*]] = phi i1 [ false, [[LOOP_BODY]] ], [ true, [[LOOP]] ]
68-
; OPT-NEXT: call void @llvm.amdgcn.end.cf.i64(i64 [[TMP2]]), !dbg [[DBG27]]
68+
; OPT-NEXT: call void @llvm.amdgcn.end.cf.i64(i64 [[TMP2]])
6969
; OPT-NEXT: [[TMP5]] = call i64 @llvm.amdgcn.if.break.i64(i1 [[TMP4]], i64 [[PHI_BROKEN]]), !dbg [[DBG27]]
7070
; OPT-NEXT: [[TMP6:%.*]] = call i1 @llvm.amdgcn.loop.i64(i64 [[TMP5]]), !dbg [[DBG27]]
7171
; OPT-NEXT: br i1 [[TMP6]], label [[EXIT:%.*]], label [[LOOP]], !dbg [[DBG27]]
7272
; OPT: exit:
73-
; OPT-NEXT: call void @llvm.amdgcn.end.cf.i64(i64 [[TMP5]]), !dbg [[DBG30:![0-9]+]]
74-
; OPT-NEXT: ret void, !dbg [[DBG30]]
73+
; OPT-NEXT: call void @llvm.amdgcn.end.cf.i64(i64 [[TMP5]])
74+
; OPT-NEXT: ret void, !dbg [[DBG30:![0-9]+]]
7575
;
7676
entry:
7777
br label %loop, !dbg !24

0 commit comments

Comments
 (0)