From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; 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. --- gcc/testsuite/g++.dg/tree-prof/indir-call-prof-2.C | 35 ++++++++++++++ gcc/testsuite/g++.dg/tree-prof/indir-call-prof.C | 39 ++++++++++++++++ .../g++.dg/tree-prof/inline_mismatch_args.C | 36 +++++++++++++++ gcc/testsuite/g++.dg/tree-prof/partition1.C | 54 ++++++++++++++++++++++ gcc/testsuite/g++.dg/tree-prof/partition2.C | 16 +++++++ gcc/testsuite/g++.dg/tree-prof/partition3.C | 18 ++++++++ gcc/testsuite/g++.dg/tree-prof/tree-prof.exp | 54 ++++++++++++++++++++++ 7 files changed, 252 insertions(+) create mode 100644 gcc/testsuite/g++.dg/tree-prof/indir-call-prof-2.C create mode 100644 gcc/testsuite/g++.dg/tree-prof/indir-call-prof.C create mode 100644 gcc/testsuite/g++.dg/tree-prof/inline_mismatch_args.C create mode 100644 gcc/testsuite/g++.dg/tree-prof/partition1.C create mode 100644 gcc/testsuite/g++.dg/tree-prof/partition2.C create mode 100644 gcc/testsuite/g++.dg/tree-prof/partition3.C create mode 100644 gcc/testsuite/g++.dg/tree-prof/tree-prof.exp (limited to 'gcc/testsuite/g++.dg/tree-prof') diff --git a/gcc/testsuite/g++.dg/tree-prof/indir-call-prof-2.C b/gcc/testsuite/g++.dg/tree-prof/indir-call-prof-2.C new file mode 100644 index 000000000..e20cc64d3 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-prof/indir-call-prof-2.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/testsuite/g++.dg/tree-prof/indir-call-prof.C b/gcc/testsuite/g++.dg/tree-prof/indir-call-prof.C new file mode 100644 index 000000000..80b41865c --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-prof/indir-call-prof.C @@ -0,0 +1,39 @@ +/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-tree_profile_ipa" } */ + +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 transformation on insn" "tree_profile_ipa" } } */ +/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized" } } */ +/* { dg-final-use { cleanup-tree-dump "optimized" } } */ +/* { dg-final-use { cleanup-ipa-dump "tree_profile_ipa" } } */ diff --git a/gcc/testsuite/g++.dg/tree-prof/inline_mismatch_args.C b/gcc/testsuite/g++.dg/tree-prof/inline_mismatch_args.C new file mode 100644 index 000000000..e82a46ebf --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-prof/inline_mismatch_args.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/testsuite/g++.dg/tree-prof/partition1.C b/gcc/testsuite/g++.dg/tree-prof/partition1.C new file mode 100644 index 000000000..108803997 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-prof/partition1.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/testsuite/g++.dg/tree-prof/partition2.C b/gcc/testsuite/g++.dg/tree-prof/partition2.C new file mode 100644 index 000000000..6715da57e --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-prof/partition2.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/testsuite/g++.dg/tree-prof/partition3.C b/gcc/testsuite/g++.dg/tree-prof/partition3.C new file mode 100644 index 000000000..784698369 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-prof/partition3.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/testsuite/g++.dg/tree-prof/tree-prof.exp b/gcc/testsuite/g++.dg/tree-prof/tree-prof.exp new file mode 100644 index 000000000..92de03210 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-prof/tree-prof.exp @@ -0,0 +1,54 @@ +# 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 +# . + +# 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 "gcda" + +# 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" +set feedback_option "-fprofile-use" + +foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.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 +} -- cgit v1.2.3