From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 1B3473858438 for ; Mon, 20 Mar 2023 08:33:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1B3473858438 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id C1CE421B2F; Mon, 20 Mar 2023 08:33:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1679301184; h=from:from:reply-to: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=tfmMs2fcAyfCju0sihg8PZYyU0WYqIxrsyMJoRxGt0A=; b=FFrEM6sggLoJ2VzMO9+xvI+Z1xk2/mjUBGS6KBcoq7kO2ARrvZ1uIW5zltxvjFqvl26hUK C8ztnyAnWyCZdLClXnv6E5n0w5qsRUMb85tcivxXhAPHrs/ID9H9DoP8jyksuBjRZECxjB EFhi7ZUVucydRAYK7Z2EdH8gyYO49TE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1679301184; h=from:from:reply-to: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=tfmMs2fcAyfCju0sihg8PZYyU0WYqIxrsyMJoRxGt0A=; b=ZKPPHQKMeqeU3OYbA7WctcyMKTUJD7xgAo6x1qh04b0npkax6sAgYL7ThlRHXB2wUDuFtC ub1xAUuZ2AMaAjAw== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 9B86A2C141; Mon, 20 Mar 2023 08:33:04 +0000 (UTC) Date: Mon, 20 Mar 2023 08:33:04 +0000 (UTC) From: Richard Biener To: Jakub Jelinek cc: Jan Hubicka , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] tree-optimization/106912 - IPA profile and pure/const In-Reply-To: Message-ID: References: User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham 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? Thanks, Richard.