From patchwork Fri Nov 25 07:59:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 61100 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 609F83945C1D for ; Fri, 25 Nov 2022 08:00:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 609F83945C1D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669363251; bh=bhmhycjnGmZZ3Wd/O0lV87YqQ4fE8Pe0FLfNW2ub/pk=; h=Date:To:cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=q5w8TTfjGtM6WW4NNkaxWfwdxOQfX6YKAmPSzAvms33DYetlkrQN89VZSKxWw9lbX 1WHvdZMI9LLh2m/iAnx3w59yYp8TTBjlAUDcYCmBnwGOECsUR5TxOF+SyPgsmkxOfv nqkoFrLady3X+hn6A/nHSPj+Ks/OCEDhZxPV585o= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 7277B394740B for ; Fri, 25 Nov 2022 07:59:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7277B394740B Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 966A621AE3; Fri, 25 Nov 2022 07:59:44 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 7DA6713A08; Fri, 25 Nov 2022 07:59:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ZyGUHfB1gGMhGgAAMHmgww (envelope-from ); Fri, 25 Nov 2022 07:59:44 +0000 Date: Fri, 25 Nov 2022 08:59:44 +0100 (CET) To: gcc-patches@gcc.gnu.org cc: Jan Hubicka Subject: [PATCH] tree-optimization/106912 - IPA profile and pure/const MIME-Version: 1.0 Message-Id: <20221125075944.7DA6713A08@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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 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-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" IPA profile instrumentation tries to clear the pure and const flags of functions but that's quite hopeless in particular for const since that attribute prevails on the type and thus on each call to the function leading to inconsistencies in the IL and eventual checking ICEs. There's no good reason to do this and it wouldn't fixup any indirect calls so just don't. No other instrumentation GCC does bothers about this. Bootstrap and regtest pending on x86_64-unknown-linux-gnu, OK? Thanks, Richard. PR tree-optimization/106912 * tree-profile.cc (tree_profiling): Do not clear pure/const flags. * gcc.dg/pr106912.c: New testcase. --- gcc/testsuite/gcc.dg/pr106912.c | 16 ++++++++++++++++ gcc/tree-profile.cc | 3 --- 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr106912.c diff --git a/gcc/testsuite/gcc.dg/pr106912.c b/gcc/testsuite/gcc.dg/pr106912.c new file mode 100644 index 00000000000..8faa877d8b3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr106912.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fPIC -ftree-vectorize -fprofile-generate" } */ + +__attribute__ ((__simd__)) +__attribute__ ((__nothrow__ , __leaf__ , __const__)) +double foo (double x); +void bar(double *f, int n) +{ + int i; + for (i = 0; i < n; i++) + f[i] = foo(f[i]); +} +double foo(double x) +{ + return x * x / 3.0; +} diff --git a/gcc/tree-profile.cc b/gcc/tree-profile.cc index 2beb49241f2..5491b398870 100644 --- a/gcc/tree-profile.cc +++ b/gcc/tree-profile.cc @@ -814,9 +814,6 @@ tree_profiling (void) /* Don't profile functions produced for builtin stuff. */ if (DECL_SOURCE_LOCATION (node->decl) == BUILTINS_LOCATION) continue; - - node->set_const_flag (false, false); - node->set_pure_flag (false, false); } /* Update call statements and rebuild the cgraph. */