diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-11-11 01:41:12 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-11-11 01:41:12 +0100 |
commit | d020cf332099fd18862dff6193fa633ac3957111 (patch) | |
tree | 5d38278fe9e41e5162d8d1fdda9737e4507a91ee | |
parent | 98469166098170fc67d3eb043656c3e79190b31f (diff) | |
parent | c4d63655e576dd59a88bc92f874a1a80f3c4cfa7 (diff) | |
download | sparse-d020cf332099fd18862dff6193fa633ac3957111.tar.gz |
Merge branch 'debug'
* do not call simplify_instruction() on removed instruction
* add debug helpers: show_insn_bb() & show_insn_entry()
-rw-r--r-- | linearize.c | 18 | ||||
-rw-r--r-- | optimize.c | 2 | ||||
-rw-r--r-- | simplify.c | 3 |
3 files changed, 20 insertions, 3 deletions
diff --git a/linearize.c b/linearize.c index d3c009b3..ab91113d 100644 --- a/linearize.c +++ b/linearize.c @@ -563,6 +563,15 @@ void show_bb(struct basic_block *bb) printf("\tEND\n"); } +/// +// show BB of non-removed instruction +void show_insn_bb(struct instruction *insn) +{ + if (!insn || !insn->bb) + return; + show_bb(insn->bb); +} + static void show_symbol_usage(pseudo_t pseudo) { struct pseudo_user *pu; @@ -610,6 +619,15 @@ void show_entry(struct entrypoint *ep) printf("\n"); } +/// +// show the function containing the instruction but only if not already removed. +void show_insn_entry(struct instruction *insn) +{ + if (!insn || !insn->bb || !insn->bb->ep) + return; + show_entry(insn->bb->ep); +} + static void bind_label(struct symbol *label, struct basic_block *bb, struct position pos) { if (label->bb_target) @@ -34,6 +34,8 @@ static void clean_up_insns(struct entrypoint *ep) FOR_EACH_PTR(ep->bbs, bb) { struct instruction *insn; FOR_EACH_PTR(bb->insns, insn) { + if (!insn->bb) + continue; repeat_phase |= simplify_instruction(insn); if (!insn->bb) continue; @@ -2117,9 +2117,6 @@ int simplify_instruction(struct instruction *insn) unsigned flags; int changed = 0; - if (!insn->bb) - return 0; - flags = opcode_table[insn->opcode].flags; if (flags & OPF_TARGET) { if (!has_users(insn->target)) |