From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) by sourceware.org (Postfix) with ESMTPS id B1F783855037 for ; Wed, 23 Jun 2021 12:38:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B1F783855037 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ucw.cz Authentication-Results: sourceware.org; spf=none smtp.mailfrom=kam.mff.cuni.cz Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 1D9E22808E0; Wed, 23 Jun 2021 14:38:41 +0200 (CEST) Date: Wed, 23 Jun 2021 14:38:41 +0200 From: Jan Hubicka To: Martin =?iso-8859-2?Q?Li=B9ka?= Cc: gcc-patches@gcc.gnu.org, Nick Desaulniers Subject: Re: [PATCH] inline: do not inline when no_profile_instrument_function is different Message-ID: <20210623123841.GC65660@kam.mff.cuni.cz> References: <4a46257d-91cd-427e-1b11-7599ad36d07f@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4a46257d-91cd-427e-1b11-7599ad36d07f@suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-14.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Jun 2021 12:38:44 -0000 > Hello. > > Similarly to e.g. sanitizer attributes, we sould prevent inlining when one function > is marked as not instrumented. We should do that with -fprofile-generate only. > > Patch can bootstrap on x86_64-linux-gnu and survives regression tests. > > Ready to be installed? > Thanks, > Martin > > 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. > --- > gcc/ipa-inline.c | 10 ++++++++++ > .../no_profile_instrument_function-attr-2.c | 15 +++++++++++++++ > 2 files changed, 25 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 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; > + } Is there reason to prevent the inlining once instrumentation is done? I think you can just block it for early inliner. Honza > + > 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"} } */ > -- > 2.32.0 >