From patchwork Mon Jan 31 17:29:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 81195 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]) by ozlabs.org (Postfix) with SMTP id EEF9BB7118 for ; Tue, 1 Feb 2011 05:11:18 +1100 (EST) Received: (qmail 14260 invoked by alias); 31 Jan 2011 18:11:16 -0000 Received: (qmail 14252 invoked by uid 22791); 31 Jan 2011 18:11:15 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 31 Jan 2011 18:11:08 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0VIB7n7003096 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 31 Jan 2011 13:11:07 -0500 Received: from vishnu.quesejoda.com (vpn-238-126.phx2.redhat.com [10.3.238.126]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p0VHTIDI013922; Mon, 31 Jan 2011 12:29:18 -0500 Message-ID: <4D46F16D.7040703@redhat.com> Date: Mon, 31 Jan 2011 11:29:17 -0600 From: Aldy Hernandez User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Thunderbird/3.1.7 MIME-Version: 1.0 To: Richard Henderson , gcc-patches Subject: [trans-mem] COMMITTED: propagate irrevocability in the presence of EXIT_BLOCKs correctly 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 Currently we are getting confused when examining an EXIT_BLOCK in ipa_tm_propagate_irr(), because we assume for any given BB that all children are irrevocable unless we can prove otherwise. However, if we have no successors (e.g. an EXIT_BLOCK), we end up assuming all children are irrevocable, so the EXIT_BLOCK must be irrevocable as well. I believe this is an obvious patch and am committing as such. Please feel free to contradict me, if I am wrong. This patch fixes the ICE in PR/47340. * trans-mem.c (ipa_tm_propagate_irr): Handle exit blocks. Index: testsuite/gcc.dg/tm/pr47520.c =================================================================== --- testsuite/gcc.dg/tm/pr47520.c (revision 0) +++ testsuite/gcc.dg/tm/pr47520.c (revision 0) @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-fgnu-tm -O" } */ + +struct ReadSeqVars +{ + int format; + char *ss; +}; + +void rms_feof(struct ReadSeqVars *); + +__attribute__((transaction_callable)) int ReadSeq(struct ReadSeqVars *V) +{ + if (V->format > 1) + { + if ((V->format != 2) && (V->ss != (void*)0) ) + { + V->format = 3; + } + } + else + { + int i = 0; + for (i = 0; i < 1; i++) + { + } + rms_feof(V); + } +} Index: trans-mem.c =================================================================== --- trans-mem.c (revision 169292) +++ trans-mem.c (working copy) @@ -3656,7 +3656,7 @@ ipa_tm_scan_irr_blocks (VEC (basic_block /* Propagate the irrevocable property both up and down the dominator tree. BB is the current block being scanned; EXIT_BLOCKS are the edges of the - TM regions; OLD_IRR is the results of a previous scan of the dominator + TM regions; OLD_IRR are the results of a previous scan of the dominator tree which has been fully propagated; NEW_IRR is the set of new blocks which are gaining the irrevocable property during the current scan. */ @@ -3675,19 +3675,24 @@ ipa_tm_propagate_irr (basic_block entry_ { basic_block bb = VEC_pop (basic_block, bbs); bool this_irr = bitmap_bit_p (new_irr, bb->index); - bool all_son_irr = true; + bool all_son_irr = false; edge_iterator ei; edge e; - /* Propagate up. If my children are, I am too. */ + /* Propagate up. If my children are, I am too, but we must have + at least one child that is. */ if (!this_irr) { FOR_EACH_EDGE (e, ei, bb->succs) - if (!bitmap_bit_p (new_irr, e->dest->index)) - { - all_son_irr = false; - break; - } + { + if (!bitmap_bit_p (new_irr, e->dest->index)) + { + all_son_irr = false; + break; + } + else + all_son_irr = true; + } if (all_son_irr) { bitmap_set_bit (new_irr, bb->index);