Skip to content

Commit 63ec93f

Browse files
committed
minimize fix
1 parent ea867d1 commit 63ec93f

File tree

2 files changed

+18
-21
lines changed

2 files changed

+18
-21
lines changed

llvm/lib/Target/AMDGPU/SIAnnotateControlFlow.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ bool SIAnnotateControlFlow::openIf(BranchInst *Term) {
207207
return false;
208208

209209
IRBuilder<> IRB(Term);
210-
IRB.SetCurrentDebugLocation(DebugLoc());
211210
Value *IfCall = IRB.CreateCall(If, {Term->getCondition()});
212211
Value *Cond = IRB.CreateExtractValue(IfCall, {0});
213212
Value *Mask = IRB.CreateExtractValue(IfCall, {1});
@@ -223,7 +222,6 @@ bool SIAnnotateControlFlow::insertElse(BranchInst *Term) {
223222
}
224223

225224
IRBuilder<> IRB(Term);
226-
IRB.SetCurrentDebugLocation(DebugLoc());
227225
Value *ElseCall = IRB.CreateCall(Else, {popSaved()});
228226
Value *Cond = IRB.CreateExtractValue(ElseCall, {0});
229227
Value *Mask = IRB.CreateExtractValue(ElseCall, {1});
@@ -237,9 +235,7 @@ Value *SIAnnotateControlFlow::handleLoopCondition(
237235
Value *Cond, PHINode *Broken, llvm::Loop *L, BranchInst *Term) {
238236

239237
auto CreateBreak = [this, Cond, Broken](Instruction *I) -> CallInst * {
240-
IRBuilder<> IRB(I);
241-
IRB.SetCurrentDebugLocation(DebugLoc());
242-
return IRB.CreateCall(IfBreak, {Cond, Broken});
238+
return IRBuilder<>(I).CreateCall(IfBreak, {Cond, Broken});
243239
};
244240

245241
if (Instruction *Inst = dyn_cast<Instruction>(Cond)) {
@@ -300,9 +296,7 @@ bool SIAnnotateControlFlow::handleLoop(BranchInst *Term) {
300296
Broken->addIncoming(PHIValue, Pred);
301297
}
302298

303-
IRBuilder<> IRB(Term);
304-
IRB.SetCurrentDebugLocation(DebugLoc());
305-
CallInst *LoopCall = IRB.CreateCall(Loop, {Arg});
299+
CallInst *LoopCall = IRBuilder<>(Term).CreateCall(Loop, {Arg});
306300
Term->setCondition(LoopCall);
307301

308302
push(Term->getSuccessor(0), Arg);
@@ -343,6 +337,9 @@ bool SIAnnotateControlFlow::closeControlFlow(BasicBlock *BB) {
343337
FirstInsertionPt = SplitEdge(DefBB, BB, DT, LI)->getFirstInsertionPt();
344338
}
345339
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.
346343
IRB.SetCurrentDebugLocation(DebugLoc());
347344
IRB.CreateCall(EndCf, {Exec});
348345
}

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ define amdgpu_ps i32 @if_else(i32 %0) !dbg !5 {
77
; OPT-SAME: i32 [[TMP0:%.*]]) !dbg [[DBG5:![0-9]+]] {
88
; OPT-NEXT: [[C:%.*]] = icmp ne i32 [[TMP0]], 0, !dbg [[DBG13:![0-9]+]]
99
; OPT-NEXT: tail call void @llvm.dbg.value(metadata i1 [[C]], metadata [[META9:![0-9]+]], metadata !DIExpression()), !dbg [[DBG13]]
10-
; OPT-NEXT: [[TMP2:%.*]] = call { i1, i64 } @llvm.amdgcn.if.i64(i1 [[C]])
11-
; OPT-NEXT: [[TMP3:%.*]] = extractvalue { i1, i64 } [[TMP2]], 0
12-
; OPT-NEXT: [[TMP4:%.*]] = extractvalue { i1, i64 } [[TMP2]], 1
13-
; OPT-NEXT: br i1 [[TMP3]], label [[FALSE:%.*]], label [[FLOW:%.*]], !dbg [[DBG14:![0-9]+]]
10+
; OPT-NEXT: [[TMP2:%.*]] = call { i1, i64 } @llvm.amdgcn.if.i64(i1 [[C]]), !dbg [[DBG14:![0-9]+]]
11+
; OPT-NEXT: [[TMP3:%.*]] = extractvalue { i1, i64 } [[TMP2]], 0, !dbg [[DBG14]]
12+
; OPT-NEXT: [[TMP4:%.*]] = extractvalue { i1, i64 } [[TMP2]], 1, !dbg [[DBG14]]
13+
; OPT-NEXT: br i1 [[TMP3]], label [[FALSE:%.*]], label [[FLOW:%.*]], !dbg [[DBG14]]
1414
; OPT: Flow:
1515
; OPT-NEXT: [[TMP5:%.*]] = phi i32 [ 33, [[FALSE]] ], [ undef, [[TMP1:%.*]] ]
16-
; OPT-NEXT: [[TMP6:%.*]] = call { i1, i64 } @llvm.amdgcn.else.i64.i64(i64 [[TMP4]])
17-
; OPT-NEXT: [[TMP7:%.*]] = extractvalue { i1, i64 } [[TMP6]], 0
18-
; OPT-NEXT: [[TMP8:%.*]] = extractvalue { i1, i64 } [[TMP6]], 1
16+
; OPT-NEXT: [[TMP6:%.*]] = call { i1, i64 } @llvm.amdgcn.else.i64.i64(i64 [[TMP4]]), !dbg [[DBG14]]
17+
; OPT-NEXT: [[TMP7:%.*]] = extractvalue { i1, i64 } [[TMP6]], 0, !dbg [[DBG14]]
18+
; OPT-NEXT: [[TMP8:%.*]] = extractvalue { i1, i64 } [[TMP6]], 1, !dbg [[DBG14]]
1919
; OPT-NEXT: br i1 [[TMP7]], label [[TRUE:%.*]], label [[EXIT:%.*]], !dbg [[DBG14]]
2020
; OPT: true:
2121
; OPT-NEXT: br label [[EXIT]], !dbg [[DBG15:![0-9]+]]
@@ -54,10 +54,10 @@ define amdgpu_ps void @loop_if_break(i32 %n) !dbg !19 {
5454
; OPT-NEXT: tail call void @llvm.dbg.value(metadata i32 [[I]], metadata [[META21:![0-9]+]], metadata !DIExpression()), !dbg [[DBG25]]
5555
; OPT-NEXT: [[C:%.*]] = icmp ugt i32 [[I]], 0, !dbg [[DBG26:![0-9]+]]
5656
; OPT-NEXT: tail call void @llvm.dbg.value(metadata i1 [[C]], metadata [[META22:![0-9]+]], metadata !DIExpression()), !dbg [[DBG26]]
57-
; OPT-NEXT: [[TMP0:%.*]] = call { i1, i64 } @llvm.amdgcn.if.i64(i1 [[C]])
58-
; OPT-NEXT: [[TMP1:%.*]] = extractvalue { i1, i64 } [[TMP0]], 0
59-
; OPT-NEXT: [[TMP2:%.*]] = extractvalue { i1, i64 } [[TMP0]], 1
60-
; OPT-NEXT: br i1 [[TMP1]], label [[LOOP_BODY:%.*]], label [[FLOW]], !dbg [[DBG27:![0-9]+]]
57+
; OPT-NEXT: [[TMP0:%.*]] = call { i1, i64 } @llvm.amdgcn.if.i64(i1 [[C]]), !dbg [[DBG27:![0-9]+]]
58+
; OPT-NEXT: [[TMP1:%.*]] = extractvalue { i1, i64 } [[TMP0]], 0, !dbg [[DBG27]]
59+
; OPT-NEXT: [[TMP2:%.*]] = extractvalue { i1, i64 } [[TMP0]], 1, !dbg [[DBG27]]
60+
; OPT-NEXT: br i1 [[TMP1]], label [[LOOP_BODY:%.*]], label [[FLOW]], !dbg [[DBG27]]
6161
; OPT: loop_body:
6262
; OPT-NEXT: [[I_NEXT:%.*]] = sub i32 [[I]], 1, !dbg [[DBG28:![0-9]+]]
6363
; OPT-NEXT: tail call void @llvm.dbg.value(metadata i32 [[I_NEXT]], metadata [[META23:![0-9]+]], metadata !DIExpression()), !dbg [[DBG28]]
@@ -66,8 +66,8 @@ define amdgpu_ps void @loop_if_break(i32 %n) !dbg !19 {
6666
; OPT-NEXT: [[TMP3]] = phi i32 [ [[I_NEXT]], [[LOOP_BODY]] ], [ undef, [[LOOP]] ]
6767
; OPT-NEXT: [[TMP4:%.*]] = phi i1 [ false, [[LOOP_BODY]] ], [ true, [[LOOP]] ]
6868
; OPT-NEXT: call void @llvm.amdgcn.end.cf.i64(i64 [[TMP2]])
69-
; OPT-NEXT: [[TMP5]] = call i64 @llvm.amdgcn.if.break.i64(i1 [[TMP4]], i64 [[PHI_BROKEN]])
70-
; OPT-NEXT: [[TMP6:%.*]] = call i1 @llvm.amdgcn.loop.i64(i64 [[TMP5]])
69+
; OPT-NEXT: [[TMP5]] = call i64 @llvm.amdgcn.if.break.i64(i1 [[TMP4]], i64 [[PHI_BROKEN]]), !dbg [[DBG27]]
70+
; 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:
7373
; OPT-NEXT: call void @llvm.amdgcn.end.cf.i64(i64 [[TMP5]])

0 commit comments

Comments
 (0)