From patchwork Mon Mar 19 15:41:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 147559 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 DABD8B6FA9 for ; Tue, 20 Mar 2012 02:42:29 +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=1332776583; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Date: From:To:Cc:Subject:Message-ID:User-Agent:MIME-Version: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=5ow9UCa BpEXnTUuuTBgPcpuiMgQ=; b=wiQgjGex7bkAg1TrOV2iMTRWLH3YGP0/ivkZHu8 UKkmBOYNq7mkpGNmRsZBAIbmN7ttlH9p/nUwd7r4l0W+REdBsL8iWnf8g8s8+yP+ 0HY2kFM9k07fLbVmNyIoJxugQ3v8+3PBODxrpsuc4ZItq2s9iqkFrOKSyprOTj8p ZrbU= 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:Date:From:To:Cc:Subject:Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=fe76T/WOIKJaXZbrf0PvPRxzbfr1U7lHpW0IRh+0NTsVc/pDAGBlg3Hc+8nRuo g3r02En0nco1ZJdQgFddYV8Fis8aRxdrx+2yKsC8Qh4/4vPNXjKu8GGyFVoJapBs Z5V6KV2qzjBhGbVDbQC9l+o6zJyOkWtOIPKAOBqZai+64=; Received: (qmail 3794 invoked by alias); 19 Mar 2012 15:42:24 -0000 Received: (qmail 3641 invoked by uid 22791); 19 Mar 2012 15:42:23 -0000 X-SWARE-Spam-Status: No, hits=-5.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, TW_CF, TW_TM, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 19 Mar 2012 15:41:59 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 59B958BB22 for ; Mon, 19 Mar 2012 16:41:57 +0100 (CET) Date: Mon, 19 Mar 2012 16:41:57 +0100 (CET) From: Richard Guenther To: gcc-patches@gcc.gnu.org Cc: Jan Hubicka Subject: [PATCH][RFC] Merge 'expand' and 'rtl_eh' Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 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 We have the unfortunate situation that expand may leave us with unreachable blocks that are required by proper rtl_eh functioning (unreachable landing-pads, that is). This is bad for any verification pass the pass manager may want to call that requires dominators to be computed (I'm thinking of verifying loop structures, which I really want to do after expand as I am trying to preserve loop structures from tree loop optimization until after RTL loop optimization). This limitation has been introduced with the introduction of rtl_eh - and is, IMHO, bad as it exposed a partly broken IL state to the passmanager. Thus the following patch makes sure we can leave cfgexpand with no unreachable blocks around and simply merges the rtl_eh pass and expand. Yes, we do have several tests in the testsuite where EH landing pads get unreachable during expansion, by a disconnect of what GIMPLE thinks can throw and what the expanded code sequence says (bogus SSE builtin definitions in the x86_64 backend for example, see g++.dg/other/i386-1.C for two cases). Bootstrap and regtest on x86_64-unknown-linux-gnu running. Comments? Thanks, Richard. 2012-03-19 Richard Guenther * tree-pass.h (pass_rtl_eh): Remove. * except.c (gate_handle_eh): Likewise. (rest_of_handle_eh): Likewise. (pass_rtl_eh): Likewise. (finish_eh_generation): Export. * except.h (finish_eh_generation): Declare. * passes.c (init_optimization_passes): Remove pass_rtl_eh. * cfgexpand.c (gimple_expand_cfg): Call finish_eh_generation after expanding stack alignment. Instead of compacting blocks call cleanup_cfg. Index: gcc/cfgexpand.c =================================================================== *** gcc/cfgexpand.c (revision 185518) --- gcc/cfgexpand.c (working copy) *************** gimple_expand_cfg (void) *** 4623,4632 **** sbitmap_free (blocks); purge_all_dead_edges (); - compact_blocks (); - expand_stack_alignment (); #ifdef ENABLE_CHECKING verify_flow_info (); #endif --- 4632,4653 ---- sbitmap_free (blocks); purge_all_dead_edges (); expand_stack_alignment (); + /* After initial rtl generation, call back to finish generating + exception support code. We need to do this before cleaning up + the CFG as the code does not expect dead landing pads. */ + if (cfun->eh->region_tree != NULL) + finish_eh_generation (); + + /* Remove unreachable blocks, otherwise we cannot compute dominators + which are needed for loop state verification. As a side-effect + this also compacts blocks. + ??? We cannot remove trivially dead insns here as for example + the DRAP reg on i?86 is not magically live at this point. + gcc.c-torture/execute/ipa-sra-2.c execution, -Os -m32 fails otherwise. */ + cleanup_cfg (CLEANUP_NO_INSN_DEL); + #ifdef ENABLE_CHECKING verify_flow_info (); #endif Index: gcc/tree-pass.h =================================================================== --- gcc/tree-pass.h.orig 2012-03-19 16:29:36.000000000 +0100 +++ gcc/tree-pass.h 2012-03-19 16:28:03.000000000 +0100 @@ -488,7 +488,6 @@ extern struct gimple_opt_pass pass_fixup extern struct rtl_opt_pass pass_expand; extern struct rtl_opt_pass pass_init_function; extern struct rtl_opt_pass pass_jump; -extern struct rtl_opt_pass pass_rtl_eh; extern struct rtl_opt_pass pass_initial_value_sets; extern struct rtl_opt_pass pass_unshare_all_rtl; extern struct rtl_opt_pass pass_instantiate_virtual_regs; Index: gcc/except.c =================================================================== --- gcc/except.c.orig 2012-03-19 16:29:36.000000000 +0100 +++ gcc/except.c 2012-03-19 16:29:06.000000000 +0100 @@ -81,7 +81,7 @@ along with GCC; see the file COPYING3. gimple to eh_region mapping that had been recorded in the THROW_STMT_TABLE. - During pass_rtl_eh (except.c), we generate the real landing pads + Then, via finish_eh_generation, we generate the real landing pads to which the runtime will actually transfer control. These new landing pads perform whatever bookkeeping is needed by the target backend in order to resume execution within the current function. @@ -1414,7 +1414,7 @@ sjlj_build_landing_pads (void) /* After initial rtl generation, call back to finish generating exception support code. */ -static void +void finish_eh_generation (void) { basic_block bb; @@ -1461,41 +1461,6 @@ finish_eh_generation (void) } } } - -static bool -gate_handle_eh (void) -{ - /* Nothing to do if no regions created. */ - return cfun->eh->region_tree != NULL; -} - -/* Complete generation of exception handling code. */ -static unsigned int -rest_of_handle_eh (void) -{ - finish_eh_generation (); - cleanup_cfg (CLEANUP_NO_INSN_DEL); - return 0; -} - -struct rtl_opt_pass pass_rtl_eh = -{ - { - RTL_PASS, - "rtl_eh", /* name */ - gate_handle_eh, /* gate */ - rest_of_handle_eh, /* execute */ - NULL, /* sub */ - NULL, /* next */ - 0, /* static_pass_number */ - TV_JUMP, /* tv_id */ - 0, /* properties_required */ - 0, /* properties_provided */ - 0, /* properties_destroyed */ - 0, /* todo_flags_start */ - 0 /* todo_flags_finish */ - } -}; /* This section handles removing dead code for flow. */ Index: gcc/except.h =================================================================== --- gcc/except.h.orig 2011-07-25 10:50:26.000000000 +0200 +++ gcc/except.h 2012-03-19 16:24:58.000000000 +0100 @@ -291,6 +291,8 @@ extern void assign_filter_values (void); extern eh_region get_eh_region_from_rtx (const_rtx); extern eh_landing_pad get_eh_landing_pad_from_rtx (const_rtx); +extern void finish_eh_generation (void); + struct GTY(()) throw_stmt_node { gimple stmt; int lp_nr; Index: gcc/passes.c =================================================================== --- gcc/passes.c.orig 2012-03-19 14:52:11.000000000 +0100 +++ gcc/passes.c 2012-03-19 16:27:22.000000000 +0100 @@ -1431,7 +1431,6 @@ init_optimization_passes (void) struct opt_pass **p = &pass_rest_of_compilation.pass.sub; NEXT_PASS (pass_init_function); NEXT_PASS (pass_jump); - NEXT_PASS (pass_rtl_eh); NEXT_PASS (pass_initial_value_sets); NEXT_PASS (pass_unshare_all_rtl); NEXT_PASS (pass_instantiate_virtual_regs);