From patchwork Sat Nov 13 23:51:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 47628 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 304E63857C44 for ; Sat, 13 Nov 2021 23:52:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 304E63857C44 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1636847541; bh=JCm+UPON3u/Ogc8o7+0wjwX3yIKBotgyFkoya2RZYnI=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=xK21oA9Vr9lCI7nOnPJDv2QTzOfCZAO1dzH0Xtpw6OxDvuDeDNdmxv+7Mp7wl/6QY xnOL6ACCUpUCCe06CFoELi09UpMi9tz/9gQfROFrNXFvTPupJyyZUpYy3+g8sZYYga XHCsppYFrV7sc0FZoyyFUFBgevdKGTbeUJybJAC4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) by sourceware.org (Postfix) with ESMTPS id 9733D3858D3C for ; Sat, 13 Nov 2021 23:51:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9733D3858D3C Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 11079280941; Sun, 14 Nov 2021 00:51:49 +0100 (CET) Date: Sun, 14 Nov 2021 00:51:49 +0100 To: gcc-patches@gcc.gnu.org Subject: Fix crash in gamess Message-ID: <20211113235149.GH13726@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Jan Hubicka via Gcc-patches From: Jan Hubicka Reply-To: Jan Hubicka Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi, this patch adds debug counters for pure/const discover and fixes somewhat embarrasing pasto I made while breaking out ipa_make_function_* helpers out of propagate_pure_const which led to wrong function being marked as pure that in turn leads to wrong code. My apologizes for that. Bootstrapped/regtested x86_64-linux, comitted. gcc/ChangeLog: PR lto/103211 * dbgcnt.def (ipa_attr): New counters. * ipa-pure-const.c: Include dbgcnt.c (ipa_make_function_const): Use debug counter. (ipa_make_function_pure): Likewise. (propagate_pure_const): Fix bug in my previous change. diff --git a/gcc/dbgcnt.def b/gcc/dbgcnt.def index 3a85665a1d7..f8a15f3d1d1 100644 --- a/gcc/dbgcnt.def +++ b/gcc/dbgcnt.def @@ -175,6 +175,7 @@ DEBUG_COUNTER (if_after_reload) DEBUG_COUNTER (if_conversion) DEBUG_COUNTER (if_conversion_tree) DEBUG_COUNTER (if_to_switch) +DEBUG_COUNTER (ipa_attr) DEBUG_COUNTER (ipa_cp_bits) DEBUG_COUNTER (ipa_cp_values) DEBUG_COUNTER (ipa_cp_vr) diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c index 5056850c0a8..a332940b55d 100644 --- a/gcc/ipa-pure-const.c +++ b/gcc/ipa-pure-const.c @@ -62,6 +62,7 @@ along with GCC; see the file COPYING3. If not see #include "ipa-prop.h" #include "ipa-fnsummary.h" #include "symtab-thunks.h" +#include "dbgcnt.h" /* Lattice values for const and pure functions. Everything starts out being const, then may drop to pure and then neither depending on @@ -1476,8 +1477,10 @@ ipa_make_function_const (struct cgraph_node *node, bool looping, bool local) fprintf (dump_file, "Function found to be %sconst: %s\n", looping ? "looping " : "", node->dump_name ()); - if (!local) + if (!local && !looping) cdtor = node->call_for_symbol_and_aliases (cdtor_p, NULL, true); + if (!dbg_cnt (ipa_attr)) + return false; if (node->set_const_flag (true, looping)) { if (dump_file) @@ -1511,8 +1514,10 @@ ipa_make_function_pure (struct cgraph_node *node, bool looping, bool local) fprintf (dump_file, "Function found to be %spure: %s\n", looping ? "looping " : "", node->dump_name ()); - if (!local) + if (!local && !looping) cdtor = node->call_for_symbol_and_aliases (cdtor_p, NULL, true); + if (!dbg_cnt (ipa_attr)) + return false; if (node->set_pure_flag (true, looping)) { if (dump_file) @@ -1797,11 +1802,11 @@ propagate_pure_const (void) switch (this_state) { case IPA_CONST: - remove_p |= ipa_make_function_const (node, this_looping, false); + remove_p |= ipa_make_function_const (w, this_looping, false); break; case IPA_PURE: - remove_p |= ipa_make_function_pure (node, this_looping, false); + remove_p |= ipa_make_function_pure (w, this_looping, false); break; default: