From patchwork Sat Aug 21 02:50:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 1519219 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+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) 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 4Gs30s14nzz9s1l for ; Sat, 21 Aug 2021 12:51:07 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 87336385F02D for ; Sat, 21 Aug 2021 02:51:00 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [IPv6:2620:20:4000:0:a9e:1ff:fe9b:1d1]) by sourceware.org (Postfix) with ESMTPS id 2732F3858434 for ; Sat, 21 Aug 2021 02:50:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2732F3858434 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 4F9A91165F1; Fri, 20 Aug 2021 22:50:25 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id UNLItMi4VqBH; Fri, 20 Aug 2021 22:50:25 -0400 (EDT) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id E44DB1165E1; Fri, 20 Aug 2021 22:50:24 -0400 (EDT) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 17L2oFUu1698550 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 20 Aug 2021 23:50:16 -0300 From: Alexandre Oliva To: gcc-patches@gcc.gnu.org Subject: fix latent bootstrap-debug issue (modref, tree-inline, tree jump-threading) Organization: Free thinker, does not speak for AdaCore Date: Fri, 20 Aug 2021 23:50:15 -0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, 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: , Cc: Jan Hubicka Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" I've hit a bootstrap-debug error involving large subprograms in gcc/ada/sem_ch12.adb. I'm afraid I couldn't narrow it down to a reasonable testcase. thread1 made different decisions about a block containing a builtin_eh_filter call because in one compilation, estimate_num_insns found a cgraph_node for the builtin and could thus get to the is_simple_builtin test, but in the other it didn't. With different insn counts, one stage jump-threaded and the other didn't, and the resulting code diverged quite a bit. The reason the builtin had a cgraph_node in one case but not the other was that modref got a chance to analyze the builtin call when it was the first stmt in the block, and that created the cgraph_node. However, when it was preceded by debug stmts, the loop in analyze_function was cut short after the first debug stmt, because the summary so far was not useful. This patch fixes both issues: skip debug stmts in the analyze_function loop, so as to prevent them from affecting any decisions in the loop, and enable the insn count estimator to get to the is_simple_builtin test when a cgraph_node has not been created for the builtin. Regstrapped on x86_64-linux-gnu. Ok to install? for gcc/ChangeLog * ipa-modref.c (analyze_function): Skip debug stmts. * tree-inline.c (estimate_num_insn): Consider builtins even without a cgraph_node. --- gcc/ipa-modref.c | 3 ++- gcc/tree-inline.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/gcc/ipa-modref.c b/gcc/ipa-modref.c index fafd804d4bae4..f0cddbb077aaa 100644 --- a/gcc/ipa-modref.c +++ b/gcc/ipa-modref.c @@ -2108,7 +2108,8 @@ analyze_function (function *f, bool ipa) FOR_EACH_BB_FN (bb, f) { gimple_stmt_iterator si; - for (si = gsi_after_labels (bb); !gsi_end_p (si); gsi_next (&si)) + for (si = gsi_start_nondebug_after_labels_bb (bb); + !gsi_end_p (si); gsi_next_nondebug (&si)) { if (!analyze_stmt (summary, summary_lto, gsi_stmt (si), ipa, &recursive_calls) diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index d0e9f52d5f138..636130fe0019e 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -4436,8 +4436,8 @@ estimate_num_insns (gimple *stmt, eni_weights *weights) /* Do not special case builtins where we see the body. This just confuse inliner. */ struct cgraph_node *node; - if (!(node = cgraph_node::get (decl)) - || node->definition) + if ((node = cgraph_node::get (decl)) + && node->definition) ; /* For buitins that are likely expanded to nothing or inlined do not account operand costs. */