From patchwork Thu Aug 15 19:03:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 267422 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id CB9922C01B8 for ; Fri, 16 Aug 2013 05:03:24 +1000 (EST) 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=Zl4I+B2tALzhKOXq1sSrMYXDMx9Cd 0RoBqvf4g6974IsF1IMe3xJUuSCzvKPpC9sP5f3GIiBdMRmjJd464DCUKpFd1lUD O28LRNnCEmvM7/cenlHzrkEvcNQ6ujR5rX07zSu3NerfiSzPNuRGwjzIZ44SBHIk MTr50Do5qGX0gU= 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=KoQ6KBQryebq243WlXrgROV/oQc=; b=yWa NmRnbh2tPHMTGpmCltOzyo23Bg4M6RbbHBMk+mw1SLV5q78DQJtBXTS6Jyf+hajQ NT/TZihvEZIZXegZZcRDasu1Dn2FjaGNvBZGLiRVSr2frNjQX1CgnbCBok4XVwVY X153sPu8vJH3cosFJo4rEbLnH6Bs5G8ryIcfUgXM= Received: (qmail 613 invoked by alias); 15 Aug 2013 19:03:17 -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 600 invoked by uid 89); 15 Aug 2013 19:03:16 -0000 X-Spam-SWARE-Status: No, score=-7.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 15 Aug 2013 19:03:14 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r7FJ3CmT003166 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 15 Aug 2013 15:03:12 -0400 Received: from zalov.cz (vpn1-7-127.ams2.redhat.com [10.36.7.127]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r7FJ3Bef005914 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 15 Aug 2013 15:03:12 -0400 Received: from zalov.cz (localhost [127.0.0.1]) by zalov.cz (8.14.5/8.14.5) with ESMTP id r7FJ3APv025478; Thu, 15 Aug 2013 21:03:10 +0200 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id r7FJ39X0025477; Thu, 15 Aug 2013 21:03:09 +0200 Date: Thu, 15 Aug 2013 21:03:09 +0200 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix tree-call-cdce.c (PR tree-optimization/58165) Message-ID: <20130815190309.GC1814@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Hi! On the following testcase we ICE because the builtin fn prototype doesn't have throw () on it (glibc headers provide it, but some other C libraries apparently don't) and thus we can have EH edges out of the builtin, and call-cdce unconditionally split the block, leaving EH edge from an empty bb and the required EH edge missing from the call. In that case there is no point in splitting the block though, so fixed thusly (not looking for last stmt, because that might be problematic with -fcompare-debug). Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/4.8? 2013-08-15 Jakub Jelinek PR tree-optimization/58165 * tree-call-cdce.c (shrink_wrap_one_built_in_call): If bi_call must be the last stmt in a bb, don't split_block, instead use fallthru edge from it and give up if there is none. Release conds vector when returning early. * g++.dg/opt/pr58165.C: New test. Jakub --- gcc/tree-call-cdce.c.jj 2013-08-13 12:20:33.000000000 +0200 +++ gcc/tree-call-cdce.c 2013-08-15 14:54:28.328435719 +0200 @@ -726,15 +726,28 @@ shrink_wrap_one_built_in_call (gimple bi return false and do not do any transformation for the call. */ if (nconds == 0) - return false; + { + conds.release (); + return false; + } bi_call_bb = gimple_bb (bi_call); - /* Now find the join target bb -- split - bi_call_bb if needed. */ - bi_call_bsi = gsi_for_stmt (bi_call); + /* Now find the join target bb -- split bi_call_bb if needed. */ + if (stmt_ends_bb_p (bi_call)) + { + /* If the call must be the last in the bb, don't split the block, + it could e.g. have EH edges. */ + join_tgt_in_edge_from_call = find_fallthru_edge (bi_call_bb->succs); + if (join_tgt_in_edge_from_call == NULL) + { + conds.release (); + return false; + } + } + else + join_tgt_in_edge_from_call = split_block (bi_call_bb, bi_call); - join_tgt_in_edge_from_call = split_block (bi_call_bb, bi_call); bi_call_bsi = gsi_for_stmt (bi_call); join_tgt_bb = join_tgt_in_edge_from_call->dest; --- gcc/testsuite/g++.dg/opt/pr58165.C.jj 2013-08-15 14:39:20.492586499 +0200 +++ gcc/testsuite/g++.dg/opt/pr58165.C 2013-08-15 14:38:43.000000000 +0200 @@ -0,0 +1,14 @@ +// PR tree-optimization/58165 +// { dg-do compile } +// { dg-options "-O2" } + +extern "C" float sqrtf (float); + +struct A { A (); ~A (); }; + +void +foo (double d) +{ + A a; + sqrtf (d); +}