From patchwork Thu Nov 4 16:13:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1551089 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=cMSExhqQ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4HlTGj5c8Lz9s5P for ; Fri, 5 Nov 2021 03:14:05 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 18B19385801B for ; Thu, 4 Nov 2021 16:14:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 18B19385801B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1636042443; bh=IhIlQB1ZqlXxzBADYIqh+QpODUHDpz5rXfCgYpH+HKo=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=cMSExhqQgPsOyI4IbuuvF3iMyUUnewvPIfnYLN6RYBUcGVm5f/Bu7Z9gudh6KSlad dO7wPekHriGqCiFZlbU/3T+xg/QV0Nv8VkLdvaK9VrQsUaIpAIseEDHhmXCaYJmFyb dA0wTlkeOXYpySlFFNmPQBgwoIEBc3KyYzhiDIGY= 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 DA987385840B for ; Thu, 4 Nov 2021 16:13:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DA987385840B Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 8E5A1280F28; Thu, 4 Nov 2021 17:13:41 +0100 (CET) Date: Thu, 4 Nov 2021 17:13:41 +0100 To: gcc-patches@gcc.gnu.org Subject: Workaround ICE in gimple_static_chain_flags Message-ID: <20211104161341.GA83757@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.6 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi, this patch workarounds ICE in gimple_static_chain_flags. I added a sanity check that the nested function is never considered interposable because such situation makes no sense: nested functions have no static API and can not be safely merged across translation units. It turns out however that this triggers for Ada and also for Fortran if LTO partitioning separates nested function from its origin. The secon is bug in binds_to_current_def_p which I was fixing some time ago but it seems that the patch got lost :( So I will dig it out and fix the situation property however to unbreak periodic testers I am silencing the ICE for now (at expense of missed optimization) Honza gcc/ChangeLog: 2021-11-04 Jan Hubicka PR ipa/103058 * gimple.c (gimple_call_static_chain_flags): Handle case when nested function does not bind locally. diff --git a/gcc/gimple.c b/gcc/gimple.c index 76768c19c8e..7a578f5113e 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -1666,7 +1666,18 @@ gimple_call_static_chain_flags (const gcall *stmt) int modref_flags = summary->static_chain_flags; /* We have possibly optimized out load. Be conservative here. */ - gcc_checking_assert (node->binds_to_current_def_p ()); + if (!node->binds_to_current_def_p ()) + { + if ((modref_flags & EAF_UNUSED) && !(flags & EAF_UNUSED)) + { + modref_flags &= ~EAF_UNUSED; + modref_flags |= EAF_NOESCAPE; + } + if ((modref_flags & EAF_NOREAD) && !(flags & EAF_NOREAD)) + modref_flags &= ~EAF_NOREAD; + if ((modref_flags & EAF_DIRECT) && !(flags & EAF_DIRECT)) + modref_flags &= ~EAF_DIRECT; + } if (dbg_cnt (ipa_mod_ref_pta)) flags |= modref_flags; }