aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-04-23 00:39:04 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-03-18 19:00:26 +0100
commit1af36e611de4d5ba511156a93d54fddcb2ff0268 (patch)
tree18057e220984236999a584f6baef626d75c1817e
parent5953ebb1f87141a268fc9a214b982079d1138410 (diff)
downloadsparse-dev-1af36e611de4d5ba511156a93d54fddcb2ff0268.tar.gz
make remove_usage() more generic
make_usage() kill the corresponding instruction when the last user have been removed. This is often desired but not always. Make a new version __remove_usage() taking a flag telling if we want to kill the instruction or not. Correct-naming-by: Ramsay Jones <ramsay@ramsayjones.plus.com> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--simplify.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/simplify.c b/simplify.c
index e5e555c1..6216caf1 100644
--- a/simplify.c
+++ b/simplify.c
@@ -184,23 +184,28 @@ out:
return count;
}
-static inline void remove_usage(pseudo_t p, pseudo_t *usep)
+static inline void rem_usage(pseudo_t p, pseudo_t *usep, int kill)
{
if (has_use_list(p)) {
if (p->type == PSEUDO_SYM)
repeat_phase |= REPEAT_SYMBOL_CLEANUP;
delete_pseudo_user_list_entry(&p->users, usep, 1);
- if (!p->users)
+ if (kill && !p->users)
kill_instruction(p->def);
}
}
+static inline void remove_usage(pseudo_t p, pseudo_t *usep)
+{
+ rem_usage(p, usep, 1);
+}
+
void kill_use(pseudo_t *usep)
{
if (usep) {
pseudo_t p = *usep;
*usep = VOID;
- remove_usage(p, usep);
+ rem_usage(p, usep, 1);
}
}