This adds a returns_twice testcase that shows the ICE (already fixed)
and show that adding a stmt before the call does not work either.
Pushed as obvious after a quick test on x86_64-linux-gnu to make sure it passes.
PR tree-optimization/126815
gcc/testsuite/ChangeLog:
* gcc.dg/torture/returns-twice-1.c: New test.
Signed-off-by: Andrea Pinski <[email protected]>
---
.../gcc.dg/torture/returns-twice-1.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
create mode 100644 gcc/testsuite/gcc.dg/torture/returns-twice-1.c
diff --git a/gcc/testsuite/gcc.dg/torture/returns-twice-1.c
b/gcc/testsuite/gcc.dg/torture/returns-twice-1.c
new file mode 100644
index 00000000000..fbd9faa0bce
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/returns-twice-1.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* PR tree-optimization/126815 */
+int f (int) __attribute__((returns_twice));
+void sink1 (int) __attribute__((leaf));
+void sink (int);
+
+void h (int a, int b, int c)
+{
+ int t;
+ if (c){
+ sink (1);
+ t = f (a);
+ }
+ else
+ t = b;
+ if (t == 42)
+ __builtin_unreachable ();
+ sink1 (a);
+}
--
2.43.0