diff options
-rw-r--r-- | linearize.h | 17 | ||||
-rw-r--r-- | simplify.c | 2 | ||||
-rw-r--r-- | ssa.c | 1 |
3 files changed, 12 insertions, 8 deletions
diff --git a/linearize.h b/linearize.h index 2c548d43..a77e4b3e 100644 --- a/linearize.h +++ b/linearize.h @@ -160,21 +160,19 @@ struct instruction_list; struct basic_block { struct position pos; unsigned long generation; - union { - int context; - int postorder_nr; /* postorder number */ - int dom_level; /* level in the dominance tree */ - }; struct entrypoint *ep; struct basic_block_list *parents; /* sources */ struct basic_block_list *children; /* destinations */ struct instruction_list *insns; /* Linear list of instructions */ struct basic_block *idom; /* link to the immediate dominator */ + unsigned int nr; /* unique id for label's names */ + int dom_level; /* level in the dominance tree */ struct basic_block_list *doms; /* list of BB idominated by this one */ - struct phi_map *phi_map; struct pseudo_list *needs, *defines; union { - unsigned int nr; /* unique id for label's names */ + struct phi_map *phi_map;/* needed during SSA conversion */ + int postorder_nr; /* postorder number */ + int context; /* needed during context checking */ void *priv; }; }; @@ -249,6 +247,11 @@ static inline int has_use_list(pseudo_t p) return (p && p->type != PSEUDO_VOID && p->type != PSEUDO_UNDEF && p->type != PSEUDO_VAL); } +static inline bool has_definition(pseudo_t p) +{ + return p->type == PSEUDO_REG || p->type == PSEUDO_PHI; +} + static inline int pseudo_user_list_size(struct pseudo_user_list *list) { return ptr_list_size((struct ptr_list *)list); @@ -271,7 +271,7 @@ static inline void rem_usage(pseudo_t p, pseudo_t *usep, int kill) { if (has_use_list(p)) { delete_pseudo_user_list_entry(&p->users, usep, 1); - if (kill && !p->users) + if (kill && !p->users && has_definition(p)) kill_instruction(p->def); } } @@ -387,6 +387,7 @@ void ssa_convert(struct entrypoint *ep) int nr = bb->nr; if (nr > last) last = nr; + bb->phi_map = NULL; } END_FOR_EACH_PTR(bb); processed = sset_init(first, last); |