From patchwork Tue May 14 21:42:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teresa Johnson X-Patchwork-Id: 243830 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 89CCB2C00A4 for ; Wed, 15 May 2013 07:42:15 +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 :to:cc:subject:mime-version:content-type :content-transfer-encoding:message-id:from; q=dns; s=default; b= aHUqJ52kCWkIb53Lk3WYATsIFc8Sa68mVR9T6WKknze5n8EV88uGqGnVrCM/eWYt JvgRNWZXiU7vmJNedmCfnhKiKwQb4vzXyiZRbx9NKwTQAgWIrU2SIEeJOywKvIHq RsRK3KWOeI957NaFetiYpvDBu4hzbFIhM6b2zIVwwrM= 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 :to:cc:subject:mime-version:content-type :content-transfer-encoding:message-id:from; s=default; bh=kGCIvj f0LqMkVeCjQRTxIf1eu+E=; b=QY21Rj1fNH0r1v0Qev4qgODeRlDpNHllbAlPYe 8h8+cBHM2+mx9MK4CTpc+Y2XvTAyVihqg2Up+fM38tKCQ6RnjFAxm6wPH2vxmPSY tkDJlZexqqtM/zdnjeSV1mxqhbJe0V+jfFuL1GR0ACKssozE6DZzxJBiIeuXJkQe DUqtg= Received: (qmail 17475 invoked by alias); 14 May 2013 21:42:08 -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 17449 invoked by uid 89); 14 May 2013 21:42:05 -0000 X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.1 Received: from mail-gh0-f201.google.com (HELO mail-gh0-f201.google.com) (209.85.160.201) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 14 May 2013 21:42:03 +0000 Received: by mail-gh0-f201.google.com with SMTP id r14so119317ghr.2 for ; Tue, 14 May 2013 14:42:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:date:to:cc:subject:user-agent:mime-version:content-type :content-transfer-encoding:message-id:from:x-gm-message-state; bh=i4eQ54VhAMoIrBEKTwHu0kpXuQ1qXl3KOrkkj5x9U68=; b=QdPzZDxzaEYRviYD+kPPJTBwgPKVf5uoa1F6OhENWo75DbWXdJVThL/AIlz73MvPr7 SdlIFro9i9Ia69VzIavMNAeFYHjHuqyOjmZhNVDA2cQ9imnWiVOGIybgF5PqmMj1YPw6 aDQClL8itrGUAdwpWtUIQz93H+3iV3j4SeTLGKBmpkGAnWMKFaf9zh0gdWYwuDacbJ4N 46xJyGv2tmD4LQv/wxbfu6gHNUvOZqPCJWBiQRPKNn/C7O4NuBlwA7PvpeGTKFQzNqRF y4mf8vtd6dWau9LgT2H8qogj2yuQnNkEtC2NcjoZNCbHderY6QRcGxSNyQpfcCwqWHh8 l8yA== X-Received: by 10.236.163.193 with SMTP id a41mr4946331yhl.0.1368567721953; Tue, 14 May 2013 14:42:01 -0700 (PDT) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id s48si4478yhe.6.2013.05.14.14.42.01 for (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Tue, 14 May 2013 14:42:01 -0700 (PDT) Received: from tjsboxrox.mtv.corp.google.com (tjsboxrox.mtv.corp.google.com [172.17.129.49]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id B163D31C07C; Tue, 14 May 2013 14:42:01 -0700 (PDT) Received: by tjsboxrox.mtv.corp.google.com (Postfix, from userid 147431) id 5DA3980BE7; Tue, 14 May 2013 14:42:01 -0700 (PDT) Date: Tue, 14 May 2013 14:42:01 -0700 To: hubicka@ucw.cz, law@redhat.com, gcc-patches@gcc.gnu.org Cc: davidxl@google.com, stevenb.gcc@gmail.com Subject: [PATCH] Improvements to -freorder-blocks-and-partition support User-Agent: Heirloom mailx 12.5 6/20/10 MIME-Version: 1.0 Message-Id: <20130514214201.5DA3980BE7@tjsboxrox.mtv.corp.google.com> From: tejohnson@google.com (Teresa Johnson) X-Gm-Message-State: ALoCoQl3/HD5BgnJQJfBNfLWiVTRX5coUKN3Jh2Keiy6FXS4CATzmOD3wfTbtZL5zO1zknotdhTzJjItgXEWxQHthLnSQ4LzyaAEzhkjGLLjZSHvDVBTFOiOY5kqgZiA576Z0U7mD8+fdHdpqx8cFlLT1KiEHtnT5t/n66plIiTU6V48/mkCmGJvFaQ8F3YASZ2kgEHsNbWsfN/J60qNE93NYUMqUAhA5wekEA2w2ZrCXIuzJllPyGQ= Patch 1 of 3 split out from the patch I sent last week that fixes problems with -freorder-blocks-and-partition, with some additional verification improvements. See http://gcc.gnu.org/ml/gcc-patches/2013-05/threads.html#00388 for context. This patch adds a flag to the rtl_data structure to indicate whether any partitioning was actually performed, so that optimizations which were conservatively disabled whenever the flag_reorder_blocks_and_partition is enabled (e.g. try_crossjump_to_edge, part of connect_traces) can be less conservative for functions where no partitions were formed (e.g. they are completely hot). It also adds another flag to the rtl_data structure to indicate whether bb reordering is complete, and if so enables sanity checking that there is at most one transition in the layout order between hot and cold sections. This was moved from verify_hot_cold_block_grouping, which was only called once at the end of the bbro pass and is now removed. Tested on x86_64-unknown-linux-gnu with bootstrap and profiledbootstrap builds and regression testing. Additionally built/ran cpu2006 with profile feedback and -freorder-blocks-and-partition enabled (which currently has build failures from splitting until my follow-on patches are in, but confirmed no new failures due to this patch), as well as gcc regression testing with -freorder-blocks-and-partition enabled. Ok for trunk? Thanks, Teresa 2013-05-14 Teresa Johnson * function.h (has_bb_partition): New rtl_data flag. (bb_reorder_complete): Ditto. * cfgrtl.c (rtl_verify_flow_info_1): After bbro, verify that text sections switch at most once in layout order. * bb-reorder.c (connect_traces): Check for has_bb_partition instead of flag_reorder_blocks_and_partition. (verify_hot_cold_block_grouping): Remove. (reorder_basic_blocks): Remove call to deleted verify_hot_cold_block_grouping, and set bb_reorder_complete. (partition_hot_cold_basic_blocks): Set has_bb_partition. * cfgcleanup.c (try_crossjump_to_edge): Check for has_bb_partition instead of flag_reorder_blocks_and_partition. Index: bb-reorder.c =================================================================== --- bb-reorder.c (revision 198891) +++ bb-reorder.c (working copy) @@ -1053,7 +1053,7 @@ connect_traces (int n_traces, struct trace *traces current_partition = BB_PARTITION (traces[0].first); two_passes = false; - if (flag_reorder_blocks_and_partition) + if (crtl->has_bb_partition) for (i = 0; i < n_traces && !two_passes; i++) if (BB_PARTITION (traces[0].first) != BB_PARTITION (traces[i].first)) @@ -1262,7 +1262,7 @@ connect_traces (int n_traces, struct trace *traces } } - if (flag_reorder_blocks_and_partition) + if (crtl->has_bb_partition) try_copy = false; /* Copy tiny blocks always; copy larger blocks only when the @@ -2068,43 +2068,6 @@ add_reg_crossing_jump_notes (void) add_reg_note (BB_END (e->src), REG_CROSSING_JUMP, NULL_RTX); } -/* Verify, in the basic block chain, that there is at most one switch - between hot/cold partitions. This is modelled on - rtl_verify_flow_info_1, but it cannot go inside that function - because this condition will not be true until after - reorder_basic_blocks is called. */ - -static void -verify_hot_cold_block_grouping (void) -{ - basic_block bb; - int err = 0; - bool switched_sections = false; - int current_partition = 0; - - FOR_EACH_BB (bb) - { - if (!current_partition) - current_partition = BB_PARTITION (bb); - if (BB_PARTITION (bb) != current_partition) - { - if (switched_sections) - { - error ("multiple hot/cold transitions found (bb %i)", - bb->index); - err = 1; - } - else - { - switched_sections = true; - current_partition = BB_PARTITION (bb); - } - } - } - - gcc_assert(!err); -} - /* Reorder basic blocks. The main entry point to this file. FLAGS is the set of flags to pass to cfg_layout_initialize(). */ @@ -2157,8 +2120,9 @@ reorder_basic_blocks (void) dump_flow_info (dump_file, dump_flags); } - if (flag_reorder_blocks_and_partition) - verify_hot_cold_block_grouping (); + /* Signal that rtl_verify_flow_info_1 can now verify that there + is at most one switch between hot/cold sections. */ + crtl->bb_reorder_complete = true; } /* Determine which partition the first basic block in the function @@ -2503,6 +2467,8 @@ partition_hot_cold_basic_blocks (void) if (!crossing_edges.exists ()) return 0; + crtl->has_bb_partition = true; + /* Make sure the source of any crossing edge ends in a jump and the destination of any crossing edge has a label. */ add_labels_and_missing_jumps (crossing_edges); Index: cfgrtl.c =================================================================== --- cfgrtl.c (revision 198891) +++ cfgrtl.c (working copy) @@ -2082,6 +2082,8 @@ rtl_verify_flow_info_1 (void) rtx x; int err = 0; basic_block bb; + bool switched_sections = false; + int current_partition = BB_UNPARTITIONED; /* Check the general integrity of the basic blocks. */ FOR_EACH_BB_REVERSE (bb) @@ -2299,6 +2301,29 @@ rtl_verify_flow_info_1 (void) err = 1; } + /* Verify, in the basic block chain, that there is at most one switch + between hot/cold partitions. This condition will not be true until + after reorder_basic_blocks is called. */ + if (crtl->bb_reorder_complete) + { + if (current_partition != BB_UNPARTITIONED + && BB_PARTITION (bb) != current_partition) + { + if (switched_sections) + { + error ("multiple hot/cold transitions found (bb %i)", + bb->index); + err = 1; + } + else + switched_sections = true; + + if (!crtl->has_bb_partition) + error ("partition found but function partition flag not set"); + } + current_partition = BB_PARTITION (bb); + } + if (BB_END (bb) == x) /* Do checks for empty blocks here. */ ; Index: function.h =================================================================== --- function.h (revision 198891) +++ function.h (working copy) @@ -446,6 +446,15 @@ struct GTY(()) rtl_data { sched2) and is useful only if the port defines LEAF_REGISTERS. */ bool uses_only_leaf_regs; + /* Nonzero if the function being compiled has undergone hot/cold partitioning + (under flag_reorder_blocks_and_partition) and has at least one cold + block. */ + bool has_bb_partition; + + /* Nonzero if the function being compiled has completed the bb reordering + pass. */ + bool bb_reorder_complete; + /* Like regs_ever_live, but 1 if a reg is set or clobbered from an asm. Unlike regs_ever_live, elements of this array corresponding to eliminable regs (like the frame pointer) are set if an asm Index: cfgcleanup.c =================================================================== --- cfgcleanup.c (revision 198891) +++ cfgcleanup.c (working copy) @@ -1864,7 +1864,7 @@ try_crossjump_to_edge (int mode, edge e1, edge e2, partition boundaries). See the comments at the top of bb-reorder.c:partition_hot_cold_basic_blocks for complete details. */ - if (flag_reorder_blocks_and_partition && reload_completed) + if (crtl->has_bb_partition && reload_completed) return false; /* Search backward through forwarder blocks. We don't need to worry