public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Martin Liška" <mliska@suse.cz>
To: Jan Hubicka <hubicka@ucw.cz>
Cc: Nick Desaulniers <ndesaulniers@google.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] inline: do not inline when no_profile_instrument_function is different
Date: Wed, 18 Aug 2021 10:38:26 +0200	[thread overview]
Message-ID: <eead9e43-623e-9452-f69a-b22e160406ce@suse.cz> (raw)
In-Reply-To: <7fed627d-7213-918c-3ca6-0db60623a32b@suse.cz>

[-- Attachment #1: Type: text/plain, Size: 534 bytes --]

On 6/23/21 3:15 PM, Martin Liška wrote:
> On 6/23/21 2:38 PM, Jan Hubicka wrote:
>> Is there reason to prevent the inlining once instrumentation is done?
> 
> No ;)
> 
>> I think you can just block it for early inliner.
> 
> Sure. Do you have a handy predicate function that tells if einliner is done?
> 
> Thanks,
> Martin

Hello.

There's updated version of that patch that blocks inlining only during einline IPA pass.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin

[-- Attachment #2: 0001-inline-do-not-einline-when-no_profile_instrument_fun.patch --]
[-- Type: text/x-patch, Size: 2395 bytes --]

From e2adaff9ed92bcc380e1368418da5ad2801fef4e Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Tue, 22 Jun 2021 10:09:01 +0200
Subject: [PATCH] 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.
---
 gcc/ipa-inline.c                                | 17 +++++++++++++++++
 .../no_profile_instrument_function-attr-2.c     | 15 +++++++++++++++
 2 files changed, 32 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/no_profile_instrument_function-attr-2.c

diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c
index 413446bcc46..012b326b5e9 100644
--- a/gcc/ipa-inline.c
+++ b/gcc/ipa-inline.c
@@ -396,6 +396,23 @@ 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)) == NULL_TREE)
+	   != (lookup_attribute ("no_profile_instrument_function",
+				 DECL_ATTRIBUTES (callee->decl)) == NULL_TREE))
+    {
+      cgraph_node *origin = caller;
+      while (origin->clone_of)
+	origin = origin->clone_of;
+
+      if (!DECL_STRUCT_FUNCTION (origin->decl)->always_inline_functions_inlined)
+	{
+	  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"} } */
-- 
2.32.0


  parent reply	other threads:[~2021-08-18  8:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-23 11:53 Martin Liška
2021-06-23 12:38 ` Jan Hubicka
2021-06-23 13:15   ` Martin Liška
2021-06-25 19:00     ` Nick Desaulniers
2021-08-18  8:38     ` Martin Liška [this message]
2021-09-06 17:06       ` Jeff Law
2021-09-07 20:41       ` [Committed] Fix fatal typo in gcc.dg/no_profile_instrument_function-attr-2.c Hans-Peter Nilsson
2021-09-08  7:29         ` Martin Liška
2021-09-08 11:25           ` Hans-Peter Nilsson
2021-09-08 11:31             ` Rainer Orth

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=eead9e43-623e-9452-f69a-b22e160406ce@suse.cz \
    --to=mliska@suse.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=ndesaulniers@google.com \
    /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).