public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Martin Liska <marxin@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc(refs/users/marxin/heads/PR80223-pgo-attr-do-not-inline-v2)] inline: do not einline when no_profile_instrument_function is different
Date: Mon, 16 Aug 2021 13:50:11 +0000 (GMT)	[thread overview]
Message-ID: <20210816135011.AD187394B009@sourceware.org> (raw)

https://gcc.gnu.org/g:1cbb3edf7f7d75c5bcee3162f0a690fb701db314

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

    inline: do not einline when no_profile_instrument_function is different
    
            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 in early inliner. It's fine to inline
            it after PGO instrumentation.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.dg/no_profile_instrument_function-attr-2.c: New test.

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

diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c
index 413446bcc46..6a0939a0998 100644
--- a/gcc/ipa-inline.c
+++ b/gcc/ipa-inline.c
@@ -396,6 +396,17 @@ can_inline_edge_p (struct cgraph_edge *e, bool report,
       e->inline_failed = CIF_SANITIZE_ATTRIBUTE_MISMATCH;
       inlinable = false;
     }
+  else if (profile_arc_flag
+	   && !DECL_STRUCT_FUNCTION (caller->decl)->always_inline_functions_inlined
+	   && (lookup_attribute ("no_profile_instrument_function",
+				 DECL_ATTRIBUTES (caller->decl)) == NULL_TREE)
+	   != (lookup_attribute ("no_profile_instrument_function",
+				 DECL_ATTRIBUTES (callee->decl)) == NULL_TREE))
+    {
+      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..472eca88efd
--- /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-not" = foo \\(\\)" "optimized"} } */


             reply	other threads:[~2021-08-16 13:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-16 13:50 Martin Liska [this message]
2021-08-17 12:15 Martin Liska

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210816135011.AD187394B009@sourceware.org \
    --to=marxin@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).