aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/flow.c
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-05-13 21:53:43 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-05-19 05:27:51 +0200
commit8c24aa51b70cf1fbbb5ff8fbd90f6bdc482d7e2f (patch)
tree9aaa19e9c91e3a3f54c5ac62847003726d61fa3d /flow.c
parente35efe330c6ae7d154197c29b127560d569016d0 (diff)
downloadsparse-dev-8c24aa51b70cf1fbbb5ff8fbd90f6bdc482d7e2f.tar.gz
fix: kill old branch in insert_branch()
insert_branch() is called after an optimization has detected an opportunity to convert a switch or a conditional branch into an unconditional branch (for example because the condition is a constant). It does this by removing the BB's last instruction and then allocate a new unconditional branch which is added at the end of the BB. The old instruction is simply discarded. Since the discarded instruction is one with a condition we must insure that the associated usage is also removed (for example, by calling kill_instruction()). But currently kill_instruction() is called, just after the call to insert_branch(), only at a single place. The 4 other places where insert_branch() is called do nothing with the removed instruction and it's condition's usage. As consequence, instructions that are dead are not removed since it still wrongly has an user. Fix this by adding a call to kill_instruction() in insert_branch() itself (and make the function description more exact). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'flow.c')
-rw-r--r--flow.c1
1 files changed, 0 insertions, 1 deletions
diff --git a/flow.c b/flow.c
index 94a8ec74..b3a657cb 100644
--- a/flow.c
+++ b/flow.c
@@ -226,7 +226,6 @@ try_to_rewrite_target:
if (bb_list_size(target->parents) != 1)
return retval;
insert_branch(target, insn, final);
- kill_instruction(insn);
return 1;
}