aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2021-01-28 00:25:39 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2021-01-31 16:27:42 +0100
commit47336d48e3226903f320bb02f386322cf9e711fd (patch)
treec8baba98add3a38f64fceabc83a034b87acab823 /validation
parenta8183270c91b098ad819f02f510945a400ebbc40 (diff)
downloadsparse-dev-47336d48e3226903f320bb02f386322cf9e711fd.tar.gz
fix add_join_conditional() when one of the alternative is VOID
add_join_conditional()'s job is to take the 2 alternatives of the conditional, make a phi-node from them and return the corresponding pseudo but if one of the alternatives is not available it's useless to create a phi-node and the other alternative can then directly be returned. The problem is that in this later case, the pseudo directly returned is the PSEUDO_PHI of the corresponding phi-source. This gives erroneous code like, for example: phisrc.32 %phi1 <- $0 ret.32 %phi1 instead of: ret.32 $0 since the %ph1 should only be used by a phi-node instruction. Fix this by returning phi-source's operand instead. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation')
-rw-r--r--validation/linear/join-cond-discard.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/validation/linear/join-cond-discard.c b/validation/linear/join-cond-discard.c
new file mode 100644
index 00000000..9f07a7d4
--- /dev/null
+++ b/validation/linear/join-cond-discard.c
@@ -0,0 +1,19 @@
+void abort(void) __attribute__((noreturn));
+
+int bar(int a)
+{
+ return a ? (abort(), 0) : 0;
+}
+
+int qux(int a)
+{
+ return a ? (abort(), 0) : (abort(), 1);
+}
+
+/*
+ * check-name: join-cond-discard
+ * check-command: test-linearize -Wno-decl $file
+ *
+ * check-output-ignore
+ * check-output-excludes: phisrc\\..*phi
+ */