summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-ssa/flatten-2.c
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gcc.dg/tree-ssa/flatten-2.c
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gcc.dg/tree-ssa/flatten-2.c')
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/flatten-2.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/flatten-2.c b/gcc/testsuite/gcc.dg/tree-ssa/flatten-2.c
new file mode 100644
index 000000000..ffed23cf4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/flatten-2.c
@@ -0,0 +1,85 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-early-inlining" } */
+
+extern void do_something_usefull();
+/* Check that we finish compiling even if instructed to
+ flatten a cyclic callgraph. Verify we correctly
+ flatten with another function marked flatten in the
+ callgraph.
+
+ Main inline is cureful about indirect calls giving
+ precedence to breaking cycle at indirect call sites.
+ Early inliner can't do similar analysis, so we need
+ to disable it if we want cycles to be broken consistently. */
+
+void __attribute__((flatten)) direct(void)
+{
+ direct();
+}
+
+
+void __attribute__((flatten)) indirect(void);
+static void indirect1(void)
+{
+ indirect();
+}
+void __attribute__((flatten)) indirect(void)
+{
+ indirect1();
+}
+
+
+void __attribute__((flatten)) doubleindirect(void);
+static void doubleindirect2(void)
+{
+ doubleindirect();
+ do_something_usefull ();
+}
+static void doubleindirect1(void)
+{
+ doubleindirect2();
+}
+void __attribute__((flatten)) doubleindirect(void)
+{
+ doubleindirect1();
+}
+
+
+static void subcycle1(void);
+static void subcycle2(void)
+{
+ subcycle1();
+ do_something_usefull ();
+}
+static void subcycle1(void)
+{
+ subcycle2();
+}
+void __attribute__((flatten)) subcycle(void)
+{
+ subcycle1();
+}
+
+
+static void doublesubcycle1(void);
+static void doublesubcycle2(void);
+static void doublesubcycle3(void)
+{
+ doublesubcycle1();
+ do_something_usefull ();
+}
+static void doublesubcycle2(void)
+{
+ doublesubcycle3();
+}
+static void doublesubcycle1(void)
+{
+ doublesubcycle2();
+}
+void __attribute__((flatten)) doublesubcycle(void)
+{
+ doublesubcycle1();
+}
+
+/* { dg-final { scan-assembler "cycle\[123\]\[: \t\n\]" } } */
+/* { dg-final { scan-assembler-not "indirect\[12\]\[: \t\n\]" } } */