From dc16b00717f72aae2d93865a8007ff220b6f022f Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 28 Sep 2018 11:33:29 +0000 Subject: [PATCH] tree.h (BLOCK_ORIGIN): New. 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. From-SVN: r264689 --- gcc/ChangeLog | 17 +++++++++++++++++ gcc/auto-profile.c | 11 ++--------- gcc/cp/ChangeLog | 5 +++++ gcc/cp/error.c | 10 ---------- gcc/langhooks.c | 10 ---------- gcc/omp-expand.c | 2 +- gcc/optinfo-emit-json.cc | 6 ------ gcc/tree-inline.c | 2 +- gcc/tree-pretty-print.c | 24 ------------------------ gcc/tree-ssa-live.c | 7 +------ gcc/tree.c | 17 +---------------- gcc/tree.h | 2 ++ 12 files changed, 30 insertions(+), 83 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5b685e42433..7c5e78b61fc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,20 @@ +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. + 2018-09-28 Andrew Stubbs Jan Hubicka Martin Jambor diff --git a/gcc/auto-profile.c b/gcc/auto-profile.c index 68abe327cce..f7ba32c30ac 100644 --- a/gcc/auto-profile.c +++ b/gcc/auto-profile.c @@ -354,17 +354,10 @@ get_combined_location (location_t loc, tree decl) 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. */ diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a28b6150d8f..f5d602de026 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2018-09-28 Richard Biener + + * error.c (cp_print_error_function): Simplify by eliding + the BLOCK_ABSTRACT_ORIGIN chasing. + 2018-09-27 Paolo Carlini PR c++/84940 diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 601f6d2c264..0b14dccba3a 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -3339,10 +3339,6 @@ cp_print_error_function (diagnostic_context *context, 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_context *context, && 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; diff --git a/gcc/langhooks.c b/gcc/langhooks.c index 4e6179f248a..9d7c2d3425d 100644 --- a/gcc/langhooks.c +++ b/gcc/langhooks.c @@ -385,10 +385,6 @@ lhd_print_error_function (diagnostic_context *context, const char *file, 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_context *context, const char *file, && 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; diff --git a/gcc/omp-expand.c b/gcc/omp-expand.c index d2a77c067c6..e8abde413db 100644 --- a/gcc/omp-expand.c +++ b/gcc/omp-expand.c @@ -7629,7 +7629,7 @@ grid_expand_target_grid_body (struct omp_region *target) 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; diff --git a/gcc/optinfo-emit-json.cc b/gcc/optinfo-emit-json.cc index 992960ec8d2..efdbdb3ae01 100644 --- a/gcc/optinfo-emit-json.cc +++ b/gcc/optinfo-emit-json.cc @@ -299,12 +299,6 @@ optrecord_json_writer::inlining_chain_to_json (location_t loc) && 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; diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index b2cddc22312..42c33d23b9b 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -704,7 +704,7 @@ remap_block (tree *block, copy_body_data *id) 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)); diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c index 2c089b11751..75b939a9418 100644 --- a/gcc/tree-pretty-print.c +++ b/gcc/tree-pretty-print.c @@ -3976,35 +3976,11 @@ percent_K_format (text_info *text, location_t loc, tree block) 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; diff --git a/gcc/tree-ssa-live.c b/gcc/tree-ssa-live.c index 2623d9b2b00..eee21a63bd7 100644 --- a/gcc/tree-ssa-live.c +++ b/gcc/tree-ssa-live.c @@ -561,12 +561,7 @@ remove_unused_scope_block_p (tree scope, bool in_ctor_dtor_block) 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) diff --git a/gcc/tree.c b/gcc/tree.c index 64d9e0bfe81..2bd209b5648 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -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. diff --git a/gcc/tree.h b/gcc/tree.h index dcf8253c3bc..35536f372a3 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -1789,6 +1789,8 @@ extern tree maybe_wrap_with_location (tree, location_t); #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) -- 2.30.2