Create special empty exit BasicBlock that all BasicBlocks will eventually flow into. All Edges to this 'dummy' BasicBlock will get marked with an edge type of EXIT. Special BasicBlocks worth noting: 1. Exceptions, Returns, Entry(why?) -> ExitBB 2. Returns -> ExitBB
(Stack<ExceptionRegion> nestedExceptionRegions, BasicBlock firstBB,
List<BasicBlock> returnBBs, List<BasicBlock> exceptionBBs, boolean nextIsFallThrough, BasicBlock currBB, BasicBlock entryBB)
| 265 | * 2. Returns -> ExitBB |
| 266 | */ |
| 267 | private BasicBlock buildExitBasicBlock(Stack<ExceptionRegion> nestedExceptionRegions, BasicBlock firstBB, |
| 268 | List<BasicBlock> returnBBs, List<BasicBlock> exceptionBBs, boolean nextIsFallThrough, BasicBlock currBB, BasicBlock entryBB) { |
| 269 | exitBB = createBB(nestedExceptionRegions); |
| 270 | |
| 271 | graph.addEdge(entryBB, exitBB, EdgeType.EXIT); |
| 272 | graph.addEdge(entryBB, firstBB, EdgeType.FALL_THROUGH); |
| 273 | |
| 274 | for (BasicBlock rb : returnBBs) { |
| 275 | graph.addEdge(rb, exitBB, EdgeType.EXIT); |
| 276 | } |
| 277 | |
| 278 | for (BasicBlock rb : exceptionBBs) { |
| 279 | graph.addEdge(rb, exitBB, EdgeType.EXIT); |
| 280 | } |
| 281 | |
| 282 | if (nextIsFallThrough) graph.addEdge(currBB, exitBB, EdgeType.EXIT); |
| 283 | |
| 284 | return exitBB; |
| 285 | } |
| 286 | |
| 287 | public void collapseStraightLineBBs() { |
| 288 | // Collect cfgs in a list first since the cfg/graph API returns an iterator |