aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo')
-rw-r--r--gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/indir-call-prof-2_0.C35
-rw-r--r--gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/indir-call-prof_0.C39
-rw-r--r--gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/inline_mismatch_args_0.C36
-rw-r--r--gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/lipo.exp60
-rw-r--r--gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/partition1_0.C54
-rw-r--r--gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/partition2_0.C16
-rw-r--r--gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/partition3_0.C18
-rw-r--r--gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/vcall1_0.C41
-rw-r--r--gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/vcall1_1.C23
-rw-r--r--gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/vcall1_2.C31
10 files changed, 353 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/indir-call-prof-2_0.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/indir-call-prof-2_0.C
new file mode 100644
index 000000000..e20cc64d3
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/indir-call-prof-2_0.C
@@ -0,0 +1,35 @@
+/* { dg-options "-O" } */
+
+int foo1(void) { return 0; }
+int bar1(void) { throw 1; }
+void foo2(void) { }
+void bar2(void) { throw 1; }
+void __attribute__((noinline,noclone)) test1(void (*f)(void)) { (*f)(); }
+void __attribute__((noinline,noclone)) test2(void (*f)(void)) { (*f)(); }
+int __attribute__((noinline,noclone)) test3(int (*f)(void)) { return (*f)(); }
+int __attribute__((noinline,noclone)) test4(int (*f)(void)) { return (*f)(); }
+int __attribute__((noinline,noclone)) test5(int (*f)(void), int x) { return x ? x : (*f)(); }
+int __attribute__((noinline,noclone)) test6(int (*f)(void), int x) { return x ? x : (*f)(); }
+void __attribute__((noinline,noclone)) test7(void (*f)(void)) { try { (*f)(); } catch (...) {} }
+void __attribute__((noinline,noclone)) test8(void (*f)(void)) { try { (*f)(); } catch (...) {}}
+int __attribute__((noinline,noclone)) test9(int (*f)(void)) { try { return (*f)(); } catch (...) {return 0;} }
+int __attribute__((noinline,noclone)) test10(int (*f)(void)) { try { return (*f)(); } catch (...) {return 0;} }
+int __attribute__((noinline,noclone)) test11(int (*f)(void), int x) { try { return x ? x : (*f)(); } catch (...) {return 0;} }
+int __attribute__((noinline,noclone)) test12(int (*f)(void), int x) { try { return x ? x : (*f)(); } catch (...) {return 0;} }
+
+int main()
+{
+ for (int i = 0; i < 100; ++i) test1(foo2);
+ for (int i = 0; i < 100; ++i) try { test2(bar2); } catch (...) {}
+ for (int i = 0; i < 100; ++i) test3(foo1);
+ for (int i = 0; i < 100; ++i) try { test4(bar1); } catch (...) {}
+ for (int i = 0; i < 100; ++i) test5(foo1, 0);
+ for (int i = 0; i < 100; ++i) try { test6(bar1, 0); } catch (...) {}
+ for (int i = 0; i < 100; ++i) test7(foo2);
+ for (int i = 0; i < 100; ++i) try { test8(bar2); } catch (...) {}
+ for (int i = 0; i < 100; ++i) test9(foo1);
+ for (int i = 0; i < 100; ++i) try { test10(bar1); } catch (...) {}
+ for (int i = 0; i < 100; ++i) test11(foo1, 0);
+ for (int i = 0; i < 100; ++i) try { test12(bar1, 0); } catch (...) {}
+ return 0;
+}
diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/indir-call-prof_0.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/indir-call-prof_0.C
new file mode 100644
index 000000000..b34b937fd
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/indir-call-prof_0.C
@@ -0,0 +1,39 @@
+/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */
+
+struct A {
+ A () {}
+
+ virtual int AA (void)
+ { return 0; }
+
+};
+
+struct B : public A {
+ B () {}
+
+ virtual int AA (void)
+ { return 1; }
+};
+
+void * __attribute__((noinline,noclone)) wrap (void *p) { return p; }
+int
+main (void)
+{
+ A a;
+ B b;
+
+ A* p;
+
+ p = (A *)wrap ((void *)&a);
+ p->AA ();
+
+ p = (B *)wrap ((void *)&b);
+ p->AA ();
+
+ return 0;
+}
+
+/* { dg-final-use { scan-ipa-dump "Indirect call -> direct call.* AA " "profile" } } */
+/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized" } } */
+/* { dg-final-use { cleanup-tree-dump "optimized" } } */
+/* { dg-final-use { cleanup-ipa-dump "profile" } } */
diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/inline_mismatch_args_0.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/inline_mismatch_args_0.C
new file mode 100644
index 000000000..e82a46ebf
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/inline_mismatch_args_0.C
@@ -0,0 +1,36 @@
+/* { dg-options "-O2 -fdump-tree-einline" } */
+class DocId {
+ public:
+ DocId() { }
+ DocId(const DocId &other) { }
+};
+
+int g;
+class Base {
+ public:
+ virtual void Foo(DocId id) { g++; }
+};
+
+class Super: public Base {
+ public:
+ void Foo(DocId id) { }
+ void Bar(Base *base, DocId id) __attribute__((noinline));
+};
+
+void Super::Bar(Base *base, DocId id) {
+ Super::Foo(id); // direct call is inlined
+ base->Foo(id); // indirect call is marked do not inline
+}
+
+int main(void)
+{
+ Base bah;
+ Super baz;
+ DocId gid;
+
+ baz.Bar(&baz, gid);
+ return 0;
+}
+/* { dg-final-use { scan-tree-dump "Inlining .*Super::Foo" "einline" } } */
+/* { dg-final-use { scan-tree-dump-not "mismatched arguments" "einline" } } */
+/* { dg-final-use { cleanup-tree-dump "einline" } } */
diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/lipo.exp b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/lipo.exp
new file mode 100644
index 000000000..2d1ddd7cd
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/lipo.exp
@@ -0,0 +1,60 @@
+# Copyright (C) 2001, 2002, 2004, 2005, 2007, 2008
+# Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# Test the functionality of programs compiled with profile-directed block
+# ordering using -fprofile-generate followed by -fprofile-use.
+
+load_lib target-supports.exp
+
+# Some targets don't support tree profiling.
+if { ![check_profiling_available ""] } {
+ return
+}
+
+# The procedures in profopt.exp need these parameters.
+set tool g++
+set prof_ext [list {gcda} {gcda.imports} ]
+
+# Override the list defined in profopt.exp.
+set PROFOPT_OPTIONS [list {}]
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+# Load support procs.
+load_lib profopt.exp
+
+# These are globals used by profopt-execute. The first is options
+# needed to generate profile data, the second is options to use the
+# profile data.
+set profile_option "-fprofile-generate -fripa"
+set feedback_option "-fprofile-use -fripa"
+
+# Add -fno-section-anchors for powerpc. Workround for Google ref b/6663281
+if {[istarget powerpc*-*-*]} {
+ set profile_option "$profile_option -fno-section-anchors"
+ set feedback_option "$feedback_option -fno-section-anchors"
+}
+
+foreach src [lsort [glob -nocomplain $srcdir/$subdir/*_0.C]] {
+ # If we're only testing specific files and this isn't one of them, skip it.
+ if ![runtest_file_p $runtests $src] then {
+ continue
+ }
+ profopt-execute $src
+}
diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/partition1_0.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/partition1_0.C
new file mode 100644
index 000000000..108803997
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/partition1_0.C
@@ -0,0 +1,54 @@
+/* { dg-require-effective-target freorder } */
+/* { dg-options "-O2 -freorder-blocks-and-partition" } */
+/* { dg-skip-if "PR target/47683" { mips-sgi-irix* } } */
+
+struct A { A () __attribute__((noinline)); ~A () __attribute__((noinline)); };
+A::A () { asm volatile ("" : : : "memory"); }
+A::~A () { asm volatile ("" : : : "memory"); }
+
+int bar () __attribute__((noinline));
+void foo () __attribute__((noinline));
+
+volatile int k, l;
+
+int bar (int i)
+{
+ void *p = __builtin_alloca (i);
+ asm volatile ("" : : "r" (i), "r" (p) : "memory");
+ if (k) throw 6;
+ return ++l;
+}
+
+void foo ()
+{
+ A a;
+ try {
+ A b;
+ int i = bar (5);
+ try { throw 6; } catch (int) {}
+ if (__builtin_expect (i < 4500, 0)) {
+ bar (7);
+ try { bar (8); } catch (long) {}
+ bar (10);
+ if (__builtin_expect (i < 0, 0)) {
+ try { bar (12); } catch (...) {}
+ bar (16);
+ bar (122);
+ } else {
+ try { bar (bar (7)); } catch (int) {}
+ }
+ } else {
+ try { bar (bar (bar (9))); } catch (...) {}
+ bar (5);
+ }
+ } catch (...) {
+ }
+}
+
+int
+main ()
+{
+ int i;
+ for (i = 0; i < 10000; i++)
+ foo ();
+}
diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/partition2_0.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/partition2_0.C
new file mode 100644
index 000000000..6715da57e
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/partition2_0.C
@@ -0,0 +1,16 @@
+// PR middle-end/45458
+// { dg-require-effective-target freorder }
+// { dg-options "-fnon-call-exceptions -freorder-blocks-and-partition" }
+// { dg-skip-if "PR target/47683" { mips-sgi-irix* } }
+
+int
+main ()
+{
+ try
+ {
+ throw 6;
+ }
+ catch (...)
+ {
+ }
+}
diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/partition3_0.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/partition3_0.C
new file mode 100644
index 000000000..784698369
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/partition3_0.C
@@ -0,0 +1,18 @@
+// PR middle-end/45566
+// { dg-require-effective-target freorder }
+// { dg-options "-O -fnon-call-exceptions -freorder-blocks-and-partition" }
+
+int k;
+
+int
+main ()
+{
+ try
+ {
+ if (k)
+ throw 6;
+ }
+ catch (...)
+ {
+ }
+}
diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/vcall1_0.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/vcall1_0.C
new file mode 100644
index 000000000..3052344b5
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/vcall1_0.C
@@ -0,0 +1,41 @@
+/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */
+#include <stdio.h>
+struct A {
+ A () {}
+ virtual int AA (void) { return 0; }
+};
+
+extern A* getB (void);
+extern A* getC (void);
+
+int g;
+
+int
+main (void)
+{
+ A* p;
+ int i;
+ int s = 0;
+
+ p = getB();
+ for (i = 0; i < 100; i++)
+ {
+ s += p->AA();
+ }
+
+ for (i = 0; i < 100; i++)
+ {
+ if (i%10 == 0)
+ p = getB();
+ else
+ p = getC();
+
+ s += p->AA();
+ }
+ printf ("result = %d\n",s);
+}
+
+/* { dg-final-use { scan-ipa-dump-times "Indirect call -> direct call" 2 "profile" } } */
+/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized" } } */
+/* { dg-final-use { cleanup-tree-dump "optimized" } } */
+/* { dg-final-use { cleanup-ipa-dump "profile" } } */
diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/vcall1_1.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/vcall1_1.C
new file mode 100644
index 000000000..6023024f4
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/vcall1_1.C
@@ -0,0 +1,23 @@
+/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */
+
+struct A {
+ A () {}
+
+ virtual int AA (void)
+ { return 0; }
+
+};
+
+struct B : public A {
+ B () {}
+
+ virtual int AA (void)
+ { return 1; }
+};
+
+B b;
+
+A* getB (void)
+{
+ return &b;
+}
diff --git a/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/vcall1_2.C b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/vcall1_2.C
new file mode 100644
index 000000000..cc33d6a19
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/g++.dg/tree-prof/lipo/vcall1_2.C
@@ -0,0 +1,31 @@
+/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */
+
+struct A {
+ A () {}
+
+ virtual int AA (void)
+ { return 0; }
+
+};
+
+struct B : public A {
+ B () {}
+
+ virtual int AA (void)
+ { return 1; }
+};
+
+struct C : public B {
+ C () {}
+
+ virtual int AA (void)
+ { return 2; }
+
+};
+
+C c;
+
+A* getC(void)
+{
+ return &c;
+}