From patchwork Thu Oct 1 13:05:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1375053 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ucw.cz Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C2CzW6xFNz9sPB for ; Thu, 1 Oct 2020 23:05:42 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9A0593987C36; Thu, 1 Oct 2020 13:05:39 +0000 (GMT) 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 2FCA739730BC for ; Thu, 1 Oct 2020 13:05:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2FCA739730BC Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ucw.cz Authentication-Results: sourceware.org; spf=none smtp.mailfrom=hubicka@kam.mff.cuni.cz Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 0C0D8282AC8; Thu, 1 Oct 2020 15:05:36 +0200 (CEST) Date: Thu, 1 Oct 2020 15:05:36 +0200 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Fix ICE in ipa_edge_args_sum_t::duplicate Message-ID: <20201001130536.GA6452@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=-14.2 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: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi the ICE with -fno-ipa-modref is caused by fact that execute method has early exit for non-existent summary that forgets to free ipa-prop edge summaries. I moved the freeing code to free-fnsummary pass that is more robust way of handling this. Bootstrapped/regtested x86_64-linux, comitted. gcc/ChangeLog: 2020-10-01 Jan Hubicka PR ipa/97244 * ipa-fnsummary.c (pass_free_fnsummary::execute): Free also indirect inlining datastructure. * ipa-modref.c (pass_ipa_modref::execute): Do not free them here. * ipa-prop.c (ipa_free_all_node_params): Do not crash when info does not exist. (ipa_unregister_cgraph_hooks): Likewise. gcc/testsuite/ChangeLog: 2020-10-01 Jan Hubicka PR ipa/97244 * gcc.dg/ipa/remref-2a.c: Add -fno-ipa-modref diff --git a/gcc/ipa-fnsummary.c b/gcc/ipa-fnsummary.c index 4c1c1f91482..8285cc00d33 100644 --- a/gcc/ipa-fnsummary.c +++ b/gcc/ipa-fnsummary.c @@ -4680,6 +4680,8 @@ public: virtual unsigned int execute (function *) { ipa_free_fn_summary (); + /* Free ipa-prop structures if they are no longer needed. */ + ipa_free_all_structures_after_iinln (); if (!flag_wpa) ipa_free_size_summary (); return 0; diff --git a/gcc/ipa-modref.c b/gcc/ipa-modref.c index 6225552e41a..2f4da8f2a14 100644 --- a/gcc/ipa-modref.c +++ b/gcc/ipa-modref.c @@ -1681,8 +1681,6 @@ pass_ipa_modref::execute (function *) } ((modref_summaries *)summaries)->ipa = false; ipa_free_postorder_info (); - /* Free ipa-prop structures if they are no longer needed. */ - ipa_free_all_structures_after_iinln (); return 0; } diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index b28c78eeab4..ea88fd3fd95 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -4124,7 +4124,8 @@ ipa_free_all_edge_args (void) void ipa_free_all_node_params (void) { - ggc_delete (ipa_node_params_sum); + if (ipa_node_params_sum) + ggc_delete (ipa_node_params_sum); ipa_node_params_sum = NULL; } @@ -4368,7 +4369,8 @@ ipa_register_cgraph_hooks (void) static void ipa_unregister_cgraph_hooks (void) { - symtab->remove_cgraph_insertion_hook (function_insertion_hook_holder); + if (function_insertion_hook_holder) + symtab->remove_cgraph_insertion_hook (function_insertion_hook_holder); function_insertion_hook_holder = NULL; } diff --git a/gcc/testsuite/gcc.dg/ipa/remref-2a.c b/gcc/testsuite/gcc.dg/ipa/remref-2a.c index 34a6188249f..c2f3eac98a9 100644 --- a/gcc/testsuite/gcc.dg/ipa/remref-2a.c +++ b/gcc/testsuite/gcc.dg/ipa/remref-2a.c @@ -1,7 +1,7 @@ /* Verify that indirect inlining can also remove references of the functions it discovers calls for. */ /* { dg-do compile } */ -/* { dg-options "-O3 -fno-early-inlining -fno-ipa-cp -fdump-ipa-inline -fdump-tree-optimized -fno-ipa-icf" } */ +/* { dg-options "-O3 -fno-early-inlining -fno-ipa-cp -fdump-ipa-inline -fdump-tree-optimized -fno-ipa-icf -fno-ipa-modref" } */ int global;