This patch propagates visibility information in the same way that weakness is for externally visible coverage objects. I don't know whether this will fix the reported firefox build failure -- can you try? Even if it doesn't, I'm pretty sure it's an improvement, but I'll leave it for comment before committing eitherway.

built & tested on i686-pc-linux-gnu.

nathan
2011-11-14  Nathan Sidwell  <nat...@acm.org>

        PR gcov-profile/51113
        * coverage.c (build_var): Propagate visibility for public decls.

        testsuite/
        * 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.

Index: coverage.c
===================================================================
--- coverage.c  (revision 181347)
+++ coverage.c  (working copy)
@@ -674,6 +674,13 @@ build_var (tree fn_decl, tree type, int
     {
       TREE_PUBLIC (var) = TREE_PUBLIC (fn_decl);
       TREE_STATIC (var) = TREE_STATIC (fn_decl);
+      if (TREE_PUBLIC (var))
+       {
+         DECL_WEAK (var) = DECL_WEAK (fn_decl);
+         DECL_VISIBILITY (var) = DECL_VISIBILITY (fn_decl);
+         DECL_VISIBILITY_SPECIFIED (var)
+           = DECL_VISIBILITY_SPECIFIED (fn_decl);
+       }
     }
   TREE_ADDRESSABLE (var) = 1;
   DECL_ALIGN (var) = TYPE_ALIGN (type);
@@ -688,7 +695,6 @@ build_var (tree fn_decl, tree type, int
   if (TREE_PUBLIC (var))
     DECL_ASSEMBLER_NAME (var);    
 
-  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);
 
Index: testsuite/gcc.misc-tests/gcov-16.c
===================================================================
--- testsuite/gcc.misc-tests/gcov-16.c  (revision 0)
+++ testsuite/gcc.misc-tests/gcov-16.c  (revision 0)
@@ -0,0 +1,10 @@
+/* Test visibility is copied */
+
+/* { dg-options "-fprofile-arcs -fvisibility=hidden" } */
+/* { dg-require-visibility "" } */
+
+void Foo ()
+{
+}
+
+ /* { dg-final { scan-assembler "\\.hidden\t__gcov__Foo" } } */
Index: testsuite/gcc.misc-tests/gcov-17.c
===================================================================
--- testsuite/gcc.misc-tests/gcov-17.c  (revision 0)
+++ testsuite/gcc.misc-tests/gcov-17.c  (revision 0)
@@ -0,0 +1,10 @@
+/* Test visibility is copied */
+
+/* { dg-options "-fprofile-arcs" } */
+/* { dg-require-visibility "" } */
+
+void __attribute__ ((visibility ("hidden"))) Foo ()
+{
+}
+
+/* { dg-final { scan-assembler "\\.hidden\t__gcov__Foo" } } */
Index: testsuite/g++.dg/gcov/gcov-8.C
===================================================================
--- testsuite/g++.dg/gcov/gcov-8.C      (revision 0)
+++ testsuite/g++.dg/gcov/gcov-8.C      (revision 0)
@@ -0,0 +1,13 @@
+/* { dg-options "-fprofile-arcs -fvisibility=hidden" } */
+/* { dg-require-visibility "" } */
+
+struct __attribute__((visibility ("hidden"))) X
+{
+  void Fink ();
+};
+
+void X::Fink ()
+{
+}
+
+/* { dg-final { scan-assembler "\\.hidden\t__gcov___ZN1X4FinkEv" } } */
Index: testsuite/g++.dg/gcov/gcov-9.C
===================================================================
--- testsuite/g++.dg/gcov/gcov-9.C      (revision 0)
+++ testsuite/g++.dg/gcov/gcov-9.C      (revision 0)
@@ -0,0 +1,15 @@
+/* { dg-options "-fprofile-arcs -fvisibility-inlines-hidden" } */
+/* { dg-require-visibility "" } */
+
+inline void Boo ()
+{
+}
+
+extern "C" void (*Foo ()) ()
+{
+  return Boo;
+}
+
+/* { dg-final { scan-assembler "\\.hidden\t__gcov___Z3Boov" } } */
+/* { dg-final { scan-assembler "__gcov__Foo:" } } */
+/* { dg-final { scan-assembler-not "\\.hidden\t__gcov__Foo" } } */

Reply via email to