From patchwork Tue Aug 7 12:09:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 175611 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 756FF2C0090 for ; Tue, 7 Aug 2012 22:09:35 +1000 (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=1344946176; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Date: From:To: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=oFGdwFhStAC3swPUy410 YCMBibI=; b=EfU9UV1Zi6iutGn5GqBGmrce6+Y1IbBp5lDrdDsqQAlj9Hx6LrrC JN8C/7bQnGM0N94z2VnWaz8N2JgL8kKB9vqyydVBAcuTKblqPq1K21QCL6OZTAIv i3WYHcpxjvFvfUZJwZuQ7+OwDH/V04exKPpBWSzYDSKgMhTIiP9Q7wI= 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: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=mj80vhkMwdDaIuunlnNeY/fpyGH2jMsXvguQXK7EJ7X5y2y8xZtw6/+6Fd3itr lbrR2kQwEkjqAA9yvM1Ek/UJxMGLp9/VSeMHmcq7XiCH+MW8IwAMbGCkdrD6Qw2u cmsf3DwbcFIHKCnj23mRRkwZWfUzAiZ9sUTMQ+FBzZIZk=; Received: (qmail 22796 invoked by alias); 7 Aug 2012 12:09:29 -0000 Received: (qmail 22779 invoked by uid 22791); 7 Aug 2012 12:09:24 -0000 X-SWARE-Spam-Status: No, hits=-5.4 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, 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; Tue, 07 Aug 2012 12:09:11 +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 E5373A398E for ; Tue, 7 Aug 2012 14:09:09 +0200 (CEST) Date: Tue, 7 Aug 2012 14:09:09 +0200 (CEST) From: Richard Guenther To: gcc-patches@gcc.gnu.org Subject: [PATCH] Remove clobbers as we go into SSA 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 This makes sure clobbers of SSA names are never retained in the IL. First by verifying that in the gimple verifier, second by removing them when we go into SSA form. Third by catching those we have to get rid of when un-nesting - this avoids stuff like finally { D.1234 = CLOBBER; frame.i = D.1234; } and D.1234 being a candidate for a register. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2012-08-07 Richard Guenther * tree-into-ssa.c (rewrite_stmt): Remove clobbers for variables we rewrite into SSA form. (rewrite_enter_block): Adjust. * gimple-iterator.c (gsi_replace): Also allow replacement with a stmt without a lhs. * tree-ssa-live.c (remove_unused_locals): Remove code handling clobbers of SSA names. * tree-nested.c (convert_local_reference_stmt): Remove clobbers for variables we access through the local chain. * tree-cfg.c (verify_gimple_assign_single): Verify clobbers clobber full decls only. Index: gcc/tree-into-ssa.c =================================================================== --- gcc/tree-into-ssa.c (revision 190199) +++ gcc/tree-into-ssa.c (working copy) @@ -1323,12 +1323,12 @@ rewrite_debug_stmt_uses (gimple stmt) definition of a variable when a new real or virtual definition is found. */ static void -rewrite_stmt (gimple_stmt_iterator si) +rewrite_stmt (gimple_stmt_iterator *si) { use_operand_p use_p; def_operand_p def_p; ssa_op_iter iter; - gimple stmt = gsi_stmt (si); + gimple stmt = gsi_stmt (*si); /* If mark_def_sites decided that we don't need to rewrite this statement, ignore it. */ @@ -1362,9 +1362,24 @@ rewrite_stmt (gimple_stmt_iterator si) FOR_EACH_SSA_DEF_OPERAND (def_p, stmt, iter, SSA_OP_ALL_DEFS) { tree var = DEF_FROM_PTR (def_p); - tree name = make_ssa_name (var, stmt); + tree name; tree tracked_var; + gcc_assert (DECL_P (var)); + + if (gimple_clobber_p (stmt) + && is_gimple_reg (var)) + { + /* If we rewrite a DECL into SSA form then drop its + clobber stmts and replace uses with a new default def. */ + gcc_assert (TREE_CODE (var) == VAR_DECL + && !gimple_vdef (stmt)); + gsi_replace (si, gimple_build_nop (), true); + register_new_def (get_or_create_ssa_default_def (cfun, var), var); + break; + } + + name = make_ssa_name (var, stmt); SET_DEF (def_p, name); register_new_def (DEF_FROM_PTR (def_p), var); @@ -1372,7 +1387,7 @@ rewrite_stmt (gimple_stmt_iterator si) if (tracked_var) { gimple note = gimple_build_debug_bind (tracked_var, name, stmt); - gsi_insert_after (&si, note, GSI_SAME_STMT); + gsi_insert_after (si, note, GSI_SAME_STMT); } } } @@ -1439,7 +1454,7 @@ rewrite_enter_block (struct dom_walk_dat of a variable when a new real or virtual definition is found. */ if (TEST_BIT (interesting_blocks, bb->index)) for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) - rewrite_stmt (gsi); + rewrite_stmt (&gsi); /* Step 3. Visit all the successor blocks of BB looking for PHI nodes. For every PHI node found, add a new argument containing the current Index: gcc/gimple-iterator.c =================================================================== --- gcc/gimple-iterator.c (revision 190198) +++ gcc/gimple-iterator.c (working copy) @@ -427,7 +427,7 @@ gsi_replace (gimple_stmt_iterator *gsi, if (stmt == orig_stmt) return; - gcc_assert (!gimple_has_lhs (orig_stmt) + gcc_assert (!gimple_has_lhs (orig_stmt) || !gimple_has_lhs (stmt) || gimple_get_lhs (orig_stmt) == gimple_get_lhs (stmt)); gimple_set_location (stmt, gimple_location (orig_stmt)); Index: gcc/tree-ssa-live.c =================================================================== --- gcc/tree-ssa-live.c (revision 190198) +++ gcc/tree-ssa-live.c (working copy) @@ -773,9 +773,6 @@ remove_unused_locals (void) if (gimple_clobber_p (stmt)) { tree lhs = gimple_assign_lhs (stmt); - lhs = get_base_address (lhs); - if (TREE_CODE (lhs) == SSA_NAME) - lhs = SSA_NAME_VAR (lhs); if (TREE_CODE (lhs) == VAR_DECL && !is_used_p (lhs)) { unlink_stmt_vdef (stmt); Index: gcc/tree-nested.c =================================================================== --- gcc/tree-nested.c (revision 190198) +++ gcc/tree-nested.c (working copy) @@ -1727,6 +1727,20 @@ convert_local_reference_stmt (gimple_stm *handled_ops_p = false; return NULL_TREE; + case GIMPLE_ASSIGN: + if (gimple_clobber_p (stmt)) + { + tree lhs = gimple_assign_lhs (stmt); + if (!use_pointer_in_frame (lhs) + && lookup_field_for_decl (info, lhs, NO_INSERT)) + { + gsi_replace (gsi, gimple_build_nop (), true); + break; + } + } + *handled_ops_p = false; + return NULL_TREE; + default: /* For every other statement that we are not interested in handling here, let the walker traverse the operands. */ Index: gcc/tree-cfg.c =================================================================== --- gcc/tree-cfg.c (revision 190199) +++ gcc/tree-cfg.c (working copy) @@ -3930,6 +3930,14 @@ verify_gimple_assign_single (gimple stmt return true; } + if (gimple_clobber_p (stmt) + && !DECL_P (lhs)) + { + error ("non-decl LHS in clobber statement"); + debug_generic_expr (lhs); + return true; + } + if (handled_component_p (lhs)) res |= verify_types_in_gimple_reference (lhs, true);