diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-03-06 01:50:18 +0100 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-03-18 19:02:28 +0100 |
| commit | 334bae855c8e24f30bfaa911265c0d64cab3432d (patch) | |
| tree | 037049f47af9a5880ec68a2f10193a016c937703 | |
| parent | 1609176c9dbddd280c20a49fce81c9e1dd9b9c78 (diff) | |
| download | sparse-dev-334bae855c8e24f30bfaa911265c0d64cab3432d.tar.gz | |
avoid deadborn loads & stores
During linearization, most kinds of instruction are not generated
if there is no active BB (which mean that these instructions can
never be executed).
However, loads & stores are generated anyway. These dead loads
and stores will then need to be removed which is a bit tricky:
- memops are special and more complex to be removed than
instructions like 'add' and such.
- these instructions exist in 'phantom basic blocks': a BB
which has ia null bb->ep and which doesn't belong to then
entrypoint's ep->bbs. Such blocks are considered as removed
and are never scanned or anything.
Keep things simple and avoid to generate memops in inactive
basic blocks.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
| -rw-r--r-- | linearize.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/linearize.c b/linearize.c index 54cdf116..be0e811f 100644 --- a/linearize.c +++ b/linearize.c @@ -935,6 +935,9 @@ static pseudo_t add_load(struct entrypoint *ep, struct access_data *ad) struct instruction *insn; pseudo_t new; + if (!ep->active) + return VOID; + insn = alloc_typed_instruction(OP_LOAD, btype); new = alloc_pseudo(insn); @@ -968,6 +971,9 @@ static pseudo_t linearize_store_gen(struct entrypoint *ep, struct symbol *btype = bitfield_base_type(ctype); pseudo_t store = value; + if (!ep->active) + return VOID; + if (type_size(btype) != type_size(ctype)) { unsigned int shift = ctype->bit_offset; unsigned int size = ctype->bit_size; @@ -1031,8 +1037,12 @@ static pseudo_t linearize_load_gen(struct entrypoint *ep, struct access_data *ad { struct symbol *ctype = ad->type; struct symbol *btype = bitfield_base_type(ctype); - pseudo_t new = add_load(ep, ad); + pseudo_t new; + + if (!ep->active) + return VOID; + new = add_load(ep, ad); if (ctype->bit_offset) { pseudo_t shift = value_pseudo(ctype->bit_offset); pseudo_t newval = add_binary_op(ep, btype, OP_LSR, new, shift); |
