aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-11-13 20:17:42 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-11-17 18:03:24 +0100
commit09474b0a451bd4e3baea5e1a5e04f9b28f644bb3 (patch)
tree70b77d62b9a625e04398903dc1db51e7fa793a8e
parent5a7a06698fe2cd4ccb8d3f1a8585c70e6d8f7531 (diff)
downloadsparse-09474b0a451bd4e3baea5e1a5e04f9b28f644bb3.tar.gz
cfg: add missing REPEAT_CFG_CLEANUP
simplify_branch() & insert_branch() convert a conditional branch into an unconditional one, removing a child which may then become unreachable. However, these function doesn't set REPEAT_CFG_CLEANUP and the unreachable child may not be removed. Fix this by setting the missing REPEAT_CFG_CLEANUP in these functions. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--linearize.c1
-rw-r--r--simplify.c2
2 files changed, 2 insertions, 1 deletions
diff --git a/linearize.c b/linearize.c
index ab91113d..5d800b7f 100644
--- a/linearize.c
+++ b/linearize.c
@@ -726,6 +726,7 @@ void insert_branch(struct basic_block *bb, struct instruction *jmp, struct basic
remove_parent(child, bb);
} END_FOR_EACH_PTR(child);
PACK_PTR_LIST(&bb->children);
+ repeat_phase |= REPEAT_CFG_CLEANUP;
}
diff --git a/simplify.c b/simplify.c
index e58fb6cf..a0e23d6d 100644
--- a/simplify.c
+++ b/simplify.c
@@ -2048,7 +2048,7 @@ static int simplify_branch(struct instruction *insn)
kill_use(&insn->cond);
insn->cond = NULL;
insn->opcode = OP_BR;
- return REPEAT_CSE;
+ return REPEAT_CSE|REPEAT_CFG_CLEANUP;
}
/* Conditional on a SETNE $0 or SETEQ $0 */