From patchwork Wed Feb 27 13:26:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1048878 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-497113-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="f/5ob6GU"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 448c0P6dLqz9s4V for ; Thu, 28 Feb 2019 00:26:45 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=pEdNuSRKP7H80zYLrh99R2lRyOEqaPA2lx0/aAdop2kgZKkTddp2N Rsaw0HY/E+yph/bTchNJom3wEsdDhtW6KNtwQ1rv/L8SRi32lYYdPxW6i8tGWiCq sWKLaK/Nj65ulkWjacNGEB8OWZpPtrEMtq4AGkrkYN+/N3rNhZ2a1g= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=t305jPGOHCsBbcpswR9P34EypxY=; b=f/5ob6GUddp4zIUdJHc3 YsiPYa2kC+NOi/gdzfn0Sq8j3GwIf30wJVBBonvCC8KLQb9yg0HOx6+yDf1DJxL2 kdwxQuOP83mVlvst/9Ws/LNeEdUH1F2fUn5p1E/M0Z5Sasjx6M1Mh3SBJektBKjD RJa6ELZeR6Lu8Cum78hacIM= Received: (qmail 50503 invoked by alias); 27 Feb 2019 13:26:38 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 50488 invoked by uid 89); 27 Feb 2019 13:26:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_NUMSUBJECT, SPF_PASS autolearn=ham version=3.3.2 spammy=repair, voi X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 27 Feb 2019 13:26:36 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 94DCAAD81 for ; Wed, 27 Feb 2019 13:26:34 +0000 (UTC) Date: Wed, 27 Feb 2019 14:26:34 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR89497 Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 CFG cleanup is now set up to perform trivial unreachable code elimination before doing anything that would require up-to-date SSA form. Unfortunately a pending SSA update still will cause breakage to stmt folding triggered for example by basic-block merging. Fortunately it's now easy to properly "interleave" CFG cleanup and SSA update. Done as follows, bootstrap & regtest running on x86_64-unknown-linux-gnu. Richard. 2019-02-27 Richard Biener PR middle-end/89497 * tree-cfgcleanup.h (cleanup_tree_cfg): Add SSA update flags argument, defaulted to zero. * passes.c (execute_function_todo): Pass down SSA update flags to cleanup_tree_cfg. * tree-cfgcleanup.c: Include tree-into-ssa.h and tree-cfgcleanup.h. (cleanup_tree_cfg_noloop): After cleanup_control_flow_pre update SSA form if requested. (cleanup_tree_cfg): Get and pass down SSA update flags. Index: gcc/tree-cfgcleanup.h =================================================================== --- gcc/tree-cfgcleanup.h (revision 269251) +++ gcc/tree-cfgcleanup.h (working copy) @@ -22,7 +22,7 @@ along with GCC; see the file COPYING3. /* In tree-cfgcleanup.c */ extern bitmap cfgcleanup_altered_bbs; -extern bool cleanup_tree_cfg (void); +extern bool cleanup_tree_cfg (unsigned = 0); extern bool fixup_noreturn_call (gimple *stmt); extern bool delete_unreachable_blocks_update_callgraph (cgraph_node *dst_node, bool update_clones); Index: gcc/passes.c =================================================================== --- gcc/passes.c (revision 269251) +++ gcc/passes.c (working copy) @@ -1927,7 +1927,7 @@ execute_function_todo (function *fn, voi /* Always cleanup the CFG before trying to update SSA. */ if (flags & TODO_cleanup_cfg) { - cleanup_tree_cfg (); + cleanup_tree_cfg (flags & TODO_update_ssa_any); /* When cleanup_tree_cfg merges consecutive blocks, it may perform some simplistic propagation when removing single Index: gcc/tree-cfgcleanup.c =================================================================== --- gcc/tree-cfgcleanup.c (revision 269251) +++ gcc/tree-cfgcleanup.c (working copy) @@ -44,6 +44,9 @@ along with GCC; see the file COPYING3. #include "gimple-fold.h" #include "tree-ssa-loop-niter.h" #include "cgraph.h" +#include "tree-into-ssa.h" +#include "tree-cfgcleanup.h" + /* The set of blocks in that at least one of the following changes happened: -- the statement at the end of the block was changed @@ -943,7 +946,7 @@ mfb_keep_latches (edge e) Return true if the flowgraph was modified, false otherwise. */ static bool -cleanup_tree_cfg_noloop (void) +cleanup_tree_cfg_noloop (unsigned ssa_update_flags) { timevar_push (TV_TREE_CLEANUP_CFG); @@ -1023,6 +1026,8 @@ cleanup_tree_cfg_noloop (void) /* After doing the above SSA form should be valid (or an update SSA should be required). */ + if (ssa_update_flags) + update_ssa (ssa_update_flags); /* Compute dominator info which we need for the iterative process below. */ if (!dom_info_available_p (CDI_DOMINATORS)) @@ -1125,9 +1130,9 @@ repair_loop_structures (void) /* Cleanup cfg and repair loop structures. */ bool -cleanup_tree_cfg (void) +cleanup_tree_cfg (unsigned ssa_update_flags) { - bool changed = cleanup_tree_cfg_noloop (); + bool changed = cleanup_tree_cfg_noloop (ssa_update_flags); if (current_loops != NULL && loops_state_satisfies_p (LOOPS_NEED_FIXUP))