From f704cf4c32a824de157757f9c4926e24d8904e80 Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Wed, 24 Sep 2014 03:29:37 +0000 Subject: [PATCH] Add test cases for noreorder 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 * 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 | 7 ++++++ gcc/testsuite/gcc.dg/noreorder.c | 38 +++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/noreorder2.c | 11 +++++++++ gcc/testsuite/gcc.dg/noreorder3.c | 10 ++++++++ gcc/testsuite/gcc.dg/noreorder4.c | 5 ++++ 5 files changed, 71 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/noreorder.c create mode 100644 gcc/testsuite/gcc.dg/noreorder2.c create mode 100644 gcc/testsuite/gcc.dg/noreorder3.c create mode 100644 gcc/testsuite/gcc.dg/noreorder4.c diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 14d65db75aa..2fb28b9f4c0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2014-09-23 Andi Kleen + + * 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 * 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 index 00000000000..7d40a2958a4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/noreorder.c @@ -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 index 00000000000..558361b628a --- /dev/null +++ b/gcc/testsuite/gcc.dg/noreorder2.c @@ -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 index 00000000000..a0b637f60cb --- /dev/null +++ b/gcc/testsuite/gcc.dg/noreorder3.c @@ -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 index 00000000000..632fc33432c --- /dev/null +++ b/gcc/testsuite/gcc.dg/noreorder4.c @@ -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" } } */ -- 2.30.2