From patchwork Fri Sep 28 08:52:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 976091 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-486609-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="ln201RZm"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42M56D5Qdhz9s3x for ; Fri, 28 Sep 2018 18:52:36 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=bcdBM5+UMzy0flV1gqevoq2b0WHke2H3SItBBCwMAO2TKneuHox9q as/JFYsA5qHAF7NBZ9jftZ0XO6cXjNC1eM6XpFvmxb64kbJK+/PjX8Jiu4myv4H6 G7nMQYlD+7lON9CO+vhzNVDmaSJvGlmc39+r0z4GykSSoSNqyEKsYs= 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 :from:to:subject:message-id:mime-version:content-type; s= default; bh=RtTTnuzFn62p3iQA1lB0S/dXPBY=; b=ln201RZmjNkU7SZbJUgV w0MsolS8LxbwxqalBaWpcEN9ssPeIrz/FACvTiAAY6+HEiBKChDaNWhGZOd0p89E HvKzXzEB8/stk0H5O0n1b46/FK8vg4uc35l8UYvat+WWzPlUqOlTmciaA6NnXEOR tQL2kg7OtqNdz0ZCC1fTC2Q= Received: (qmail 93802 invoked by alias); 28 Sep 2018 08:52:29 -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 93426 invoked by uid 89); 28 Sep 2018 08:52:28 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_PASS autolearn=ham version=3.3.2 spammy=blockchain, representing, locat, remap_block X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 28 Sep 2018 08:52:26 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 12DC0B054 for ; Fri, 28 Sep 2018 08:52:24 +0000 (UTC) Date: Fri, 28 Sep 2018 10:52:22 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH][1/n] Make BLOCK_ABSTRACT_ORIGIN "ultimate" Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 The following is step number one to make BLOCK_ABSTRACT_ORIGIN behave similar to DECL_ABSTRACT_ORIGIN, namely point to the ultimate origin. I've audited all uses and they all are interested in the ultimate origin only (well, most do not bother to look at DECL_ORIGIN of the FUNCTION_DECL they eventually run into). Bootstrap and regtest is in progress on x86_64-unknown-linux-gnu, if you have any objection speak up quickly ;) Further experiment will see whether I can make it really ultimate (it's a single place where for the inline BLOCK we have to assign DECL_ORIGIN (fn) instead of fn). Richard. 2018-09-28 Richard Biener * tree.h (BLOCK_ORIGIN): New. * omp-expand.c (grid_expand_target_grid_body): Assign BLOCK_ORIGIN to BLOCK_ABSTRACT_ORIGIN. * tree-inline.c (remap_block): Likewise. * auto-profile.c (get_function_decl_from_block): Simplify by eliding the BLOCK_ABSTRACT_ORIGIN chasing. * langhooks.c (lhd_print_error_function): Likewise. * optinfo-emit-json.cc (optrecord_json_writer::inlining_chain_to): Likewise. * tree-ssa-live.c (remove_unused_scope_block_p): Likewise. * tree.c (block_nonartificial_location): Likewise. (block_ultimate_origin): Likewise. * tree-pretty-print.c (percent_K_format): Likewise. Remove no longer needed LTO case. cp/ * error.c (cp_print_error_function): Simplify by eliding the BLOCK_ABSTRACT_ORIGIN chasing. Index: gcc/auto-profile.c =================================================================== --- gcc/auto-profile.c (revision 264686) +++ gcc/auto-profile.c (working copy) @@ -354,17 +354,10 @@ get_combined_location (location_t loc, t static tree get_function_decl_from_block (tree block) { - tree decl; - - if (LOCATION_LOCUS (BLOCK_SOURCE_LOCATION (block)) == UNKNOWN_LOCATION) + if (!inlined_function_outer_scope_p (block)) return NULL_TREE; - for (decl = BLOCK_ABSTRACT_ORIGIN (block); - decl && (TREE_CODE (decl) == BLOCK); - decl = BLOCK_ABSTRACT_ORIGIN (decl)) - if (TREE_CODE (decl) == FUNCTION_DECL) - break; - return decl; + return BLOCK_ABSTRACT_ORIGIN (block); } /* Store inline stack for STMT in STACK. */ Index: gcc/cp/error.c =================================================================== --- gcc/cp/error.c (revision 264686) +++ gcc/cp/error.c (working copy) @@ -3339,10 +3339,6 @@ cp_print_error_function (diagnostic_cont if (abstract_origin) { ao = BLOCK_ABSTRACT_ORIGIN (abstract_origin); - while (TREE_CODE (ao) == BLOCK - && BLOCK_ABSTRACT_ORIGIN (ao) - && BLOCK_ABSTRACT_ORIGIN (ao) != ao) - ao = BLOCK_ABSTRACT_ORIGIN (ao); gcc_assert (TREE_CODE (ao) == FUNCTION_DECL); fndecl = ao; } @@ -3364,12 +3360,6 @@ cp_print_error_function (diagnostic_cont && BLOCK_ABSTRACT_ORIGIN (block)) { ao = BLOCK_ABSTRACT_ORIGIN (block); - - while (TREE_CODE (ao) == BLOCK - && BLOCK_ABSTRACT_ORIGIN (ao) - && BLOCK_ABSTRACT_ORIGIN (ao) != ao) - ao = BLOCK_ABSTRACT_ORIGIN (ao); - if (TREE_CODE (ao) == FUNCTION_DECL) { fndecl = ao; Index: gcc/langhooks.c =================================================================== --- gcc/langhooks.c (revision 264686) +++ gcc/langhooks.c (working copy) @@ -385,10 +385,6 @@ lhd_print_error_function (diagnostic_con if (abstract_origin) { ao = BLOCK_ABSTRACT_ORIGIN (abstract_origin); - while (TREE_CODE (ao) == BLOCK - && BLOCK_ABSTRACT_ORIGIN (ao) - && BLOCK_ABSTRACT_ORIGIN (ao) != ao) - ao = BLOCK_ABSTRACT_ORIGIN (ao); gcc_assert (TREE_CODE (ao) == FUNCTION_DECL); fndecl = ao; } @@ -416,12 +412,6 @@ lhd_print_error_function (diagnostic_con && BLOCK_ABSTRACT_ORIGIN (block)) { ao = BLOCK_ABSTRACT_ORIGIN (block); - - while (TREE_CODE (ao) == BLOCK - && BLOCK_ABSTRACT_ORIGIN (ao) - && BLOCK_ABSTRACT_ORIGIN (ao) != ao) - ao = BLOCK_ABSTRACT_ORIGIN (ao); - if (TREE_CODE (ao) == FUNCTION_DECL) { fndecl = ao; Index: gcc/omp-expand.c =================================================================== --- gcc/omp-expand.c (revision 264686) +++ gcc/omp-expand.c (working copy) @@ -7629,7 +7629,7 @@ grid_expand_target_grid_body (struct omp SET_DECL_ASSEMBLER_NAME (kern_fndecl, DECL_NAME (kern_fndecl)); tree tgtblock = gimple_block (tgt_stmt); tree fniniblock = make_node (BLOCK); - BLOCK_ABSTRACT_ORIGIN (fniniblock) = tgtblock; + BLOCK_ABSTRACT_ORIGIN (fniniblock) = BLOCK_ORIGIN (tgtblock); BLOCK_SOURCE_LOCATION (fniniblock) = BLOCK_SOURCE_LOCATION (tgtblock); BLOCK_SOURCE_END_LOCATION (fniniblock) = BLOCK_SOURCE_END_LOCATION (tgtblock); BLOCK_SUPERCONTEXT (fniniblock) = kern_fndecl; Index: gcc/optinfo-emit-json.cc =================================================================== --- gcc/optinfo-emit-json.cc (revision 264686) +++ gcc/optinfo-emit-json.cc (working copy) @@ -299,12 +299,6 @@ optrecord_json_writer::inlining_chain_to && BLOCK_ABSTRACT_ORIGIN (block)) { tree ao = BLOCK_ABSTRACT_ORIGIN (block); - - while (TREE_CODE (ao) == BLOCK - && BLOCK_ABSTRACT_ORIGIN (ao) - && BLOCK_ABSTRACT_ORIGIN (ao) != ao) - ao = BLOCK_ABSTRACT_ORIGIN (ao); - if (TREE_CODE (ao) == FUNCTION_DECL) { fndecl = ao; Index: gcc/tree-inline.c =================================================================== --- gcc/tree-inline.c (revision 264686) +++ gcc/tree-inline.c (working copy) @@ -704,7 +704,7 @@ remap_block (tree *block, copy_body_data old_block = *block; new_block = make_node (BLOCK); TREE_USED (new_block) = TREE_USED (old_block); - BLOCK_ABSTRACT_ORIGIN (new_block) = old_block; + BLOCK_ABSTRACT_ORIGIN (new_block) = BLOCK_ORIGIN (old_block); BLOCK_SOURCE_LOCATION (new_block) = BLOCK_SOURCE_LOCATION (old_block); BLOCK_NONLOCALIZED_VARS (new_block) = vec_safe_copy (BLOCK_NONLOCALIZED_VARS (old_block)); Index: gcc/tree-pretty-print.c =================================================================== --- gcc/tree-pretty-print.c (revision 264686) +++ gcc/tree-pretty-print.c (working copy) @@ -3976,35 +3976,11 @@ percent_K_format (text_info *text, locat gcc_assert (pp_ti_abstract_origin (text) != NULL); *pp_ti_abstract_origin (text) = NULL; - if (in_lto_p) - { - /* ??? LTO drops all BLOCK_ABSTRACT_ORIGINs apart from those - representing the outermost block of an inlined function. - So walk the BLOCK tree until we hit such a scope. */ - while (block - && TREE_CODE (block) == BLOCK) - { - if (inlined_function_outer_scope_p (block)) - { - *pp_ti_abstract_origin (text) = block; - break; - } - block = BLOCK_SUPERCONTEXT (block); - } - return; - } - while (block && TREE_CODE (block) == BLOCK && BLOCK_ABSTRACT_ORIGIN (block)) { tree ao = BLOCK_ABSTRACT_ORIGIN (block); - - while (TREE_CODE (ao) == BLOCK - && BLOCK_ABSTRACT_ORIGIN (ao) - && BLOCK_ABSTRACT_ORIGIN (ao) != ao) - ao = BLOCK_ABSTRACT_ORIGIN (ao); - if (TREE_CODE (ao) == FUNCTION_DECL) { *pp_ti_abstract_origin (text) = block; Index: gcc/tree-ssa-live.c =================================================================== --- gcc/tree-ssa-live.c (revision 264686) +++ gcc/tree-ssa-live.c (working copy) @@ -561,12 +561,7 @@ remove_unused_scope_block_p (tree scope, will not be emitted properly. */ if (inlined_function_outer_scope_p (scope)) { - tree ao = scope; - - while (ao - && TREE_CODE (ao) == BLOCK - && BLOCK_ABSTRACT_ORIGIN (ao) != ao) - ao = BLOCK_ABSTRACT_ORIGIN (ao); + tree ao = BLOCK_ORIGIN (scope); if (ao && TREE_CODE (ao) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (ao) Index: gcc/tree.c =================================================================== --- gcc/tree.c (revision 264686) +++ gcc/tree.c (working copy) @@ -11964,12 +11964,6 @@ block_nonartificial_location (tree block && BLOCK_ABSTRACT_ORIGIN (block)) { tree ao = BLOCK_ABSTRACT_ORIGIN (block); - - while (TREE_CODE (ao) == BLOCK - && BLOCK_ABSTRACT_ORIGIN (ao) - && BLOCK_ABSTRACT_ORIGIN (ao) != ao) - ao = BLOCK_ABSTRACT_ORIGIN (ao); - if (TREE_CODE (ao) == FUNCTION_DECL) { /* If AO is an artificial inline, point RET to the @@ -12150,16 +12144,7 @@ block_ultimate_origin (const_tree block) return NULL_TREE; else { - tree ret_val; - tree lookahead = immediate_origin; - - do - { - ret_val = lookahead; - lookahead = (TREE_CODE (ret_val) == BLOCK - ? BLOCK_ABSTRACT_ORIGIN (ret_val) : NULL); - } - while (lookahead != NULL && lookahead != ret_val); + tree ret_val = immediate_origin; /* The block's abstract origin chain may not be the *ultimate* origin of the block. It could lead to a DECL that has an abstract origin set. Index: gcc/tree.h =================================================================== --- gcc/tree.h (revision 264686) +++ gcc/tree.h (working copy) @@ -1789,6 +1789,8 @@ extern tree maybe_wrap_with_location (tr #define BLOCK_SUPERCONTEXT(NODE) (BLOCK_CHECK (NODE)->block.supercontext) #define BLOCK_CHAIN(NODE) (BLOCK_CHECK (NODE)->block.chain) #define BLOCK_ABSTRACT_ORIGIN(NODE) (BLOCK_CHECK (NODE)->block.abstract_origin) +#define BLOCK_ORIGIN(NODE) \ + (BLOCK_ABSTRACT_ORIGIN(NODE) ? BLOCK_ABSTRACT_ORIGIN(NODE) : (NODE)) #define BLOCK_ABSTRACT(NODE) (BLOCK_CHECK (NODE)->block.abstract_flag) #define BLOCK_DIE(NODE) (BLOCK_CHECK (NODE)->block.die)