Skip to content

Commit

Permalink
Fix a couple of bugs in basic block elimination.
Browse files Browse the repository at this point in the history
We accidentally failed to eliminate some blocks we should have in one
case, and as efficiently as we could in another.
  • Loading branch information
jnthn committed Mar 14, 2015
1 parent d515ea9 commit f1b8c16
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/spesh/graph.c
Expand Up @@ -535,14 +535,14 @@ static void build_cfg(MVMThreadContext *tc, MVMSpeshGraph *g, MVMStaticFrame *sf
* pre-requisite for dominance computation. */
void MVM_spesh_graph_eliminate_unreachable(MVMThreadContext *tc, MVMSpeshGraph *g, MVMSpeshOnBBRemoval on_remove) {
/* Iterate to fixed point. */
MVMint8 *seen = MVM_malloc(g->num_bbs);
MVMint32 orig_bbs = g->num_bbs;
MVMint8 *seen = MVM_malloc(orig_bbs);
MVMint8 death = 1;
while (death) {
/* First pass: mark every basic block that is the entry point or the
* successor of some other block. */
MVMSpeshBB *cur_bb = g->entry;
memset(seen, 0, g->num_bbs);
memset(seen, 0, orig_bbs);
seen[0] = 1;
while (cur_bb) {
MVMuint16 i;
Expand All @@ -563,7 +563,9 @@ void MVM_spesh_graph_eliminate_unreachable(MVMThreadContext *tc, MVMSpeshGraph *
g->num_bbs--;
death = 1;
}
cur_bb = cur_bb->linear_next;
else {
cur_bb = cur_bb->linear_next;
}
}
}
MVM_free(seen);
Expand Down

0 comments on commit f1b8c16

Please sign in to comment.