From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) by sourceware.org (Postfix) with ESMTPS id EBFDF3858D37; Sun, 1 Nov 2020 14:48:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org EBFDF3858D37 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 E662828117F; Sun, 1 Nov 2020 15:48:50 +0100 (CET) Date: Sun, 1 Nov 2020 15:48:50 +0100 From: Jan Hubicka To: "su at cs dot ucdavis.edu" Cc: gcc-bugs@gcc.gnu.org Subject: Re: [Bug c/97578] ice during IPA pass: inline Message-ID: <20201101144850.GL66596@kam.mff.cuni.cz> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-15.8 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-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Nov 2020 14:48:56 -0000 Hi, this patch fixes the ICE, though I think we do have a design issue here while producing debug info across ltrans boundary. Martin, Jakub: as discussed on IRC it would be nice to add predicate when the body is really needed and avoid materializing if it is not. Can you add one? Something like param_adjustemnts->need_callee_parm_decls_p () Honza diff --git a/gcc/ipa-inline-transform.c b/gcc/ipa-inline-transform.c index 4df1b7fb9ee..907a95cac5a 100644 --- a/gcc/ipa-inline-transform.c +++ b/gcc/ipa-inline-transform.c @@ -51,6 +51,7 @@ along with GCC; see the file COPYING3. If not see #include "ipa-modref-tree.h" #include "ipa-modref.h" #include "symtab-thunks.h" +#include "symtab-clones.h" int ncalls_inlined; int nfunctions_inlined; @@ -695,6 +696,31 @@ preserve_function_body_p (struct cgraph_node *node) return false; } +/* tree-inline can not recurse; materialize all function bodie we will need + during inlining. This includes inlined functions, but also called functions + with param manipulation because IPA param manipulation attaches debug + statements to PARM_DECLs of called clone. Materialize them if needed. + + FIXME: This is somehwat broken by design because it does not play well + with partitioning. */ + +static void +maybe_materialize_called_clones (cgraph_node *node) +{ + for (cgraph_edge *e = node->callees; e; e = e->next_callee) + { + clone_info *info; + + if (!e->inline_failed) + maybe_materialize_called_clones (e->callee); + + cgraph_node *callee = cgraph_node::get (e->callee->decl); + if (callee->clone_of + && (info = clone_info::get (callee)) && info->param_adjustments) + callee->get_untransformed_body (); + } +} + /* Apply inline plan to function. */ unsigned int @@ -748,6 +774,7 @@ inline_transform (struct cgraph_node *node) ENTRY_BLOCK_PTR_FOR_FN (cfun)->count = node->count; } + maybe_materialize_called_clones (node); for (e = node->callees; e; e = next) { if (!e->inline_failed)