From patchwork Tue Feb 5 15:32:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1036817 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-495306-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="OVziCu+C"; 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 43v7r63dRrz9sMM for ; Wed, 6 Feb 2019 02:32:49 +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:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=QPiWtiMHBboeJRhnWGi0uxSsV3nbi treVMB8XgZ46+wjyMlGGID4/Rm3U8k1Jgz3Gs/cTWVDb+8rWRV3CMRe71oPL7ZCo wsIj9h5dJmoWcwb5tqUAm9K/R5k070iJ6GtTNXBVIpMpzTx+5ccOKMMmb37Sm2Of fDWaZBx1Xu2hc8= 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:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=w074sf5rqcudJ72LleN1g7Fc/NI=; b=OVz iCu+C7dsxjjeN0bcKE1pyJ/G1BmKeIT/8nFnbFknpnk4auWUZc7E+fqoY5X3SUKY lnDDynQFljdxFssEGNxN4PHDMSmTbRROoO2iaZnYMYrjGNH1HaRCg28rCuetsShX JU744juizLVaIzn1nbNWUD+XEX2opRNJYLD3KpAw= Received: (qmail 61097 invoked by alias); 5 Feb 2019 15:32:41 -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 61089 invoked by uid 89); 5 Feb 2019 15:32:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=prepared, Always X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 05 Feb 2019 15:32:36 +0000 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3DCBD87638; Tue, 5 Feb 2019 15:32:35 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-88.ams2.redhat.com [10.36.116.88]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8C697B28C7; Tue, 5 Feb 2019 15:32:34 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id x15FWWKb006397; Tue, 5 Feb 2019 16:32:32 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id x15FWTER006396; Tue, 5 Feb 2019 16:32:29 +0100 Date: Tue, 5 Feb 2019 16:32:29 +0100 From: Jakub Jelinek To: Richard Biener , Eric Botcazou Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix RTL DCE (PR target/89188) Message-ID: <20190205153229.GT2135@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-IsSubscribed: yes Hi! RTL DCE is called in different modes, sometimes it is allowed to alter cfg, in other cases it is not. The following testcase ICEs because when it is not allowed to alter cfg (combiner's df_analyze) we remove a noop move that was considered to potentially throw and that made a bb unreachable (which the pass didn't like), but even removing those unreachable bbs would ICE anyway, as the algorithm is for !can_alter_cfg not really prepared to see bbs and edges being removed. So, the following patch does 3 things: 1) doesn't delete noop moves if they can throw and we can't alter cfg or delete dead exceptions 2) instead of setting must_clean blindly for any CALL_INSNs, it instead sets it accurately from delete_insn_and_edges return value 3) it asserts that if !can_alter_cfg we don't actually have must_clean set Bootstrapped/regtested on powerpc64{,le}-linux, ok for trunk? 2019-02-05 Jakub Jelinek PR target/89188 * dce.c (delete_unmarked_insns): Don't remove no-op moves if they can throw, non-call exceptions are enabled and we can't delete dead exceptions or alter cfg. Set must_clean if delete_insn_and_edges returns true, don't set it blindly for calls. Assert that delete_unreachable_blocks is called only if can_alter_cfg. * g++.dg/opt/pr89188.C: New test. Jakub --- gcc/dce.c.jj 2019-02-05 10:04:16.984062429 +0100 +++ gcc/dce.c 2019-02-05 10:53:47.655584503 +0100 @@ -584,7 +584,12 @@ delete_unmarked_insns (void) rtx turn_into_use = NULL_RTX; /* Always delete no-op moves. */ - if (noop_move_p (insn)) + if (noop_move_p (insn) + /* Unless the no-op move can throw and we are not allowed + to alter cfg. */ + && (!cfun->can_throw_non_call_exceptions + || (cfun->can_delete_dead_exceptions && can_alter_cfg) + || insn_nothrow_p (insn))) { if (RTX_FRAME_RELATED_P (insn)) turn_into_use @@ -627,12 +632,6 @@ delete_unmarked_insns (void) for the destination regs in order to avoid dangling notes. */ remove_reg_equal_equiv_notes_for_defs (insn); - /* If a pure or const call is deleted, this may make the cfg - have unreachable blocks. We rememeber this and call - delete_unreachable_blocks at the end. */ - if (CALL_P (insn)) - must_clean = true; - if (turn_into_use) { /* Don't remove frame related noop moves if they cary @@ -645,12 +644,15 @@ delete_unmarked_insns (void) } else /* Now delete the insn. */ - delete_insn_and_edges (insn); + must_clean |= delete_insn_and_edges (insn); } /* Deleted a pure or const call. */ if (must_clean) - delete_unreachable_blocks (); + { + gcc_assert (can_alter_cfg); + delete_unreachable_blocks (); + } } --- gcc/testsuite/g++.dg/opt/pr89188.C.jj 2019-02-04 14:20:57.714851393 +0100 +++ gcc/testsuite/g++.dg/opt/pr89188.C 2019-02-04 14:52:09.988782531 +0100 @@ -0,0 +1,5 @@ +// PR target/89188 +// { dg-do compile { target c++11 } } +// { dg-options "-Og -flive-range-shrinkage -fnon-call-exceptions" } + +#include "../torture/pr88861.C"