Skip to content

Commit 6fd952b

Browse files
pratikasharigcbot
authored andcommitted
Renumber subroutines after removing unreachable code.
1 parent a89a198 commit 6fd952b

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

visa/FlowGraph.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,6 +1751,7 @@ void FlowGraph::removeUnreachableBlocks(FuncInfoHashTable& funcInfoHT)
17511751
}
17521752
reassignBlockIDs();
17531753
setPhysicalPredSucc();
1754+
reassignFuncIds(funcInfoHT);
17541755
}
17551756

17561757
// prevent overwriting dump file and indicate compilation order with dump serial number
@@ -2385,6 +2386,18 @@ void FlowGraph::linkDummyBB()
23852386
}
23862387
}
23872388

2389+
//
2390+
// Re-assign function ids as implementation expects them to be consecutive.
2391+
//
2392+
void FlowGraph::reassignFuncIds(FuncInfoHashTable& funcInfoHT)
2393+
{
2394+
unsigned int index = 0;
2395+
for (auto& item : funcInfoHT)
2396+
{
2397+
item.second->setId(index++);
2398+
}
2399+
}
2400+
23882401
//
23892402
// Re-assign block ID so that we can use id to determine the ordering of two blocks in the code layout
23902403
//

visa/FlowGraph.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,11 +1106,20 @@ class FlowGraph
11061106
// Add a dummy BB for multiple-exit flow graph
11071107
//
11081108
void linkDummyBB();
1109+
1110+
//
1111+
// Reassign function ids in case some functions were optimized away as dead code.
1112+
// Implementation uses function id to index in to std::vector so there shouldnt
1113+
// be holds in function ids.
1114+
//
1115+
void reassignFuncIds(FuncInfoHashTable& funcInfoHT);
1116+
11091117
//
11101118
// Re-assign block ID so that we can use id to determine the ordering of two blocks in
11111119
// the code layout
11121120
//
11131121
void reassignBlockIDs();
1122+
11141123
//
11151124
// Remove blocks that are unreachable via control flow of program
11161125
//

0 commit comments

Comments
 (0)