aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/memops.c
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-03-14 00:29:16 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-03-14 16:29:38 +0100
commit9b69a4bfa543068f5bfd23edd2c7b2b41300cb9a (patch)
tree7a2168457275e2bd8191e25133ad907d3ffc631d /memops.c
parentd2ca9a9ceb2cb6437b3b01fc5b3819df4e071e34 (diff)
downloadsparse-dev-9b69a4bfa543068f5bfd23edd2c7b2b41300cb9a.tar.gz
cleanup deadborn phi-sources
In simplify_loads(), phisrcs are created in find_dominating_parents() and are then supposed to be used in rewrite_load_instruction(). However, it may happen (quite often) that find_dominating_parents() find a dominator for one of the branch, create a phi-source for it, record it's usage and then doesn't find a dominator in one of other parent branches. In this case, the function returns early and the created phisrcs are simply ignored. These phisrcs can't be simplified away as dead instructions because they still have their usage recorded. Fix this by explicitly remove these ignored phisrcs. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'memops.c')
-rw-r--r--memops.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/memops.c b/memops.c
index 30316391..df2e4d6c 100644
--- a/memops.c
+++ b/memops.c
@@ -134,6 +134,11 @@ static void simplify_loads(struct basic_block *bb)
goto next_load;
}
rewrite_load_instruction(insn, dominators);
+ } else { // cleanup pending phi-sources
+ pseudo_t phi;
+ FOR_EACH_PTR(dominators, phi) {
+ kill_instruction(phi->def);
+ } END_FOR_EACH_PTR(phi);
}
}
next_load: