public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/marxin/heads/PR80223-pgo-attr-do-not-inline)] inline: do not inline when no_profile_instrument_function is different
@ 2021-06-23  8:16 Martin Liska
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Liska @ 2021-06-23  8:16 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:e0b6de5b4a8f98ccdc876883e0f2ebe17306406c

commit e0b6de5b4a8f98ccdc876883e0f2ebe17306406c
Author: Martin Liska <mliska@suse.cz>
Date:   Tue Jun 22 10:09:01 2021 +0200

    inline: do not inline when no_profile_instrument_function is different
    
    Adds test-case for:
            PR gcov-profile/80223
    
    gcc/ChangeLog:
    
            * ipa-inline.c (can_inline_edge_p): Similarly to sanitizer
            options, do not inline when no_profile_instrument_function
            attributes are different.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.dg/no_profile_instrument_function-attr-2.c: New test.

Diff:
---
 gcc/ipa-inline.c                                          | 10 ++++++++++
 .../gcc.dg/no_profile_instrument_function-attr-2.c        | 15 +++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c
index 9d896beb2ac..786ab2e7f7f 100644
--- a/gcc/ipa-inline.c
+++ b/gcc/ipa-inline.c
@@ -396,6 +396,16 @@ can_inline_edge_p (struct cgraph_edge *e, bool report,
       e->inline_failed = CIF_SANITIZE_ATTRIBUTE_MISMATCH;
       inlinable = false;
     }
+  else if (profile_arc_flag
+	   && lookup_attribute ("no_profile_instrument_function",
+				DECL_ATTRIBUTES (caller->decl))
+	      != lookup_attribute ("no_profile_instrument_function",
+				   DECL_ATTRIBUTES (callee->decl)))
+    {
+      e->inline_failed = CIF_UNSPECIFIED;
+      inlinable = false;
+    }
+
   if (!inlinable && report)
     report_inline_failed_reason (e);
   return inlinable;
diff --git a/gcc/testsuite/gcc.dg/no_profile_instrument_function-attr-2.c b/gcc/testsuite/gcc.dg/no_profile_instrument_function-attr-2.c
new file mode 100644
index 00000000000..586962a1c76
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/no_profile_instrument_function-attr-2.c
@@ -0,0 +1,15 @@
+/* { dg-require-effective-target global_constructor } */
+/* { dg-options "-O2 -fprofile-generate -fprofile-update=single -fdump-tree-optimized" } */
+
+__attribute__ ((no_profile_instrument_function))
+int foo()
+{
+  return 0;
+}
+
+int bar()
+{
+  return foo();
+}
+
+/* { dg-final { scan-tree-dump-times " = foo \\(\\)" 1 "optimized"} } */


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [gcc(refs/users/marxin/heads/PR80223-pgo-attr-do-not-inline)] inline: do not inline when no_profile_instrument_function is different
@ 2021-06-22  8:10 Martin Liska
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Liska @ 2021-06-22  8:10 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:5034132ea7ff20f335ae7d0aae26970fb8be8f54

commit 5034132ea7ff20f335ae7d0aae26970fb8be8f54
Author: Martin Liska <mliska@suse.cz>
Date:   Tue Jun 22 10:09:01 2021 +0200

    inline: do not inline when no_profile_instrument_function is different
    
    Adds test-case for:
            PR gcov-profile/80223
    
    gcc/ChangeLog:
    
            * ipa-inline.c (can_inline_edge_p): Similarly to sanitizer
            options, do not inline when no_profile_instrument_function
            attributes are different.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.dg/no_profile_instrument_function-attr-2.c: New test.

Diff:
---
 gcc/ipa-inline.c                                          |  9 +++++++++
 .../gcc.dg/no_profile_instrument_function-attr-2.c        | 15 +++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c
index 9d896beb2ac..89ce301f06a 100644
--- a/gcc/ipa-inline.c
+++ b/gcc/ipa-inline.c
@@ -396,6 +396,15 @@ can_inline_edge_p (struct cgraph_edge *e, bool report,
       e->inline_failed = CIF_SANITIZE_ATTRIBUTE_MISMATCH;
       inlinable = false;
     }
+  else if (lookup_attribute ("no_profile_instrument_function",
+			     DECL_ATTRIBUTES (caller->decl))
+	   != lookup_attribute ("no_profile_instrument_function",
+				DECL_ATTRIBUTES (callee->decl)))
+    {
+      e->inline_failed = CIF_UNSPECIFIED;
+      inlinable = false;
+    }
+
   if (!inlinable && report)
     report_inline_failed_reason (e);
   return inlinable;
diff --git a/gcc/testsuite/gcc.dg/no_profile_instrument_function-attr-2.c b/gcc/testsuite/gcc.dg/no_profile_instrument_function-attr-2.c
new file mode 100644
index 00000000000..586962a1c76
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/no_profile_instrument_function-attr-2.c
@@ -0,0 +1,15 @@
+/* { dg-require-effective-target global_constructor } */
+/* { dg-options "-O2 -fprofile-generate -fprofile-update=single -fdump-tree-optimized" } */
+
+__attribute__ ((no_profile_instrument_function))
+int foo()
+{
+  return 0;
+}
+
+int bar()
+{
+  return foo();
+}
+
+/* { dg-final { scan-tree-dump-times " = foo \\(\\)" 1 "optimized"} } */


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-23  8:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-23  8:16 [gcc(refs/users/marxin/heads/PR80223-pgo-attr-do-not-inline)] inline: do not inline when no_profile_instrument_function is different Martin Liska
  -- strict thread matches above, loose matches on Subject: below --
2021-06-22  8:10 Martin Liska

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).