[PATCH] avoid deadborn loads & stores

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 linearize.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/linearize.c b/linearize.c
index 54cdf116f..be0e811f2 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);
-- 
2.16.2

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux