diff options
author | spark <spark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-03-31 21:52:10 +0000 |
---|---|---|
committer | spark <spark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-03-31 21:52:10 +0000 |
commit | 3e3a0e9c37dbdb4832751d12d0b16f58983cd5aa (patch) | |
tree | d9fedd3a8f1f63959b283643213b8eec14e77278 /gcc | |
parent | 4e508025ecb527c36c59e2702b942def21914cdd (diff) | |
download | gcc-3e3a0e9c37dbdb4832751d12d0b16f58983cd5aa.tar.gz |
gcc/ChangeLog:
2008-03-31 Seongbae Park <seongbae.park@gmail.com>
* common.opt (fprofile-dir=, fprofile-use=, fprofile-generate=):
New options
(fprofile-use): Add var flag_profile_use
* coverage.c (coverage_begin_output): Do not open a gcno file for output
only if -ftest-coverage is set.
Do not add getpwd() to gcda file path.
(build_gcov_info): Check the new flag
flag_profile_datafile_relative_path.
(coverage_init): Use profile_data_prefix.
Read profile counter only if flag_profile_use is set.
* opts.c (common_handle_option): New option fprofile-use=,
fprofile-dir=, fprofile-generate=.
* toplev.c (profile_data_prefix): New variable definition.
* toplev.h (profile_data_prefix): New declaration.
* doc/invoke.tex (Option Summary, Optimization Options):
Add new options.
gcc/testsuite/ChangeLog:
2008-03-31 Seongbae Park <seongbae.park@gmail.com>
* g++.db/bprob/bprob.exp: Do not check gcno files.
Use -fprofile-use for profile use.
* gcc.misc-tests/bprob.exp: Ditto.
* g++.dg/tree-pro/tree-prof.exp: Do not check gcno files.
* gcc.dg/matrix/matrix.exp: Ditto.
* gcc.dg/struct/struct-reorg.exp: Ditto.
* gcc.dg/tree-prof/tree-prof.exp: Ditto.
* gcc.dg/profile-dir-1.c: New test.
* gcc.dg/profile-dir-2.c: New test.
* gcc.dg/profile-dir-3.c: New test.
ChangeLog:
2008-03-31 Seongbae Park <seongbae.park@gmail.com>
* Makefile.tpl (.NOTPARALLEL): Serialize stageprofile libiberty.
* Makefile.in (.NOTPARALLEL): Regenerate.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@133774 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 19 | ||||
-rw-r--r-- | gcc/common.opt | 15 | ||||
-rw-r--r-- | gcc/coverage.c | 43 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 24 | ||||
-rw-r--r-- | gcc/opts.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 13 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/bprob/bprob.exp | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/tree-prof/tree-prof.exp | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/matrix/matrix.exp | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/profile-dir-1.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/profile-dir-2.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/profile-dir-3.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/struct/struct-reorg.exp | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-prof/tree-prof.exp | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.misc-tests/bprob.exp | 4 | ||||
-rw-r--r-- | gcc/toplev.c | 3 | ||||
-rw-r--r-- | gcc/toplev.h | 1 |
17 files changed, 154 insertions, 26 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ade9571978e..44dabe846e6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,22 @@ +2008-03-31 Seongbae Park <seongbae.park@gmail.com> + + * common.opt (fprofile-dir=, fprofile-use=, fprofile-generate=): + New options + (fprofile-use): Add var flag_profile_use + * coverage.c (coverage_begin_output): Do not open a gcno file for output + only if -ftest-coverage is set. + Do not add getpwd() to gcda file path. + (build_gcov_info): Check the new flag + flag_profile_datafile_relative_path. + (coverage_init): Use profile_data_prefix. + Read profile counter only if flag_profile_use is set. + * opts.c (common_handle_option): New option fprofile-use=, + fprofile-dir=, fprofile-generate=. + * toplev.c (profile_data_prefix): New variable definition. + * toplev.h (profile_data_prefix): New declaration. + * doc/invoke.tex (Option Summary, Optimization Options): + Add new options. + 2008-03-31 James E. Wilson <wilson@tuliptree.org> PR target/35695 diff --git a/gcc/common.opt b/gcc/common.opt index ae0009cf446..dae5d61637d 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -815,14 +815,27 @@ fprofile-arcs Common Report Var(profile_arc_flag) Insert arc-based program profiling code +fprofile-dir= +Common Joined RejectNegative +Set the top-level directory for storing the profile data. +The default is 'pwd'. + fprofile-generate Common Enable common options for generating profile info for profile feedback directed optimizations +fprofile-generate= +Common Joined RejectNegative +Enable common options for generating profile info for profile feedback directed optimizations, and set -fprofile-dir= + fprofile-use -Common +Common Var(flag_profile_use) Enable common options for performing profile feedback directed optimizations +fprofile-use= +Common Joined RejectNegative +Enable common options for performing profile feedback directed optimizations, and set -fprofile-dir= + fprofile-values Common Report Var(flag_profile_values) Insert code to profile values of expressions diff --git a/gcc/coverage.c b/gcc/coverage.c index f3a0152ab9b..cd1c13e2d57 100644 --- a/gcc/coverage.c +++ b/gcc/coverage.c @@ -545,7 +545,9 @@ compute_checksum (void) int coverage_begin_output (void) { - if (no_coverage) + /* We don't need to output .gcno file unless we're under -ftest-coverage + (e.g. -fprofile-arcs/generate/use don't need .gcno to work). */ + if (no_coverage || !flag_test_coverage) return 0; if (!bbg_function_announced) @@ -802,8 +804,7 @@ build_gcov_info (void) tree field, fields = NULL_TREE; tree value = NULL_TREE; tree filename_string; - char *filename; - int filename_len; + int da_file_name_len; unsigned n_fns; const struct function_list *fn; tree string_type; @@ -842,17 +843,11 @@ build_gcov_info (void) field = build_decl (FIELD_DECL, NULL_TREE, string_type); TREE_CHAIN (field) = fields; fields = field; - filename = getpwd (); - filename = (filename && da_file_name[0] != '/' - ? concat (filename, "/", da_file_name, NULL) - : da_file_name); - filename_len = strlen (filename); - filename_string = build_string (filename_len + 1, filename); - if (filename != da_file_name) - free (filename); + da_file_name_len = strlen (da_file_name); + filename_string = build_string (da_file_name_len + 1, da_file_name); TREE_TYPE (filename_string) = build_array_type (char_type_node, build_index_type - (build_int_cst (NULL_TREE, filename_len))); + (build_int_cst (NULL_TREE, da_file_name_len))); value = tree_cons (field, build1 (ADDR_EXPR, string_type, filename_string), value); @@ -979,10 +974,27 @@ void coverage_init (const char *filename) { int len = strlen (filename); + /* + 1 for extra '/', in case prefix doesn't end with /. */ + int prefix_len; + + if (profile_data_prefix == 0 && filename[0] != '/') + profile_data_prefix = getpwd (); + + prefix_len = (profile_data_prefix) ? strlen (profile_data_prefix) + 1 : 0; /* Name of da file. */ - da_file_name = XNEWVEC (char, len + strlen (GCOV_DATA_SUFFIX) + 1); - strcpy (da_file_name, filename); + da_file_name = XNEWVEC (char, len + strlen (GCOV_DATA_SUFFIX) + + prefix_len + 1); + + if (profile_data_prefix) + { + strcpy (da_file_name, profile_data_prefix); + da_file_name[prefix_len - 1] = '/'; + da_file_name[prefix_len] = 0; + } + else + da_file_name[0] = 0; + strcat (da_file_name, filename); strcat (da_file_name, GCOV_DATA_SUFFIX); /* Name of bbg file. */ @@ -990,7 +1002,8 @@ coverage_init (const char *filename) strcpy (bbg_file_name, filename); strcat (bbg_file_name, GCOV_NOTE_SUFFIX); - read_counts_file (); + if (flag_profile_use) + read_counts_file (); } /* Performs file-level cleanup. Close graph file, generate coverage diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 87188103813..d16f161a7e4 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -341,8 +341,9 @@ Objective-C and Objective-C++ Dialects}. -fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss @gol -fomit-frame-pointer -foptimize-register-move -foptimize-sibling-calls @gol -fpeel-loops -fpredictive-commoning -fprefetch-loop-arrays @gol --fprofile-generate -fprofile-use -fprofile-values -freciprocal-math @gol --fregmove -frename-registers -freorder-blocks @gol +-fprofile-dir=@var{path} -fprofile-generate -fprofile-generate=@var{path} @gol +-fprofile-use -fprofile-use=@var{path} -fprofile-values @gol +-freciprocal-math -fregmove -frename-registers -freorder-blocks @gol -freorder-blocks-and-partition -freorder-functions @gol -frerun-cse-after-loop -freschedule-modulo-scheduled-loops @gol -frounding-math -frtl-abstract-sequences -fsched2-use-superblocks @gol @@ -6311,7 +6312,19 @@ and occasionally eliminate the copy. Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}. +@item -fprofile-dir=@var{path} +@opindex fprofile-dir + +Set the directory to search the profile data files in to @var{path}. +This option affects only the profile data generated by +@option{-fprofile-generate}, @option{-ftest-coverage}, @option{-fprofile-arcs} +and used by @option{-fprofile-use} and @option{-fbranch-probabilities} +and its related options. +By default, GCC will use the current directory as @var{path} +thus the profile data file will appear in the same directory as the object file. + @item -fprofile-generate +@itemx -fprofile-generate=@var{path} @opindex fprofile-generate Enable options usually used for instrumenting application to produce @@ -6321,7 +6334,11 @@ compiling and when linking your program. The following options are enabled: @code{-fprofile-arcs}, @code{-fprofile-values}, @code{-fvpt}. +If @var{path} is specified, GCC will look at the @var{path} to find +the profile feeedback data files. See @option{-fprofile-dir}. + @item -fprofile-use +@itemx -fprofile-use=@var{path} @opindex fprofile-use Enable profile feedback directed optimizations, and optimizations generally profitable only with profile feedback available. @@ -6333,6 +6350,9 @@ By default, GCC emits an error message if the feedback profiles do not match the source code. This error can be turned into a warning by using @option{-Wcoverage-mismatch}. Note this may result in poorly optimized code. + +If @var{path} is specified, GCC will look at the @var{path} to find +the profile feedback data files. See @option{-fprofile-dir}. @end table The following options control compiler behavior regarding floating diff --git a/gcc/opts.c b/gcc/opts.c index 528c8b83460..b87bc562e5a 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -1716,6 +1716,15 @@ common_handle_option (size_t scode, const char *arg, int value, flag_inline_functions_set = true; break; + case OPT_fprofile_dir_: + profile_data_prefix = xstrdup (arg); + break; + + case OPT_fprofile_use_: + profile_data_prefix = xstrdup (arg); + flag_profile_use = true; + value = true; + /* No break here - do -fprofile-use processing. */ case OPT_fprofile_use: if (!flag_branch_probabilities_set) flag_branch_probabilities = value; @@ -1733,6 +1742,10 @@ common_handle_option (size_t scode, const char *arg, int value, flag_inline_functions = value; break; + case OPT_fprofile_generate_: + profile_data_prefix = xstrdup (arg); + value = true; + /* No break here - do -fprofile-generate processing. */ case OPT_fprofile_generate: if (!profile_arc_flag_set) profile_arc_flag = value; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index eddd5c95564..8e9f51b84eb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,16 @@ +2008-03-31 Seongbae Park <seongbae.park@gmail.com> + + * g++.db/bprob/bprob.exp: Do not check gcno files. + Use -fprofile-use for profile use. + * gcc.misc-tests/bprob.exp: Ditto. + * g++.dg/tree-pro/tree-prof.exp: Do not check gcno files. + * gcc.dg/matrix/matrix.exp: Ditto. + * gcc.dg/struct/struct-reorg.exp: Ditto. + * gcc.dg/tree-prof/tree-prof.exp: Ditto. + * gcc.dg/profile-dir-1.c: New test. + * gcc.dg/profile-dir-2.c: New test. + * gcc.dg/profile-dir-3.c: New test. + 2008-03-31 Volker Reichelt <v.reichelt@netcologne.de> PR c/35750 diff --git a/gcc/testsuite/g++.dg/bprob/bprob.exp b/gcc/testsuite/g++.dg/bprob/bprob.exp index ee12d43e873..a2f011f69ee 100644 --- a/gcc/testsuite/g++.dg/bprob/bprob.exp +++ b/gcc/testsuite/g++.dg/bprob/bprob.exp @@ -27,7 +27,7 @@ if { ![check_profiling_available "-fprofile-arcs"] } { # The procedures in profopt.exp need these parameters. set tool g++ -set prof_ext "gcda gcno" +set prof_ext "gcda" if $tracelevel then { strace $tracelevel @@ -51,7 +51,7 @@ if $tracelevel then { load_lib profopt.exp set profile_options "-fprofile-arcs" -set feedback_options "-fbranch-probabilities" +set feedback_options "-fprofile-use" # Main loop. foreach profile_option $profile_options feedback_option $feedback_options { diff --git a/gcc/testsuite/g++.dg/tree-prof/tree-prof.exp b/gcc/testsuite/g++.dg/tree-prof/tree-prof.exp index 6d71b808633..930df4f1acc 100644 --- a/gcc/testsuite/g++.dg/tree-prof/tree-prof.exp +++ b/gcc/testsuite/g++.dg/tree-prof/tree-prof.exp @@ -26,7 +26,7 @@ if { ![check_profiling_available ""] } { # The procedures in profopt.exp need these parameters. set tool g++ -set prof_ext "gcda gcno" +set prof_ext "gcda" # Override the list defined in profopt.exp. set PROFOPT_OPTIONS [list {}] diff --git a/gcc/testsuite/gcc.dg/matrix/matrix.exp b/gcc/testsuite/gcc.dg/matrix/matrix.exp index 10f13eff6c3..b2f4ede9448 100644 --- a/gcc/testsuite/gcc.dg/matrix/matrix.exp +++ b/gcc/testsuite/gcc.dg/matrix/matrix.exp @@ -36,7 +36,7 @@ if { ![check_profiling_available ""] } { # The procedures in profopt.exp need these parameters. set tool gcc -set prof_ext "gcda gcno" +set prof_ext "gcda" # Override the list defined in profopt.exp. set PROFOPT_OPTIONS [list {}] diff --git a/gcc/testsuite/gcc.dg/profile-dir-1.c b/gcc/testsuite/gcc.dg/profile-dir-1.c new file mode 100644 index 00000000000..78fbcb20eb5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/profile-dir-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fprofile-generate=." } */ +/* { dg-final { scan-assembler "\"./profile-dir-1.gcda\"" } } */ + +int +main(void) +{ + return 0; +} + +/* { dg-final { cleanup-coverage-files } } */ diff --git a/gcc/testsuite/gcc.dg/profile-dir-2.c b/gcc/testsuite/gcc.dg/profile-dir-2.c new file mode 100644 index 00000000000..af55b36a400 --- /dev/null +++ b/gcc/testsuite/gcc.dg/profile-dir-2.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fprofile-generate" } */ +/* { dg-final { scan-assembler "/profile-dir-2.gcda" } } */ + +int +main(void) +{ + return 0; +} + +/* { dg-final { cleanup-coverage-files } } */ diff --git a/gcc/testsuite/gcc.dg/profile-dir-3.c b/gcc/testsuite/gcc.dg/profile-dir-3.c new file mode 100644 index 00000000000..0a924e97251 --- /dev/null +++ b/gcc/testsuite/gcc.dg/profile-dir-3.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fprofile-generate -fprofile-dir=." } */ +/* { dg-final { scan-assembler "\"./profile-dir-3.gcda\"" } } */ + +int +main(void) +{ + return 0; +} + +/* { dg-final { cleanup-coverage-files } } */ diff --git a/gcc/testsuite/gcc.dg/struct/struct-reorg.exp b/gcc/testsuite/gcc.dg/struct/struct-reorg.exp index 5598a7647cb..19a7f63a7dd 100644 --- a/gcc/testsuite/gcc.dg/struct/struct-reorg.exp +++ b/gcc/testsuite/gcc.dg/struct/struct-reorg.exp @@ -36,7 +36,7 @@ if { ![check_profiling_available ""] } { # The procedures in profopt.exp need these parameters. set tool gcc -set prof_ext "gcda gcno" +set prof_ext "gcda" # Override the list defined in profopt.exp. set PROFOPT_OPTIONS [list {}] diff --git a/gcc/testsuite/gcc.dg/tree-prof/tree-prof.exp b/gcc/testsuite/gcc.dg/tree-prof/tree-prof.exp index 4c8ae441214..974c68b1d6f 100644 --- a/gcc/testsuite/gcc.dg/tree-prof/tree-prof.exp +++ b/gcc/testsuite/gcc.dg/tree-prof/tree-prof.exp @@ -26,7 +26,7 @@ if { ![check_profiling_available ""] } { # The procedures in profopt.exp need these parameters. set tool gcc -set prof_ext "gcda gcno" +set prof_ext "gcda" # Override the list defined in profopt.exp. set PROFOPT_OPTIONS [list {}] diff --git a/gcc/testsuite/gcc.misc-tests/bprob.exp b/gcc/testsuite/gcc.misc-tests/bprob.exp index 340c6259972..933546e1c40 100644 --- a/gcc/testsuite/gcc.misc-tests/bprob.exp +++ b/gcc/testsuite/gcc.misc-tests/bprob.exp @@ -27,7 +27,7 @@ if { ![check_profiling_available "-fprofile-arcs"] } { # The procedures in profopt.exp need these parameters. set tool gcc -set prof_ext "gcda gcno" +set prof_ext "gcda" set perf_ext tim # Override the list defined in profopt.exp. @@ -48,7 +48,7 @@ if $tracelevel then { load_lib profopt.exp set profile_options "-fprofile-arcs" -set feedback_options "-fbranch-probabilities" +set feedback_options "-fprofile-use" foreach profile_option $profile_options feedback_option $feedback_options { foreach src [lsort [glob -nocomplain $srcdir/$subdir/bprob-*.c]] { diff --git a/gcc/toplev.c b/gcc/toplev.c index e6460ada469..36b24d7eabf 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -152,6 +152,9 @@ const char *dump_base_name; const char *aux_base_name; +/* Prefix for profile data files */ +const char *profile_data_prefix; + /* A mask of target_flags that includes bit X if X was set or cleared on the command line. */ diff --git a/gcc/toplev.h b/gcc/toplev.h index 45e464680ff..9c42aefd78b 100644 --- a/gcc/toplev.h +++ b/gcc/toplev.h @@ -111,6 +111,7 @@ extern const char *progname; extern const char *dump_base_name; extern const char *aux_base_name; extern const char *aux_info_file_name; +extern const char *profile_data_prefix; extern const char *asm_file_name; extern bool exit_after_options; |