Skip to content

Commit f6e6a70

Browse files
jgu222sys_zuul
authored andcommitted
Better error messages when goto and non-goto branching
instructions cross their ranges. The structurier assumes no crossing and works on goto branching only. Change-Id: I543de8b87430d3f230d88e2230ab0d8f6df05fad
1 parent 25022d5 commit f6e6a70

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

visa/CFGStructurizer.cpp

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,10 +1553,30 @@ ANodeHG* CFGStructurizer::getEnclosingANodeHG(ANode *AN)
15531553
}
15541554

15551555
ANodeHG *hg = (ANodeHG *)pred->parent;
1556-
MUST_BE_TRUE(hg->ANStackIx >= 0, "ANodeHG's index is wrong");
1557-
if (ix > hg->ANStackIx)
1556+
if (hg)
15581557
{
1559-
ix = hg->ANStackIx;
1558+
MUST_BE_TRUE(hg->ANStackIx >= 0, "ANodeHG's index is wrong");
1559+
if (ix > hg->ANStackIx)
1560+
{
1561+
ix = hg->ANStackIx;
1562+
}
1563+
}
1564+
else
1565+
{
1566+
// Error message
1567+
G4_BB* predBB = pred->getBeginBB();
1568+
G4_INST* predGoto = getGotoInst(predBB);
1569+
1570+
// If predGoto is null, it means that a non-goto branching inst like jmpi jumps
1571+
// into a range of goto instrutions, such as the following:
1572+
// jmp A
1573+
// goto B
1574+
// A:
1575+
// ...
1576+
// B:
1577+
//
1578+
MUST_BE_TRUE(predGoto != nullptr, "Error: Non-goto (like jmp) and goto crossing !");
1579+
MUST_BE_TRUE(false, "Error: unknown control flow in the program.");
15601580
}
15611581
}
15621582
// No need to check succs as forward goto will be handled later

0 commit comments

Comments
 (0)