aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-02-16 05:57:03 +0100
committerChristopher Li <sparse@chrisli.org>2017-02-16 20:43:09 +0800
commitc3420f1e8ad7af77c03c2946e826b5ad4692601e (patch)
tree62f262bb397997fb17f2585df97157ec90086054 /validation
parentc17cd10a6a94640575c551fa8d72097cc7626e83 (diff)
downloadsparse-dev-c3420f1e8ad7af77c03c2946e826b5ad4692601e.tar.gz
add killing of non-volatile loads
OP_LOADs were ignored by kill_instruction() but there are two cases were something can or must be done: 1) if the is not a volatile one, it is free of side-effects and can thus be optimized away like others instructions. 2) if force-killed then we need to adjust the usage of its operand. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> Signed-off-by: Christopher Li <sparse@chrisli.org>
Diffstat (limited to 'validation')
-rw-r--r--validation/kill-load.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/validation/kill-load.c b/validation/kill-load.c
new file mode 100644
index 00000000..45fb83e4
--- /dev/null
+++ b/validation/kill-load.c
@@ -0,0 +1,17 @@
+int keep(volatile int *p) { return *p && 0; }
+int kill(int *p, int i) { return *p && 0; }
+void ind(volatile int *p,int i) { int v = i++; if (i && 0) p[v]; }
+
+
+/*
+ * check-name: kill-load
+ * check-command: test-linearize -Wno-decl $file
+ * check-description:
+ * Check that loads are optimized away but only
+ * when needed:
+ * - non-volatile
+ * - bb unreachable.
+ *
+ * check-output-ignore
+ * check-output-pattern-1-times: load\\.
+ */