summaryrefslogtreecommitdiff
path: root/gcc/coverage.c
diff options
context:
space:
mode:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2011-11-20 09:09:34 +0000
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2011-11-20 09:09:34 +0000
commit33087d4dcbcc8e9d77c45c5230bec9c0c9eeef93 (patch)
tree0aeff57f2bcf6a88201dbda657eb6d07666898ca /gcc/coverage.c
parent14bf3817ddada5f91772d3fb4a7889169f59c7ba (diff)
downloadgcc-33087d4dcbcc8e9d77c45c5230bec9c0c9eeef93.tar.gz
PR gcov-profile/51113
* coverage.c (build_var): Propagate visibility for public decls. testsuite/ * gcc.misc-tests/gcov-13.c: Check gcovpart-13b coverage * gcc.misc-tests/gcov-16.c: New. * gcc.misc-tests/gcov-17.c: New. * g++.dg/gcov/gcov-8.C: New. * g++.dg/gcov/gcov-9.C: New. * g++.dg/gcov/gcov-10.C: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@181524 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/coverage.c')
-rw-r--r--gcc/coverage.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/gcc/coverage.c b/gcc/coverage.c
index 520652b1e71..65ceba22783 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -657,9 +657,8 @@ coverage_end_function (unsigned lineno_checksum, unsigned cfg_checksum)
}
/* Build a coverage variable of TYPE for function FN_DECL. If COUNTER
- >= 0 it is a counter array, and thus local. Otherwise it is the
- function structure and needs to be globalized. All cases must be
- in the same comdat group as FN_DECL. */
+ >= 0 it is a counter array, otherwise it is the function structure.
+ Propagate appropriate linkage and visibility from the function decl. */
static tree
build_var (tree fn_decl, tree type, int counter)
@@ -668,29 +667,29 @@ build_var (tree fn_decl, tree type, int counter)
tree fn_name = DECL_ASSEMBLER_NAME (fn_decl);
char *buf = (char *)alloca (IDENTIFIER_LENGTH (fn_name) + 10);
- if (counter >= 0)
- TREE_STATIC (var) = 1;
- else
- {
- TREE_PUBLIC (var) = TREE_PUBLIC (fn_decl);
- TREE_STATIC (var) = TREE_STATIC (fn_decl);
- }
- TREE_ADDRESSABLE (var) = 1;
- DECL_ALIGN (var) = TYPE_ALIGN (type);
-
if (counter < 0)
sprintf (buf, "__gcov__%s", IDENTIFIER_POINTER (fn_name));
else
sprintf (buf, "__gcov%u_%s", counter, IDENTIFIER_POINTER (fn_name));
DECL_NAME (var) = get_identifier (buf);
-
- /* Initialize assembler name so we can stream out. */
+ TREE_STATIC (var) = 1;
+ TREE_ADDRESSABLE (var) = 1;
+ DECL_ALIGN (var) = TYPE_ALIGN (type);
+ DECL_WEAK (var) = DECL_WEAK (fn_decl);
+ TREE_PUBLIC (var)
+ = TREE_PUBLIC (fn_decl) && (counter < 0 || DECL_WEAK (fn_decl));
+ if (DECL_ONE_ONLY (fn_decl))
+ make_decl_one_only (var, DECL_COMDAT_GROUP (fn_decl));
+
if (TREE_PUBLIC (var))
- DECL_ASSEMBLER_NAME (var);
+ {
+ DECL_VISIBILITY (var) = DECL_VISIBILITY (fn_decl);
+ DECL_VISIBILITY_SPECIFIED (var)
+ = DECL_VISIBILITY_SPECIFIED (fn_decl);
- DECL_WEAK (var) = TREE_PUBLIC (var) && DECL_WEAK (fn_decl);
- DECL_COMDAT (var) = DECL_COMDAT (fn_decl);
- DECL_COMDAT_GROUP (var) = DECL_COMDAT_GROUP (fn_decl);
+ /* Initialize assembler name so we can stream out. */
+ DECL_ASSEMBLER_NAME (var);
+ }
return var;
}