aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-09-04 13:09:39 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-11-11 17:00:37 +0100
commit9831e680492ec89328a7b9388031a2a5d8636cd5 (patch)
tree8a7224c06167bc66e30543fc9da757717870acb1
parent884802fca5b5751fc7007251d925a775f1d08f41 (diff)
downloadsparse-dev-9831e680492ec89328a7b9388031a2a5d8636cd5.tar.gz
fix: volatile stores must not be simplified
kill_dominated_stores() simplify away redundant stores. Nice but volatile stores are never redundant and must never be simplified away. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--memops.c6
-rw-r--r--validation/memops-volatile.c1
2 files changed, 5 insertions, 2 deletions
diff --git a/memops.c b/memops.c
index aeacdf56..1c845a5f 100644
--- a/memops.c
+++ b/memops.c
@@ -158,8 +158,12 @@ static void kill_dominated_stores(struct basic_block *bb)
if (insn->opcode == OP_STORE) {
struct instruction *dom;
pseudo_t pseudo = insn->src;
- int local = local_pseudo(pseudo);
+ int local;
+
+ if (insn->type->ctype.modifiers & MOD_VOLATILE)
+ continue;
+ local = local_pseudo(pseudo);
RECURSE_PTR_REVERSE(insn, dom) {
int dominance;
if (!dom->bb)
diff --git a/validation/memops-volatile.c b/validation/memops-volatile.c
index 71299f49..15314e1c 100644
--- a/validation/memops-volatile.c
+++ b/validation/memops-volatile.c
@@ -9,7 +9,6 @@ static int foo(volatile int *a, int v)
* check-name: memops-volatile
* check-command: test-linearize $file
*
- * check-known-to-fail
* check-output-ignore
* check-output-contains: store\\..*%arg2 -> 0\\[%arg1]
* check-output-contains: store\\..*\\$0 -> 0\\[%arg1]