OSDN Git Service

PR gcov-profile/51113
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 20 Nov 2011 09:09:34 +0000 (09:09 +0000)
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 20 Nov 2011 09:09:34 +0000 (09:09 +0000)
* 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

gcc/ChangeLog
gcc/coverage.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/gcov/gcov-10.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gcov/gcov-11.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gcov/gcov-8.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gcov/gcov-9.C [new file with mode: 0644]
gcc/testsuite/gcc.misc-tests/gcov-13.c
gcc/testsuite/gcc.misc-tests/gcov-16.c [new file with mode: 0644]
gcc/testsuite/gcc.misc-tests/gcov-17.c [new file with mode: 0644]

index 6f98784..298db24 100644 (file)
@@ -1,3 +1,16 @@
+2011-11-20  Nathan Sidwell  <nathan@acm.org>
+
+       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.
+
 2011-11-19  Eric Botcazou  <ebotcazou@adacore.com>
 
        PR rtl-optimization/51187
index 520652b..65ceba2 100644 (file)
@@ -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;
 }
index c5f33a6..ef00522 100644 (file)
@@ -1,3 +1,13 @@
+2011-11-20  Nathan Sidwell  <nathan@acm.org>
+
+       PR gcov-profile/51113
+       * 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.
+
 2011-11-20  Dodji Seketeli  <dodji@redhat.com>
 
        PR c++/51194
diff --git a/gcc/testsuite/g++.dg/gcov/gcov-10.C b/gcc/testsuite/g++.dg/gcov/gcov-10.C
new file mode 100644 (file)
index 0000000..4c91be9
--- /dev/null
@@ -0,0 +1,20 @@
+/* Ensure PIC sequence used for comdat functions */
+
+/* { dg-options "-fprofile-arcs -ftest-coverage -fpic" } */
+/* { dg-do run { target native } } */
+/* { dg-require-effective-target fpic } */
+
+inline int __attribute__ ((noinline)) Foo ()
+{
+  static int x[1];
+
+  return x[0]++;  /* count (1) */
+}
+
+int main ()
+{
+  Foo ();  /* count (1) */
+  return 0;  /* count (1) */
+}
+
+/* { dg-final { run-gcov gcov-10.C } } */
diff --git a/gcc/testsuite/g++.dg/gcov/gcov-11.C b/gcc/testsuite/g++.dg/gcov/gcov-11.C
new file mode 100644 (file)
index 0000000..fa08902
--- /dev/null
@@ -0,0 +1,42 @@
+/* Check that unexecuted exception processing regions are shown
+   distinct from  unexecuted normal regions.  */
+
+/* { dg-options "-fprofile-arcs -ftest-coverage" } */
+/* { dg-do run { target native } } */
+
+void Baz (int i)
+{
+  if (i)
+    throw 1;
+}
+
+void Boz () throw ()
+{
+}
+
+int main ()
+{
+  try
+    {
+      Baz (0);  /* count (1) */
+      Baz (0);  /* count (1) */
+    }
+  catch (...)
+    {
+      Boz ();  /* count (=====) */
+    }
+
+  try
+    {
+      Baz (1);  /* count (1) */
+      Baz (0);  /* count (#####) */
+    }
+  catch (...)
+    {
+      Boz ();  /* count (1) */
+    }
+
+  return 0;  /* count (1) */
+}
+
+/* { dg-final { run-gcov gcov-11.C } } */
diff --git a/gcc/testsuite/g++.dg/gcov/gcov-8.C b/gcc/testsuite/g++.dg/gcov/gcov-8.C
new file mode 100644 (file)
index 0000000..25e265e
--- /dev/null
@@ -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" } } */
diff --git a/gcc/testsuite/g++.dg/gcov/gcov-9.C b/gcc/testsuite/g++.dg/gcov/gcov-9.C
new file mode 100644 (file)
index 0000000..e8d5ad8
--- /dev/null
@@ -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" } } */
index 605d4d4..14be8f9 100644 (file)
@@ -16,3 +16,4 @@ int main ()
 }
 
 /* { dg-final { run-gcov { -a gcov-13.c } } } */
+/* { dg-final { run-gcov { -a gcovpart-13b.c } } } */
diff --git a/gcc/testsuite/gcc.misc-tests/gcov-16.c b/gcc/testsuite/gcc.misc-tests/gcov-16.c
new file mode 100644 (file)
index 0000000..b05c4a0
--- /dev/null
@@ -0,0 +1,11 @@
+/* Test visibility is copied */
+
+/* { dg-options "-fprofile-arcs -fvisibility=hidden" } */
+/* { dg-require-visibility "" } */
+/* { dg-require-weak "" } */
+
+void Foo ()
+{
+}
+
+ /* { dg-final { scan-assembler "\\.hidden\t__gcov__Foo" } } */
diff --git a/gcc/testsuite/gcc.misc-tests/gcov-17.c b/gcc/testsuite/gcc.misc-tests/gcov-17.c
new file mode 100644 (file)
index 0000000..66f50f2
--- /dev/null
@@ -0,0 +1,11 @@
+/* Test visibility is copied */
+
+/* { dg-options "-fprofile-arcs" } */
+/* { dg-require-visibility "" } */
+/* { dg-require-weak "" } */
+
+void __attribute__ ((visibility ("hidden"), weak)) Foo ()
+{
+}
+
+/* { dg-final { scan-assembler "\\.hidden\t__gcov__Foo" } } */