aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/memops.c
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-12-01 23:46:56 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2021-03-25 00:11:53 +0100
commit23109ddefaadf1a476ea47d123994e5f073f701e (patch)
treec1016ec418e923d96c64a7909cc9dad566b01077 /memops.c
parente0c12f39daec8b2d13fb84e80033f7d9052374c7 (diff)
downloadsparse-dev-23109ddefaadf1a476ea47d123994e5f073f701e.tar.gz
kill redundant stores (local)
A store is called 'redundant' when the corresponding location already contains the value that will be stored. This patch removes such stores in the case where the memops which make them redundant is in the same basic block. 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 44d90754..f734f6eb 100644
--- a/memops.c
+++ b/memops.c
@@ -213,6 +213,11 @@ static bool try_to_kill_store(pseudo_t pseudo, struct instruction *insn,
/* possible partial dominance? */
if (dominance < 0)
return false;
+ if (insn->target == dom->target && insn->bb == dom->bb) {
+ // found a memop which makes the store redundant
+ kill_instruction_force(insn);
+ return false;
+ }
if (dom->opcode == OP_LOAD)
return false;
if (dom->is_volatile)