diff options
author | Tomas Bily <tbily@suse.cz> | 2007-01-19 19:34:02 +0100 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2007-01-19 18:34:02 +0000 |
commit | 6bad26173df0462c3d7391d58d55fa132bb44102 (patch) | |
tree | 41def031b05732ddcfbc26eac41ed55f2a54dc07 /gcc/testsuite | |
parent | b7c75af4b5b275047cb622ae85f98839cf6299a1 (diff) | |
download | gcc-6bad26173df0462c3d7391d58d55fa132bb44102.zip gcc-6bad26173df0462c3d7391d58d55fa132bb44102.tar.gz gcc-6bad26173df0462c3d7391d58d55fa132bb44102.tar.bz2 |
Patch by Tomas Bily <tbily@suse.cz>
Patch by Tomas Bily <tbily@suse.cz>
* cgraphunit.c (cgraph_finalize_function): Updating of pid
* tree-profile.c:
(tree_init_ic_make_global_vars): New function
(tree_init_edge_profiler): call of tree_init_ic_make_global_vars
(tree_gen_ic_profiler): New function
(tree_gen_ic_func_profiler): New function
(tree_profiling): Added calling of tree_gen_ic_func_profiler
(tree_profile_hooks): Added hook for indirec/virtual calls
* value-prof.c (tree_find_values_to_profile): New case for
indirect calls
(tree_values_to_profile): Call for determining indirect/virtual
counters
(tree_indirect_call_to_profile): New function
(tree_ic_transform): New function
(tree_ic): New function
(find_func_by_pid): New function
(init_pid_map): New function
(tree_value_profile_transformations): Added check for
indirect/virtual call transformation
* value-prof.h (enum hist_type): New counter type for
indirect/virtual calls
(profile_hooks): Added new hook for profiling indirect/virtual
calls
* profile.c (instrument_values): New case for indirect/virtual
call added
* gcov-io.h (GCOV_LAST_VALUE_COUNTER): Changed to 6
(GCOV_COUNTER_V_INDIR): New counter type
(GCOV_COUNTER_NAMES): New name of counter "indirect" added
(GCOV_MERGE_FUNCTIONS): New merge function for indirect/virtual
call added
* cgraph.c: Definition of cgraph_max_pid
(cgraph_create_node): Default init of pid attribute
* cgraph.h: Declaration of cgraph_max_pid
(struct cgraph_node): Added pid attribute
* libgcov.c (__gcov_indirect_call_profiler): New function
(__gcov_one_value_profiler_body): New function
(__gcov_one_value_profiler): Body was moved to
__gcov_one_value_profiler_body and calls it
gcc.dg/tree-prof/indir-call-prof.c: New.
g++.dg/dg.exp: Add tree-prof subdirectory.
g++.dg/tree-prof/indir-call-prof.C: New.
g++.dg/tree-prof/tree-prof.exp: New.
From-SVN: r120975
Diffstat (limited to 'gcc/testsuite')
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/dg.exp | 1 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/tree-prof/indir-call-prof.C | 39 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/tree-prof/tree-prof.exp | 53 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-prof/indir-call-prof.c | 45 |
5 files changed, 145 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 34b02ac..e0178ad 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2007-01-19 Tomas Bily <tbily@suse.cz> + + gcc.dg/tree-prof/indir-call-prof.c: New. + g++.dg/dg.exp: Add tree-prof subdirectory. + g++.dg/tree-prof/indir-call-prof.C: New. + g++.dg/tree-prof/tree-prof.exp: New. + 2007-01-19 Manuel Lopez-Ibanez <manu@gcc.gnu.org> PR c++/17947 diff --git a/gcc/testsuite/g++.dg/dg.exp b/gcc/testsuite/g++.dg/dg.exp index 5ecb161..2581139 100644 --- a/gcc/testsuite/g++.dg/dg.exp +++ b/gcc/testsuite/g++.dg/dg.exp @@ -41,6 +41,7 @@ set tests [prune $tests $srcdir/$subdir/special/*] set tests [prune $tests $srcdir/$subdir/tls/*] set tests [prune $tests $srcdir/$subdir/vect/*] set tests [prune $tests $srcdir/$subdir/gomp/*] +set tests [prune $tests $srcdir/$subdir/tree-prof/*] # Main loop. dg-runtest $tests "" $DEFAULT_CXXFLAGS 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 0000000..98ab302 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-prof/indir-call-prof.C @@ -0,0 +1,39 @@ +/* { dg-options "-O2 -fdump-tree-optimized -fdump-tree-tree_profile" } */ + +struct A { + A () {} + + virtual int AA (void) + { return 0; } + +}; + +struct B : public A { + B () {} + + virtual int AA (void) + { return 1; } +}; + +int +main (void) +{ + A a; + B b; + + A* p; + + p = &a; + p->AA (); + + p = &b; + p->AA (); + + return 0; +} + +/* { dg-final-use { scan-tree-dump "Indirect call -> direct call.* AA transformation on insn" "tree_profile"} } */ +/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */ +/* { dg-final-use { cleanup-tree-dump "optimized" } } */ +/* { dg-final-use { cleanup-tree-dump "tree_profile" } } */ + 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 0000000..f9ebbd6 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-prof/tree-prof.exp @@ -0,0 +1,53 @@ +# Copyright (C) 2001, 2002, 2004, 2005 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 2 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 this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +# Test the functionality of programs compiled with profile-directed block +# ordering using -fprofile-generate followed by -fbranch-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 gcno" + +# 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 +} diff --git a/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof.c b/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof.c new file mode 100644 index 0000000..101b972 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof.c @@ -0,0 +1,45 @@ +/* { dg-options "-O2 -fdump-tree-optimized -fdump-tree-tree_profile" } */ + +static int a1 (void) +{ + return 10; +} + +static int a2 (void) +{ + return 0; +} + +typedef int (*tp) (void); + +static tp aa [] = {a2, a1, a1, a1, a1}; + +void setp (int (**pp) (void), int i) +{ + if (!i) + *pp = aa [i]; + else + *pp = aa [(i & 2) + 1]; +} + +int +main (void) +{ + int (*p) (void); + int i; + + for (i = 0; i < 10; i ++) + { + setp (&p, i); + p (); + } + + return 0; +} + +/* { dg-final-use { scan-tree-dump "Indirect call -> direct call.* a1 transformation on insn" "tree_profile"} } */ +/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */ +/* { dg-final-use { cleanup-tree-dump "optimized" } } */ +/* { dg-final-use { cleanup-tree-dump "tree_profile" } } */ + + |