Skip to content

Commit a838f09

Browse files
jgu222sys_zuul
authored andcommitted
Structurizer requires that the last BB is a return BB. Make sure this condition is met before invoking the structurizer. It not ( should not happen), non-structurized code (goto/join) will be generated instead.
Change-Id: I9b3a3a1f183fb7648f664f4225dc98e0f35412ba
1 parent fe6f5b5 commit a838f09

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

visa/FlowGraph.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,10 @@ void FlowGraph::constructFlowGraph(INST_LIST& instlist)
893893
setPhysicalPredSucc();
894894
if (hasGoto)
895895
{
896-
if (builder->getOption(vISA_EnableStructurizer))
896+
// Structurizer requires that the last BB has no goto (ie, the
897+
// last BB is either a return or an exit).
898+
if (builder->getOption(vISA_EnableStructurizer) &&
899+
!endWithGotoInLastBB())
897900
{
898901
if (builder->getOption(vISA_DumpDotAll))
899902
{

visa/FlowGraph.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,16 @@ class FlowGraph
10941094
}
10951095
}
10961096

1097+
bool endWithGotoInLastBB() const
1098+
{
1099+
if (BBs.empty())
1100+
{
1101+
return false;
1102+
}
1103+
G4_BB* lastBB = back();
1104+
return lastBB->isEndWithGoto();
1105+
}
1106+
10971107
private:
10981108
//
10991109
// Flow group traversal routines

0 commit comments

Comments
 (0)