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 C780F3858D28 for ; Fri, 24 Mar 2023 11:49:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C780F3858D28 Authentication-Results: sourceware.org; dmarc=fail (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 B080A28A393; Fri, 24 Mar 2023 12:49:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucw.cz; s=gen1; t=1679658543; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=DfJ02MvZWyXpmmiJp0mCLLw8ZzMqREhd6eGY0/6rHEo=; b=evM+xYY4TBZCkE915QHyzqiAxBs/Ri4j6gpV75hL6cKaS/gOjO4baHJKxI9jumSajyFCTd ZWGw4vDrfMyENTUIvW+aTHV6giT4O75jT/P91iKhqpN6Pu+6LAalzutQNinTR6p9r2vg/y 3g2wmOuNbm6/n72DA6gm+YmvAWtP3K0= Date: Fri, 24 Mar 2023 12:49:03 +0100 From: Jan Hubicka To: Richard Biener Cc: Jakub Jelinek , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] tree-optimization/106912 - IPA profile and pure/const Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: > On Fri, 17 Mar 2023, Jakub Jelinek wrote: > > > On Fri, Mar 17, 2023 at 08:40:34PM +0100, Jan Hubicka wrote: > > > > + /* Drop the const attribute from the call type (the pure > > > > + attribute is not available on types). */ > > > > + tree fntype = gimple_call_fntype (call); > > > > + if (fntype && TYPE_READONLY (fntype)) > > > > + gimple_call_set_fntype > > > > + (call, build_qualified_type (fntype, (TYPE_QUALS (fntype) > > > > + & ~TYPE_QUAL_CONST))); > > > > > > Sorry, now I am bit confused on why Jakub's fix did not need similar > > > fixup. The flag is only set during the profiling stage and thus I would > > > expect it to still run into the problem that VOPs are missing. > > > Is it only becuase we do not sanity check? > > > > My patch started from this point ignoring all TYPE_READONLY bits on > > all FUNCTION_TYPE/METHOD_TYPEs, while Richi's patch instead makes it > > explicit in the IL, TYPE_READONLY is honored as before but it shouldn't > > show up in any of the gimple_call_fntype types unless it is a direct > > call to a const function for which we don't have a body. > > > > In either case, vops are added on the update_stmt a few lines later. > > > > > Here is a testcase that shows the problem: > > > > > > include > > > float c; > > > > > > __attribute__ ((const)) > > > float > > > instrument(float v) > > > { > > > return sin (v); > > > } > > > __attribute__ ((no_profile_instrument_function,const,noinline)) > > > float noinstrument (float v) > > > { > > > return instrument (v); > > > } > > > > > > m() > > > { > > > c+=instrument(c); > > > if (!__builtin_expect (c,1)) > > > { > > > c+=noinstrument (c); > > > } > > > c+=instrument(c); > > > } > > > main() > > > { > > > m(); > > > } > > > > > > Compiling > > > gcc -O0 t.c -fprofile-arcs -fno-early-inlining --coverage -lm -ftest-coverage -S ; gcc t.s -ftest-coverage -lm -fprofile-arcs > > > makes gcov to report 3 executions on instrument while with -O3 it is 2. > > With my proposed patch it works fine and reports 3 executions on > 'instrument' with both -O0 and -O3. I checked it indeed reports only > 2 executions with GCC 12. > > So it seems the patch is a progression in general? > > Thus, OK? OK, thanks! Honza > > Thanks, > Richard.