diff options
Diffstat (limited to 'gcc/coverage.c')
-rw-r--r-- | gcc/coverage.c | 37 |
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; } |