aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2016-07-28 10:45:29 +0200
committerMartin Liska <marxin@gcc.gnu.org>2016-07-28 08:45:29 +0000
commit1225d6b1134b5eb31bcb592ac46a4d479dcb62b1 (patch)
tree65d289d14b3f9bef4364fd78f61f605d0611bbf4 /gcc
parent9bd6a6aebf1d2ef3c8199d2c9a263dd47054d14c (diff)
downloadgcc-1225d6b1134b5eb31bcb592ac46a4d479dcb62b1.zip
gcc-1225d6b1134b5eb31bcb592ac46a4d479dcb62b1.tar.gz
gcc-1225d6b1134b5eb31bcb592ac46a4d479dcb62b1.tar.bz2
Introduce no_profile_instrument_function attribute
PR gcov-profile/68025 * tree-profile.c (tree_profiling): Respect no_profile_instrument_function attribute. * doc/extend.texi: Document no_profile_instrument_function attribute. PR gcov-profile/68025 * c-common.c (handle_no_profile_instrument_function_attribute): PR gcov-profile/68025 * gcc.dg/no_profile_instrument_function-attr-1.c: New test. From-SVN: r238811
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/c-family/ChangeLog5
-rw-r--r--gcc/c-family/c-common.c21
-rw-r--r--gcc/doc/extend.texi6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/no_profile_instrument_function-attr-1.c23
-rw-r--r--gcc/tree-profile.c3
7 files changed, 71 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 919f3f8..7e3ac32 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,13 @@
2016-07-28 Martin Liska <mliska@suse.cz>
+ PR gcov-profile/68025
+ * tree-profile.c (tree_profiling): Respect
+ no_profile_instrument_function attribute.
+ * doc/extend.texi: Document no_profile_instrument_function
+ attribute.
+
+2016-07-28 Martin Liska <mliska@suse.cz>
+
PR rtl-optimization/70944
* combine.c (make_compound_operation):
Do not allow make_compound_operation for vector mode
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 34c65ec..1007340 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,8 @@
+2016-07-28 Martin Liska <mliska@suse.cz>
+
+ PR gcov-profile/68025
+ * c-common.c (handle_no_profile_instrument_function_attribute):
+
2016-07-27 Bernd Edlinger <bernd.edlinger@hotmail.de>
* c-common.c (check_user_alignment): Use LOG2_BITS_PER_UNIT instead of
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 38a7b2e..16e3965 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -353,6 +353,8 @@ static tree handle_tls_model_attribute (tree *, tree, tree, int,
bool *);
static tree handle_no_instrument_function_attribute (tree *, tree,
tree, int, bool *);
+static tree handle_no_profile_instrument_function_attribute (tree *, tree,
+ tree, int, bool *);
static tree handle_malloc_attribute (tree *, tree, tree, int, bool *);
static tree handle_returns_twice_attribute (tree *, tree, tree, int, bool *);
static tree handle_no_limit_stack_attribute (tree *, tree, tree, int,
@@ -717,6 +719,9 @@ const struct attribute_spec c_common_attribute_table[] =
{ "no_instrument_function", 0, 0, true, false, false,
handle_no_instrument_function_attribute,
false },
+ { "no_profile_instrument_function", 0, 0, true, false, false,
+ handle_no_profile_instrument_function_attribute,
+ false },
{ "malloc", 0, 0, true, false, false,
handle_malloc_attribute, false },
{ "returns_twice", 0, 0, true, false, false,
@@ -8293,6 +8298,22 @@ handle_no_instrument_function_attribute (tree *node, tree name,
return NULL_TREE;
}
+/* Handle a "no_profile_instrument_function" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_no_profile_instrument_function_attribute (tree *node, tree name, tree,
+ int, bool *no_add_attrs)
+{
+ if (TREE_CODE (*node) != FUNCTION_DECL)
+ {
+ warning (OPT_Wattributes, "%qE attribute ignored", name);
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
+
/* Handle a "malloc" attribute; arguments as in
struct attribute_spec.handler. */
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index ad8898c..70636c1 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -2853,6 +2853,12 @@ If @option{-finstrument-functions} is given, profiling function calls are
generated at entry and exit of most user-compiled functions.
Functions with this attribute are not so instrumented.
+@item no_profile_instrument_function
+@cindex @code{no_profile_instrument_function} function attribute
+The @code{no_profile_instrument_function} attribute on functions is used
+to inform the compiler that it should not process any profile feedback based
+optimization code instrumentation.
+
@item no_reorder
@cindex @code{no_reorder} function attribute
Do not reorder functions or variables marked @code{no_reorder}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4becb4a..6123f10 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2016-07-28 Martin Liska <mliska@suse.cz>
+ PR gcov-profile/68025
+ * gcc.dg/no_profile_instrument_function-attr-1.c: New test.
+
+2016-07-28 Martin Liska <mliska@suse.cz>
+
* g++.dg/vect/pr70944.cc: New test.
2016-07-28 Kugan Vivekanandarajah <kuganv@linaro.org>
diff --git a/gcc/testsuite/gcc.dg/no_profile_instrument_function-attr-1.c b/gcc/testsuite/gcc.dg/no_profile_instrument_function-attr-1.c
new file mode 100644
index 0000000..c93d171
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/no_profile_instrument_function-attr-1.c
@@ -0,0 +1,23 @@
+/* { dg-options "-O2 -fprofile-generate -fdump-tree-optimized" } */
+
+__attribute__ ((no_profile_instrument_function))
+int foo()
+{
+ return 0;
+}
+
+__attribute__ ((no_profile_instrument_function))
+int bar()
+{
+ return 1;
+}
+
+int main ()
+{
+ return foo ();
+}
+
+/* { dg-final { scan-tree-dump-times "__gcov0\\.main.* = PROF_edge_counter" 1 "optimized"} } */
+/* { dg-final { scan-tree-dump-times "__gcov_indirect_call_profiler_v2" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "__gcov_time_profiler" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "__gcov_init" 1 "optimized" } } */
diff --git a/gcc/tree-profile.c b/gcc/tree-profile.c
index 1f3a726..39fe15f 100644
--- a/gcc/tree-profile.c
+++ b/gcc/tree-profile.c
@@ -524,6 +524,9 @@ tree_profiling (void)
if (DECL_SOURCE_LOCATION (node->decl) == BUILTINS_LOCATION)
continue;
+ if (lookup_attribute ("no_profile_instrument_function",
+ DECL_ATTRIBUTES (node->decl)))
+ continue;
/* Do not instrument extern inline functions when testing coverage.
While this is not perfectly consistent (early inlined extern inlines
will get acocunted), testsuite expects that. */