summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog13
-rw-r--r--gcc/coverage.c37
-rw-r--r--gcc/testsuite/ChangeLog10
-rw-r--r--gcc/testsuite/g++.dg/gcov/gcov-10.C20
-rw-r--r--gcc/testsuite/g++.dg/gcov/gcov-11.C42
-rw-r--r--gcc/testsuite/g++.dg/gcov/gcov-8.C13
-rw-r--r--gcc/testsuite/g++.dg/gcov/gcov-9.C15
-rw-r--r--gcc/testsuite/gcc.misc-tests/gcov-13.c1
-rw-r--r--gcc/testsuite/gcc.misc-tests/gcov-16.c11
-rw-r--r--gcc/testsuite/gcc.misc-tests/gcov-17.c11
10 files changed, 154 insertions, 19 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6f987847ce8..298db241830 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
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;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c5f33a6216e..ef00522d131 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 00000000000..4c91be94ee4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gcov/gcov-10.C
@@ -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
index 00000000000..fa0890206f3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gcov/gcov-11.C
@@ -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
index 00000000000..25e265e9c98
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gcov/gcov-8.C
@@ -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
index 00000000000..e8d5ad8b0a4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gcov/gcov-9.C
@@ -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" } } */
diff --git a/gcc/testsuite/gcc.misc-tests/gcov-13.c b/gcc/testsuite/gcc.misc-tests/gcov-13.c
index 605d4d4b382..14be8f9e103 100644
--- a/gcc/testsuite/gcc.misc-tests/gcov-13.c
+++ b/gcc/testsuite/gcc.misc-tests/gcov-13.c
@@ -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
index 00000000000..b05c4a064e8
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/gcov-16.c
@@ -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
index 00000000000..66f50f27477
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/gcov-17.c
@@ -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" } } */