From patchwork Mon Jan 28 14:15:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 216216 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 0B6522C0084 for ; Tue, 29 Jan 2013 01:16:08 +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=1359987369; 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=KjWt6q3 FD8z0wFq8HXtS8sQa9Ac=; b=wQg3ITn0nH9MzYIjGcRJngZBQIH1m8hN2B91mEU 6tYBWaqj7/sF4nLRd+EI5fZgxMOQzrimXCDUZaMePf85Qn1xVQ+y2dqZK/K+ih37 IZIfDQ5twevQ0mJHoSx/OZkkUmxIYEEtNyZlbOUMQKg0OM3dEastF6SrWCBIpFI/ a58M= 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=CZ2764LUlgo48WTt2rdPjSXKDiCXAI2zjfxtR9gbcgfBGauKqfSnUfZv4hzwWl nKVTlfFkiKbUAqxxbK4fUJxJ7VNGsni4MPOnX95g2q4ThD8A66f9q7REDtDDRCQK xphEe/uekH+xdWozz1qNu4fXc9ZX7qibT81aUAUectkok=; Received: (qmail 8369 invoked by alias); 28 Jan 2013 14:16:02 -0000 Received: (qmail 8350 invoked by uid 22791); 28 Jan 2013 14:16:00 -0000 X-SWARE-Spam-Status: No, hits=-5.6 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, TW_TM 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, 28 Jan 2013 14:15:54 +0000 Received: from relay1.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 38F91A522C; Mon, 28 Jan 2013 15:15:53 +0100 (CET) Date: Mon, 28 Jan 2013 15:15:53 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Cc: Jakub Jelinek Subject: [PATCH][RFC] Avoid excessive BLOCK associations for locations 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 avoids assigning BLOCKs to things that didn't have one before (originally I observed that the code snippets below happily generate a UNKNOWN_LOCATION, id->block association). A previous patch last year changed expansion in a way to not jump back to the outermost block when observing a NULL LOCATION_BLOCK in the IL, but similar to UNKNOWN_LOCATION locus handling just inherit the currently active BLOCK. Thus the patch below, instead of just avoiding the non-sensical UNKNOWN_LOCATION, id->block association goes one step further and never puts things in the outermost inline BLOCK if it didn't have a BLOCK assigned before. This avoids the original non-sensical issue and avoids excessive BLOCK associations where they are of not much use. What's the point of switching to the outermost scope for unknown-BLOCK locations? Isn't inheriting the currently active scope much more useful (it definitely is for UNKNOWN_LOCATIONs)? If we have a non-UNKNOWN_LOCATION, would a NULL BLOCK not be an error anyway? An error we "hide" in the current scheme? Bootstrapped and tested on x86_64-unknown-linux-gnu. Does this make sense? Thanks, Richard. 2013-01-28 Richard Biener * tree-inline.c (remap_gimple_stmt): Do not assing a BLOCK to a stmt that didn't have one. (copy_phis_for_bb): Likewise for PHI arguments. (copy_debug_stmt): Likewise for debug stmts. Index: gcc/tree-inline.c =================================================================== --- gcc/tree-inline.c (revision 195502) +++ gcc/tree-inline.c (working copy) @@ -1198,7 +1198,6 @@ remap_gimple_stmt (gimple stmt, copy_bod { gimple copy = NULL; struct walk_stmt_info wi; - tree new_block; bool skip_first = false; /* Begin by recognizing trees that we'll completely rewrite for the @@ -1458,19 +1457,15 @@ remap_gimple_stmt (gimple stmt, copy_bod } /* If STMT has a block defined, map it to the newly constructed - block. When inlining we want statements without a block to - appear in the block of the function call. */ - new_block = id->block; + block. */ if (gimple_block (copy)) { tree *n; n = (tree *) pointer_map_contains (id->decl_map, gimple_block (copy)); gcc_assert (n); - new_block = *n; + gimple_set_block (copy, *n); } - gimple_set_block (copy, new_block); - if (gimple_debug_bind_p (copy) || gimple_debug_source_bind_p (copy)) return copy; @@ -1987,7 +1982,6 @@ copy_phis_for_bb (basic_block bb, copy_b edge old_edge = find_edge ((basic_block) new_edge->src->aux, bb); tree arg; tree new_arg; - tree block = id->block; edge_iterator ei2; location_t locus; @@ -2015,19 +2009,18 @@ copy_phis_for_bb (basic_block bb, copy_b inserted = true; } locus = gimple_phi_arg_location_from_edge (phi, old_edge); - block = id->block; if (LOCATION_BLOCK (locus)) { tree *n; n = (tree *) pointer_map_contains (id->decl_map, LOCATION_BLOCK (locus)); gcc_assert (n); - block = *n; + locus = COMBINE_LOCATION_DATA (line_table, locus, *n); } + else + locus = LOCATION_LOCUS (locus); - add_phi_arg (new_phi, new_arg, new_edge, block ? - COMBINE_LOCATION_DATA (line_table, locus, block) : - LOCATION_LOCUS (locus)); + add_phi_arg (new_phi, new_arg, new_edge, locus); } } } @@ -2324,14 +2317,11 @@ copy_debug_stmt (gimple stmt, copy_body_ tree t, *n; struct walk_stmt_info wi; - t = id->block; if (gimple_block (stmt)) { n = (tree *) pointer_map_contains (id->decl_map, gimple_block (stmt)); - if (n) - t = *n; + gimple_set_block (stmt, n ? *n : id->block); } - gimple_set_block (stmt, t); /* Remap all the operands in COPY. */ memset (&wi, 0, sizeof (wi));