When simplifying memops, it's needed to check if the memops is a volatile access or not. This is currently done by checking insn->type->ctype.modifiers & MOD_VOLATILE which is rather long but also incorrect for bitfields. Prepare to fix this by adding a flag to struct instruction directly telling if the access is volatile. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- flow.c | 2 +- linearize.c | 2 ++ linearize.h | 1 + memops.c | 4 ++-- simplify.c | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/flow.c b/flow.c index 9483938fb..3796c75fa 100644 --- a/flow.c +++ b/flow.c @@ -174,7 +174,7 @@ static int bb_has_side_effects(struct basic_block *bb) case OP_LOAD: if (!insn->type) return 1; - if (insn->type->ctype.modifiers & MOD_VOLATILE) + if (insn->is_volatile) return 1; continue; diff --git a/linearize.c b/linearize.c index 2e9a56383..1444e655b 100644 --- a/linearize.c +++ b/linearize.c @@ -946,6 +946,7 @@ static pseudo_t add_load(struct entrypoint *ep, struct access_data *ad) insn->target = new; insn->offset = ad->offset; + insn->is_volatile = insn->type && (insn->type->ctype.modifiers & MOD_VOLATILE); use_pseudo(insn, ad->address, &insn->src); add_one_insn(ep, insn); return new; @@ -961,6 +962,7 @@ static void add_store(struct entrypoint *ep, struct access_data *ad, pseudo_t va store = alloc_typed_instruction(OP_STORE, ad->btype); store->offset = ad->offset; + store->is_volatile = store->type && (store->type->ctype.modifiers & MOD_VOLATILE); use_pseudo(store, value, &store->target); use_pseudo(store, ad->address, &store->src); add_one_insn(ep, store); diff --git a/linearize.h b/linearize.h index f7b5c3f44..d72051e4c 100644 --- a/linearize.h +++ b/linearize.h @@ -112,6 +112,7 @@ struct instruction { struct /* memops */ { pseudo_t addr; unsigned int offset; + unsigned int is_volatile:1; }; struct /* binops and sel */ { pseudo_t src1, src2, src3; diff --git a/memops.c b/memops.c index df2e4d6c2..7732b5858 100644 --- a/memops.c +++ b/memops.c @@ -99,7 +99,7 @@ static void simplify_loads(struct basic_block *bb) /* Check for illegal offsets.. */ check_access(insn); - if (insn->type->ctype.modifiers & MOD_VOLATILE) + if (insn->is_volatile) continue; RECURSE_PTR_REVERSE(insn, dom) { @@ -160,7 +160,7 @@ static void kill_dominated_stores(struct basic_block *bb) if (!insn->type) continue; - if (insn->type->ctype.modifiers & MOD_VOLATILE) + if (insn->is_volatile) continue; local = local_pseudo(pseudo); diff --git a/simplify.c b/simplify.c index ef98b205a..0e9b0381f 100644 --- a/simplify.c +++ b/simplify.c @@ -289,7 +289,7 @@ int kill_insn(struct instruction *insn, int force) break; case OP_LOAD: - if (!force && insn->type->ctype.modifiers & MOD_VOLATILE) + if (!force && insn->is_volatile) return 0; kill_use(&insn->src); break; -- 2.18.0