New ipa-modref testcases
authorJan Hubicka <jh@suse.cz>
Wed, 25 Nov 2020 19:52:20 +0000 (20:52 +0100)
committerJan Hubicka <jh@suse.cz>
Wed, 25 Nov 2020 19:52:20 +0000 (20:52 +0100)
gcc/testsuite/ChangeLog:
* gcc.dg/lto/modref-3_0.c: New test.
* gcc.dg/lto/modref-3_1.c: New test.
* gcc.dg/lto/modref-4_0.c: New test.
* gcc.dg/lto/modref-4_1.c: New test.
* gcc.dg/tree-ssa/modref-5.c: New test.

gcc/testsuite/gcc.dg/lto/modref-3_0.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/lto/modref-3_1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/lto/modref-4_0.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/lto/modref-4_1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/modref-5.c [new file with mode: 0644]

diff --git a/gcc/testsuite/gcc.dg/lto/modref-3_0.c b/gcc/testsuite/gcc.dg/lto/modref-3_0.c
new file mode 100644 (file)
index 0000000..bd8f96f
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-lto-do run } */
+/* { dg-lto-options { {-O2 -flto-partition=max -fdump-ipa-modref -fno-ipa-sra -fno-ipa-cp -flto} } } */
+extern void copy (int *a, int *b);
+extern void barrier ();
+extern int *ptr;
+int
+main()
+{
+  int a = 1, b = 2;
+  copy (&a,&b);
+  barrier ();
+  *ptr = 1;
+  if (!__builtin_constant_p (b == 2))
+    __builtin_abort ();
+  return 0;
+}
+/* { dg-final { scan-wpa-ipa-dump "parm 1 flags: nodirectescape"  "modref"  } } */
diff --git a/gcc/testsuite/gcc.dg/lto/modref-3_1.c b/gcc/testsuite/gcc.dg/lto/modref-3_1.c
new file mode 100644 (file)
index 0000000..c36f3d1
--- /dev/null
@@ -0,0 +1,13 @@
+__attribute__ ((noinline))
+void
+copy (int *a, int *b)
+{
+  *a=*b;
+}
+int p, *ptr = &p;
+__attribute__ ((noinline))
+void
+barrier ()
+{
+  asm ("":"=r"(ptr):"0"(ptr));
+}
diff --git a/gcc/testsuite/gcc.dg/lto/modref-4_0.c b/gcc/testsuite/gcc.dg/lto/modref-4_0.c
new file mode 100644 (file)
index 0000000..db90b4f
--- /dev/null
@@ -0,0 +1,17 @@
+/* { dg-lto-do run } */
+/* { dg-lto-options { {-O2 -flto-partition=max -fdump-ipa-modref -fno-ipa-sra -flto} } } */
+extern void copy (int *a, int *b);
+extern void barrier ();
+extern int *ptr;
+int
+main()
+{
+  int a = 1, b = 2;
+  copy (&a,&b);
+  barrier ();
+  *ptr = 1;
+  if (!__builtin_constant_p (b == 2))
+    __builtin_abort ();
+  return 0;
+}
+/* { dg-final { scan-wpa-ipa-dump "parm 1 flags: nodirectescape"  "modref"  } } */
diff --git a/gcc/testsuite/gcc.dg/lto/modref-4_1.c b/gcc/testsuite/gcc.dg/lto/modref-4_1.c
new file mode 100644 (file)
index 0000000..c36f3d1
--- /dev/null
@@ -0,0 +1,13 @@
+__attribute__ ((noinline))
+void
+copy (int *a, int *b)
+{
+  *a=*b;
+}
+int p, *ptr = &p;
+__attribute__ ((noinline))
+void
+barrier ()
+{
+  asm ("":"=r"(ptr):"0"(ptr));
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/modref-5.c b/gcc/testsuite/gcc.dg/tree-ssa/modref-5.c
new file mode 100644 (file)
index 0000000..fde3177
--- /dev/null
@@ -0,0 +1,27 @@
+/* { dg-options "-O2 -fdump-tree-modref1"  } */
+/* { dg-do run } */
+__attribute__ ((noinline))
+void
+copy (int *a, int *b)
+{
+  *a=*b;
+}
+int p, *ptr = &p;
+__attribute__ ((noinline))
+void
+barrier ()
+{
+  asm ("":"=r"(ptr):"0"(ptr));
+}
+int
+main()
+{
+  int a = 1, b = 2;
+  copy (&a,&b);
+  barrier ();
+  *ptr = 1;
+  if (!__builtin_constant_p (b == 2))
+    __builtin_abort ();
+  return 0;
+}
+/* { dg-final { scan-tree-dump "parm 1 flags: nodirectescape" "modref1"  } } */