From patchwork Thu Nov 18 22:15:47 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 72156 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 E256DB7141 for ; Fri, 19 Nov 2010 09:15:56 +1100 (EST) Received: (qmail 24315 invoked by alias); 18 Nov 2010 22:15:54 -0000 Received: (qmail 24303 invoked by uid 22791); 18 Nov 2010 22:15:53 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, TW_CF, TW_VZ, TW_ZJ X-Spam-Check-By: sourceware.org Received: from mail-pv0-f175.google.com (HELO mail-pv0-f175.google.com) (74.125.83.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 18 Nov 2010 22:15:49 +0000 Received: by pvd12 with SMTP id 12so1004599pvd.20 for ; Thu, 18 Nov 2010 14:15:47 -0800 (PST) MIME-Version: 1.0 Received: by 10.142.253.21 with SMTP id a21mr1041523wfi.219.1290118547601; Thu, 18 Nov 2010 14:15:47 -0800 (PST) Received: by 10.143.161.2 with HTTP; Thu, 18 Nov 2010 14:15:47 -0800 (PST) In-Reply-To: References: <20101117064421.GA30836@intel.com> Date: Thu, 18 Nov 2010 23:15:47 +0100 Message-ID: Subject: Re: PATCH: Properly check the end of basic block From: Uros Bizjak To: "H.J. Lu" Cc: gcc-patches@gcc.gnu.org, Jan Hubicka , Richard Henderson 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 On Thu, Nov 18, 2010 at 8:43 PM, Uros Bizjak wrote: > On Thu, Nov 18, 2010 at 8:37 PM, H.J. Lu wrote: > >>>> ix86_pad_returns forgot to update BB_END when it >>>> replaces it with a new one. OK for trunk? >>> >>> IMO,  you should just move the call to vzeroupper optimization to be >>> the first thing in ix86_reorg. This way, ix86_pad_short_function, >>> ix86_pad_returns and ix86_avoid_jump_mispredict will also count >>> emitted vzeroupper. >> >> But it will leave bad BB_END in place.  Any uses of BB_END later >> will still be screwed. > > I think that Jan or Richard (CC'd) can provide better answer on this issue. Got it. It is a pass ordering problem, we free CFG before machine reorg pass, so BLOCK_FOR_INSN in machine reorg pass does not work anymore (it returns 0). remove_insn (called from delete_insn) can correctly fixup BB_END (see emit-rtl.c, line 3883), but it needs data from BLOCK_FOR_INSN to figure out BB_END of the bb of the insn it processes. The fix is then trivial. 2010-11-18 Uros Bizjak PR middle-end/46546 * passes.c (init_optimization_passes): Move machine_reorg pass before free_cfg pass. Tested on x86_64-pc-linux-gnu {,-m32}. OK for mainline and release branches? Uros. Index: passes.c =================================================================== --- passes.c (revision 166920) +++ passes.c (working copy) @@ -1051,8 +1051,8 @@ init_optimization_passes (void) NEXT_PASS (pass_compute_alignments); NEXT_PASS (pass_duplicate_computed_gotos); NEXT_PASS (pass_variable_tracking); - NEXT_PASS (pass_free_cfg); NEXT_PASS (pass_machine_reorg); + NEXT_PASS (pass_free_cfg); NEXT_PASS (pass_cleanup_barriers); NEXT_PASS (pass_delay_slots); NEXT_PASS (pass_split_for_shorten_branches);