aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-07-08 10:03:39 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-08-07 12:18:26 +0200
commit7347750afb894047b5145637cdebd1613c33d64a (patch)
treede0ac73e686725e5cfc7bc8c58c68580606117ed
parentf8b6997ff58a9a057dbd858aa190577fdc4ece45 (diff)
downloadsparse-dev-7347750afb894047b5145637cdebd1613c33d64a.tar.gz
put back the bitfield base type into struct access_data
In commit 48bda7573 ("let struct access_data use a single type"), the members result_type & source_type have been replaced by an unique member 'type', mainly because the role of these members and when they needed to be updated was not clear at all. Now that the situation is much clearer, the second member, used to hold the base type of bitfields, can be put back as it avoid to have to call bitfield_base_type() multiple time. Put back this member into struct access_data and use when appropriate (which remove the now unneeded calls to bitfield_base_type()). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--linearize.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/linearize.c b/linearize.c
index e8d145a7..9a6fd250 100644
--- a/linearize.c
+++ b/linearize.c
@@ -878,6 +878,7 @@ pseudo_t alloc_phi(struct basic_block *source, pseudo_t pseudo, struct symbol *t
*/
struct access_data {
struct symbol *type; // ctype
+ struct symbol *btype; // base type of bitfields
pseudo_t address; // pseudo containing address ..
unsigned int offset; // byte offset
};
@@ -934,14 +935,13 @@ static int linearize_address_gen(struct entrypoint *ep,
static pseudo_t add_load(struct entrypoint *ep, struct access_data *ad)
{
- struct symbol *btype = bitfield_base_type(ad->type);
struct instruction *insn;
pseudo_t new;
if (!ep->active)
return VOID;
- insn = alloc_typed_instruction(OP_LOAD, btype);
+ insn = alloc_typed_instruction(OP_LOAD, ad->btype);
new = alloc_pseudo(insn);
insn->target = new;
@@ -959,7 +959,7 @@ static void add_store(struct entrypoint *ep, struct access_data *ad, pseudo_t va
if (!bb)
return;
- store = alloc_typed_instruction(OP_STORE, bitfield_base_type(ad->type));
+ store = alloc_typed_instruction(OP_STORE, ad->btype);
store->offset = ad->offset;
use_pseudo(store, value, &store->target);
use_pseudo(store, ad->address, &store->src);
@@ -990,12 +990,13 @@ static pseudo_t linearize_store_gen(struct entrypoint *ep,
struct access_data *ad)
{
struct symbol *ctype = ad->type;
- struct symbol *btype = bitfield_base_type(ctype);
+ struct symbol *btype;
pseudo_t store = value;
if (!ep->active)
return VOID;
+ btype = ad->btype = bitfield_base_type(ctype);
if (type_size(btype) != type_size(ctype)) {
pseudo_t orig = add_load(ep, ad);
store = linearize_bitfield_insert(ep, orig, value, ctype, btype);
@@ -1079,12 +1080,13 @@ static pseudo_t linearize_bitfield_extract(struct entrypoint *ep,
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);
+ struct symbol *btype;
pseudo_t new;
if (!ep->active)
return VOID;
+ btype = ad->btype = bitfield_base_type(ctype);
new = add_load(ep, ad);
if (ctype->bit_size != type_size(btype))
new = linearize_bitfield_extract(ep, new, ctype, btype);