From patchwork Tue Jan 24 12:37:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 63617 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 7B54E3858C83 for ; Tue, 24 Jan 2023 12:37:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7B54E3858C83 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674563861; bh=XmYYb1g2QBNV0vv3E9PkgD/6z2t192SL6WuWcS4QxtA=; h=Date:To:cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=yA/La5D3/zG5CAnUF8pDUH8TtuZAqK6kPzqjuHWn1steinr/Kz531j30DvDnYfspw 08EEVssGdyE1hsTWZ+93qm2KwEa6SViXrP0x4jN/VDuXaka6gJDM5CktMLJ3/A9Zhi p4Z1On+mND0p/dmc9/yYE65SHtCKgiAcbCjCJ1+s= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 5BEF43858D28 for ; Tue, 24 Jan 2023 12:37:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5BEF43858D28 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id EE8772188B; Tue, 24 Jan 2023 12:37:07 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id D802C139FB; Tue, 24 Jan 2023 12:37:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ug2tM/PQz2OMQwAAMHmgww (envelope-from ); Tue, 24 Jan 2023 12:37:07 +0000 Date: Tue, 24 Jan 2023 13:37:07 +0100 (CET) To: gcc-patches@gcc.gnu.org cc: Jakub Jelinek Subject: [PATCH] tree-optimization/108500 - avoid useless fast-query compute in CFG cleanup MIME-Version: 1.0 Message-Id: <20230124123707.D802C139FB@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" CFG cleanup computes dominators before the loop over blocks looking for merging opportunities. That computes also the fast-query DFS numbers but that's a bit pointless since any CFG cleanup will invalidate them immediately (they are re-computed before fixing up loops). The following avoids this and fixes the SIGSEGV due to the deep recursion in assign_dfs_numbers after inlining very many small functions. Bootstrapped and tested on x86_64-unknown-linux-gnu, it's a border-line regression and the following doesn't really avoid the deep recursion but instead cleans up the CFG before eventually doing it. OK for trunk? Thanks, Richard. PR tree-optimization/108500 * dominance.h (calculate_dominance_info): Add parameter to indicate fast-query compute, defaulted to true. * dominance.cc (calculate_dominance_info): Honor fast-query compute parameter. * tree-cfgcleanup.cc (cleanup_tree_cfg_noloop): Do not compute the dominator fast-query DFS numbers. --- gcc/dominance.cc | 9 ++++++--- gcc/dominance.h | 2 +- gcc/tree-cfgcleanup.cc | 6 ++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/gcc/dominance.cc b/gcc/dominance.cc index 13d5498443b..099b8fd3f24 100644 --- a/gcc/dominance.cc +++ b/gcc/dominance.cc @@ -705,10 +705,12 @@ compute_dom_fast_query_in_region (enum cdi_direction dir, } /* The main entry point into this module. DIR is set depending on whether - we want to compute dominators or postdominators. */ + we want to compute dominators or postdominators. If COMPUTE_FAST_QUERY + is false then the DFS numbers allowing for a O(1) dominance query + are not computed. */ void -calculate_dominance_info (cdi_direction dir) +calculate_dominance_info (cdi_direction dir, bool compute_fast_query) { unsigned int dir_index = dom_convert_dir_to_idx (dir); @@ -745,7 +747,8 @@ calculate_dominance_info (cdi_direction dir) else checking_verify_dominators (dir); - compute_dom_fast_query (dir); + if (compute_fast_query) + compute_dom_fast_query (dir); timevar_pop (TV_DOMINANCE); } diff --git a/gcc/dominance.h b/gcc/dominance.h index abdcf76e6f2..3c5a345f478 100644 --- a/gcc/dominance.h +++ b/gcc/dominance.h @@ -35,7 +35,7 @@ enum dom_state DOM_OK /* Everything is ok. */ }; -extern void calculate_dominance_info (enum cdi_direction); +extern void calculate_dominance_info (enum cdi_direction, bool = true); extern void calculate_dominance_info_for_region (enum cdi_direction, vec); extern void free_dominance_info (function *, enum cdi_direction); diff --git a/gcc/tree-cfgcleanup.cc b/gcc/tree-cfgcleanup.cc index ca0cb633f2c..64ff16fc45b 100644 --- a/gcc/tree-cfgcleanup.cc +++ b/gcc/tree-cfgcleanup.cc @@ -1106,9 +1106,11 @@ cleanup_tree_cfg_noloop (unsigned ssa_update_flags) timevar_push (TV_TREE_CLEANUP_CFG); } - /* Compute dominator info which we need for the iterative process below. */ + /* Compute dominator info which we need for the iterative process below. + Avoid computing the fast query DFS numbers since any block merging + done will invalidate them anyway. */ if (!dom_info_available_p (CDI_DOMINATORS)) - calculate_dominance_info (CDI_DOMINATORS); + calculate_dominance_info (CDI_DOMINATORS, false); else checking_verify_dominators (CDI_DOMINATORS);