Skip to content

Commit ba1e418

Browse files
igcbotpratikashar
andauthored
Set CISA offset correctly when transforming goto/join to if/else/endif. (#22)
This is required so debugger can set breakpoint at corresponding source lines. Co-authored-by: Pratik J Ashar <[email protected]>
1 parent 0cf20a2 commit ba1e418

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

visa/CFGStructurizer.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3275,7 +3275,11 @@ void CFGStructurizer::convertIf(ANodeHG *node, G4_BB *nextJoinBB)
32753275

32763276
G4_INST* endifInst = CFG->builder->createInternalCFInst(
32773277
NULL, G4_endif, execSize, nextJoinLabel, NULL, InstOpt_NoOpt);
3278-
3278+
// Set CISA index link here explicitly since not doing so causes
3279+
// endif to merge with immediately following line. This prevents
3280+
// debugger from setting bp on src line immediately following
3281+
// the endif.
3282+
endifInst->inheritDIFrom(gotoInst);
32793283
insertAtBegin(exit, endifInst);
32803284

32813285
// jip = uip = endif
@@ -3284,6 +3288,7 @@ void CFGStructurizer::convertIf(ANodeHG *node, G4_BB *nextJoinBB)
32843288
pred->setState(pred->getState() == PredState_Plus ? PredState_Minus : PredState_Plus);
32853289
G4_INST* ifInst = CFG->builder->createInternalCFInst(
32863290
pred, G4_if, execSize, endifLabel, endifLabel, InstOpt_NoOpt);
3291+
ifInst->inheritDIFrom(endifInst);
32873292
begin->pop_back();
32883293
begin->push_back(ifInst);
32893294
if (isUniform)
@@ -3380,7 +3385,7 @@ void CFGStructurizer::convertIf(ANodeHG *node, G4_BB *nextJoinBB)
33803385
// instruction.
33813386
auto endifInst = CFG->builder->createInternalCFInst(
33823387
NULL, G4_endif, execSize, nextJoinLabel, NULL, InstOpt_NoOpt);
3383-
3388+
endifInst->inheritDIFrom(gotoInst);
33843389
insertAtBegin(exit, endifInst);
33853390

33863391
G4_BB *elseFirstBB = elseNode->getBeginBB();
@@ -3392,6 +3397,7 @@ void CFGStructurizer::convertIf(ANodeHG *node, G4_BB *nextJoinBB)
33923397
// if instruction : jip = else_label, uip = endif
33933398
G4_INST* ifInst = CFG->builder->createInternalCFInst(
33943399
pred, G4_if, execSize, elseLabel, endifLabel, InstOpt_NoOpt);
3400+
ifInst->inheritDIFrom(endifInst);
33953401
begin->pop_back();
33963402
begin->push_back(ifInst);
33973403

@@ -3411,6 +3417,7 @@ void CFGStructurizer::convertIf(ANodeHG *node, G4_BB *nextJoinBB)
34113417
G4_INST *thenGoto = newThenLastBB->back();
34123418
G4_INST* elseInst = CFG->builder->createInternalCFInst(
34133419
NULL, G4_else, execSize, endifLabel, endifLabel, InstOpt_NoOpt);
3420+
elseInst->inheritDIFrom(endifInst);
34143421
if (thenGoto->opcode() == G4_goto)
34153422
{
34163423
newThenLastBB->pop_back();
@@ -3498,6 +3505,7 @@ void CFGStructurizer::convertDoWhile(ANodeHG *node, G4_BB *nextJoinBB)
34983505
// jip = uip = do
34993506
G4_INST *whileInst = CFG->builder->createInternalCFInst(
35003507
gotoInst->getPredicate(), G4_while, execSize, doLabel, doLabel, InstOpt_NoOpt);
3508+
whileInst->inheritDIFrom(end->back());
35013509
end->pop_back();
35023510
end->push_back(whileInst);
35033511
if (isUniform)
@@ -3649,6 +3657,7 @@ void CFGStructurizer::convertGoto(ANodeBB *node, G4_BB *nextJoinBB)
36493657
G4_INST* breakInst = CFG->builder->createInternalCFInst(
36503658
gotoInst->getPredicate(), G4_break, execSize,
36513659
innerBlock->getLabel(), whilebb->getLabel(), InstOpt_NoOpt);
3660+
breakInst->inheritDIFrom(gotoInst);
36523661
beginbb->pop_back();
36533662
beginbb->push_back(breakInst);
36543663
if (isUniform)

0 commit comments

Comments
 (0)