From patchwork Tue Oct 30 16:26:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Bosscher X-Patchwork-Id: 195536 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 D6B7E2C009B for ; Wed, 31 Oct 2012 03:27:01 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1352219222; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: MIME-Version:Received:From:Date:Message-ID:Subject:To:Cc: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=yeKQ1/K WLQ4CdxxqOFDqH6oU18U=; b=yo5tyDwBAmFSsSbM2ajLyWba9bqKM2przaeYNSn Hjnqd2U+43Bx+RtC3vEC2G4m2OuwWZ/sAV78DKftr+aAKBv7n2+kwiAtQEOuJWGF uxTfpWWll6K67wZGSj2QL8DtMznBCiWRyLO5bV6PwcdUpxjMHC9Re5/FbPoZqlfJ Bccw= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:MIME-Version:Received:From:Date:Message-ID:Subject:To:Cc:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=W/2T2kDxylc7hkOEs38wySCy9tcSHfhwiDxsFP1O7Zo+KOTzZTxdjkOmjqP/0G N16WJ3VuxSaRGO9nQfcIaEpn9bauz6chU7pKTkaSnYzE42dOOSIhVzyU1gyVEDzv kibc1p38Fd/QSBDcl8nkWWn4snbZQDfdUVApx1JFRY6uw=; Received: (qmail 18119 invoked by alias); 30 Oct 2012 16:26:53 -0000 Received: (qmail 18035 invoked by uid 22791); 30 Oct 2012 16:26:51 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, TW_CF X-Spam-Check-By: sourceware.org Received: from mail-lb0-f175.google.com (HELO mail-lb0-f175.google.com) (209.85.217.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 30 Oct 2012 16:26:45 +0000 Received: by mail-lb0-f175.google.com with SMTP id y2so370342lbk.20 for ; Tue, 30 Oct 2012 09:26:43 -0700 (PDT) Received: by 10.112.25.168 with SMTP id d8mr13307593lbg.61.1351614403425; Tue, 30 Oct 2012 09:26:43 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.88.99 with HTTP; Tue, 30 Oct 2012 09:26:23 -0700 (PDT) From: Steven Bosscher Date: Tue, 30 Oct 2012 17:26:23 +0100 Message-ID: Subject: [PATCH][RFC] Sanity checking for -freorder-blocks-and-partition failures To: GCC Patches Cc: Teresa Johnson , Matthew Gretton-Dann , Christophe Lyon X-IsSubscribed: yes 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 Hello, Hot/cold partitioning is apparently a hot topic all of a sudden, which is a good thing of course, because it's in need of some TLC. The attached patch adds another check the RTL cfg checking (verify_flow_info) for the partitioning: A hot block can never be dominated by a cold block (because the dominated block must also be cold). This trips in PR55121. I haven't tested this with any profiling tests, but it's bound to break things. From my POV, whatever gets broken by this patch was already broken to begin with :-) If you're in CC, it's because I hope you can help test this patch. Downside of this patch is that I need dominance info. If it's not available, I compute and free it. I'm not sure if this works if dominance info status is DOM_NO_FAST_QUERY, and I don't want to recompute in this case because IMHO a verifier should be a no-op from the POV of the rest of the compiler, and updating dominators would make this patch a not-a-no-op :-) Thoughts/comments? Ciao! Steven * cfgrtl.c (rtl_verify_flow_info_1): Verify that blocks in the hot partition are not dominated by blocks in the cold partition. Index: cfgrtl.c =================================================================== --- cfgrtl.c (revision 191819) +++ cfgrtl.c (working copy) @@ -2033,6 +2033,7 @@ rtl_verify_flow_info_1 (void) rtx x; int err = 0; basic_block bb; + bool have_partitions = false; /* Check the general integrity of the basic blocks. */ FOR_EACH_BB_REVERSE (bb) @@ -2145,6 +2146,8 @@ rtl_verify_flow_info_1 (void) n_eh++; else if (e->flags & EDGE_ABNORMAL) n_abnormal++; + + have_partitions |= is_crossing; } if (n_eh && !find_reg_note (BB_END (bb), REG_EH_REGION, NULL_RTX)) @@ -2263,6 +2268,40 @@ rtl_verify_flow_info_1 (void) } } + /* If there are partitions, do a sanity check on them: A basic block in + a cold partition cannot dominate a basic block in a hot partition. */ + VEC (basic_block, heap) *bbs_in_cold_partition = NULL; + if (have_partitions && !err) + FOR_EACH_BB (bb) + if ((BB_PARTITION (bb) == BB_COLD_PARTITION)) + VEC_safe_push (basic_block, heap, bbs_in_cold_partition, bb); + if (! VEC_empty (basic_block, bbs_in_cold_partition)) + { + bool dom_calculated_here = !dom_info_available_p (CDI_DOMINATORS); + basic_block son; + + if (dom_calculated_here) + calculate_dominance_info (CDI_DOMINATORS); + + while (! VEC_empty (basic_block, bbs_in_cold_partition)) + { + bb = VEC_pop (basic_block, bbs_in_cold_partition); + if ((BB_PARTITION (bb) != BB_COLD_PARTITION)) + { + error ("non-cold basic block %d dominated " + "by a block in the cold partition", bb->index); + err = 1; + } + for (son = first_dom_son (CDI_DOMINATORS, bb); + son; + son = next_dom_son (CDI_DOMINATORS, son)) + VEC_safe_push (basic_block, heap, bbs_in_cold_partition, son); + } + + if (dom_calculated_here) + free_dominance_info (CDI_DOMINATORS); + } + /* Clean up. */ return err; }