Skip to content

Commit

Permalink
Optimize CFG by allowing empty non-exception edged BB with one path t…
Browse files Browse the repository at this point in the history
…o merge

with that one path BB.  In a sense you can think of it as an airbubble in that
edge!  Bleed it!
enebo committed Nov 29, 2017
1 parent a0fd348 commit 64ff128
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/src/main/java/org/jruby/ir/representations/CFG.java
Original file line number Diff line number Diff line change
@@ -524,7 +524,11 @@ public void collapseStraightLineBBs() {
if (!mergedBBs.contains(b) && outDegree(b) == 1) {
for (Edge<BasicBlock> e : getOutgoingEdges(b)) {
BasicBlock outB = e.getDestination().getData();
if (e.getType() != EdgeType.EXCEPTION && inDegree(outB) == 1 && mergeBBs(b, outB)) {

// 1:1 BBs can just be one since there is only one place to go. An empty entering any BB can merge
// since the empty one does nothing (Note: mergeBBs uses empty as destination impl-wise but outcome
// is the same).
if (e.getType() != EdgeType.EXCEPTION && (inDegree(outB) == 1 || b.isEmpty()) && mergeBBs(b, outB)) {
mergedBBs.add(outB);
}
}

0 comments on commit 64ff128

Please sign in to comment.