Add test cases for noreorder
authorAndi Kleen <ak@linux.intel.com>
Wed, 24 Sep 2014 03:29:37 +0000 (03:29 +0000)
committerAndi Kleen <ak@gcc.gnu.org>
Wed, 24 Sep 2014 03:29:37 +0000 (03:29 +0000)
Add some simple test cases for noreorder behaving like
-fno-toplevel-reorder and -fno-toplevel-reorder still working.

gcc/testsuite/:

2014-09-23  Andi Kleen  <ak@linux.intel.com>

* gcc.dg/noreorder.c: New test.
* gcc.dg/noreorder2.c: New test.
* gcc.dg/noreorder3.c: New test.
* gcc.dg/noreorder4.c: New test.

From-SVN: r215538

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/noreorder.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/noreorder2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/noreorder3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/noreorder4.c [new file with mode: 0644]

index 14d65db75aa85091412b8af11446c57c98fe636a..2fb28b9f4c00027762e2457f1e6cbaeb281fb62b 100644 (file)
@@ -1,3 +1,10 @@
+2014-09-23  Andi Kleen  <ak@linux.intel.com>
+
+       * gcc.dg/noreorder.c: New test.
+       * gcc.dg/noreorder2.c: New test.
+       * gcc.dg/noreorder3.c: New test.
+       * gcc.dg/noreorder4.c: New test.
+
 2014-09-23  Alan Lawrence  <alan.lawrence@arm.com>
 
        * gcc.dg/combine_ashiftrt_1.c: New test.
diff --git a/gcc/testsuite/gcc.dg/noreorder.c b/gcc/testsuite/gcc.dg/noreorder.c
new file mode 100644 (file)
index 0000000..7d40a29
--- /dev/null
@@ -0,0 +1,38 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+/* The function order in this file is opposite from what the cgraph
+   topological sort would output. So we can check the order is preserved. */
+
+extern void f2(int);
+static int func2(void);
+
+#ifndef NOREORDER
+#define NOREORDER __attribute__((no_reorder))
+#endif
+
+asm("firstasm");
+
+NOREORDER __attribute__((noinline)) int bozo(void)
+{
+  f2(3);
+  func2();
+}
+
+asm("jukjuk");
+
+NOREORDER __attribute__((noinline)) static int func1(void)
+{
+  f2(1);
+}
+
+asm("barbar");
+
+NOREORDER __attribute__((noinline)) static int func2(void)
+{
+  func1();
+}
+
+asm("lastasm");
+
+/* { dg-final { scan-assembler "firstasm.*bozo.*jukjuk.*func1.*barbar.*func2.*lastasm" } } */
diff --git a/gcc/testsuite/gcc.dg/noreorder2.c b/gcc/testsuite/gcc.dg/noreorder2.c
new file mode 100644 (file)
index 0000000..558361b
--- /dev/null
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-toplevel-reorder" } */
+
+__attribute__((no_reorder)) int foobar;
+
+static int barbar;
+int bozo;
+
+/* { dg-final { scan-assembler "foobar" } } */
+/* { dg-final { scan-assembler "bozo" } } */
+/* { dg-final { scan-assembler "barbar" } } */
diff --git a/gcc/testsuite/gcc.dg/noreorder3.c b/gcc/testsuite/gcc.dg/noreorder3.c
new file mode 100644 (file)
index 0000000..a0b637f
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+__attribute__((no_reorder)) int foobar;
+static int barbar;
+int bozo;
+
+/* { dg-final { scan-assembler "foobar" } } */
+/* { dg-final { scan-assembler "bozo" } } */
+/* { dg-final { scan-assembler-not "barbar" } } */
diff --git a/gcc/testsuite/gcc.dg/noreorder4.c b/gcc/testsuite/gcc.dg/noreorder4.c
new file mode 100644 (file)
index 0000000..632fc33
--- /dev/null
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-toplevel-reorder" } */
+#define NOREORDER
+#include "noreorder.c"
+/* { dg-final { scan-assembler "bozo.*jukjuk.*func1.*barbar.*func2" } } */