summaryrefslogtreecommitdiff
path: root/gcc/coverage.c
diff options
context:
space:
mode:
authorspark <spark@138bc75d-0d04-0410-961f-82ee72b054a4>2008-03-31 21:52:10 +0000
committerspark <spark@138bc75d-0d04-0410-961f-82ee72b054a4>2008-03-31 21:52:10 +0000
commit3e3a0e9c37dbdb4832751d12d0b16f58983cd5aa (patch)
treed9fedd3a8f1f63959b283643213b8eec14e77278 /gcc/coverage.c
parent4e508025ecb527c36c59e2702b942def21914cdd (diff)
downloadgcc-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/coverage.c')
-rw-r--r--gcc/coverage.c43
1 files changed, 28 insertions, 15 deletions
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