Commit d70ba0c1 by Eric Botcazou Committed by Eric Botcazou

gimplify.c (nonlocal_vlas): Delete.

	* gimplify.c (nonlocal_vlas): Delete.
	(nonlocal_vla_vars): Likewise.
	(gimplify_var_or_parm_decl): Do not add debug VAR_DECLs for non-local
	referenced VLAs.
	(gimplify_body): Do not create and destroy nonlocal_vlas.
	* tree-nested.c: Include diagnostic.h.
	(use_pointer_in_frame): Tweak.
	(lookup_field_for_decl): Add assertion and declare the transformation.
	(convert_nonlocal_reference_op) <PARM_DECL>: Rework and issue an
	internal error when the reference is in a wrong context.  Do not
	create a debug decl by default.
	(note_nonlocal_block_vlas): Delete.
	(convert_nonlocal_reference_stmt) <GIMPLE_BIND>: Do not call it.
	(convert_local_reference_op) <PARM_DECL>: Skip the frame decl.  Do not
	create a debug decl by default.
	(convert_gimple_call) <GIMPLE_CALL>: Issue an internal error when the
	call is in a wrong context.
	(fixup_vla_decls): New function.
	(finalize_nesting_tree_1): Adjust comment.  Call fixup_vla_decls if no
	debug variables were created.
	* tree.c (decl_value_expr_lookup): Add checking assertion.
	(decl_value_expr_insert): Likewise.
fortran/
	* fortran/trans-decl.c (nonlocal_dummy_decl_pset): Delete.
	(nonlocal_dummy_decls): Likewise.
	(gfc_nonlocal_dummy_array_decl): Likewise.
	(gfc_get_symbol_decl): Do not call gfc_nonlocal_dummy_array_decl.
	(gfc_get_fake_result_decl): Do not generate a new DECL if simply
	reusing the result of a recursive call.
	(gfc_generate_function_code): Do not create, insert and destroy
	nonlocal_dummy_decls.

From-SVN: r261687
parent f6a4a25f
2018-06-17 Eric Botcazou <ebotcazou@adacore.com>
* gimplify.c (nonlocal_vlas): Delete.
(nonlocal_vla_vars): Likewise.
(gimplify_var_or_parm_decl): Do not add debug VAR_DECLs for non-local
referenced VLAs.
(gimplify_body): Do not create and destroy nonlocal_vlas.
* tree-nested.c: Include diagnostic.h.
(use_pointer_in_frame): Tweak.
(lookup_field_for_decl): Add assertion and declare the transformation.
(convert_nonlocal_reference_op) <PARM_DECL>: Rework and issue an
internal error when the reference is in a wrong context. Do not
create a debug decl by default.
(note_nonlocal_block_vlas): Delete.
(convert_nonlocal_reference_stmt) <GIMPLE_BIND>: Do not call it.
(convert_local_reference_op) <PARM_DECL>: Skip the frame decl. Do not
create a debug decl by default.
(convert_gimple_call) <GIMPLE_CALL>: Issue an internal error when the
call is in a wrong context.
(fixup_vla_decls): New function.
(finalize_nesting_tree_1): Adjust comment. Call fixup_vla_decls if no
debug variables were created.
* tree.c (decl_value_expr_lookup): Add checking assertion.
(decl_value_expr_insert): Likewise.
2018-06-16 Kugan Vivekanandarajah <kuganv@linaro.org>
PR middle-end/82479
......
2018-06-17 Eric Botcazou <ebotcazou@adacore.com>
* fortran/trans-decl.c (nonlocal_dummy_decl_pset): Delete.
(nonlocal_dummy_decls): Likewise.
(gfc_nonlocal_dummy_array_decl): Likewise.
(gfc_get_symbol_decl): Do not call gfc_nonlocal_dummy_array_decl.
(gfc_get_fake_result_decl): Do not generate a new DECL if simply
reusing the result of a recursive call.
(gfc_generate_function_code): Do not create, insert and destroy
nonlocal_dummy_decls.
2018-06-13 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/86110
......
......@@ -61,9 +61,6 @@ static GTY(()) tree parent_fake_result_decl;
static GTY(()) tree saved_function_decls;
static GTY(()) tree saved_parent_function_decls;
static hash_set<tree> *nonlocal_dummy_decl_pset;
static GTY(()) tree nonlocal_dummy_decls;
/* Holds the variable DECLs that are locals. */
static GTY(()) tree saved_local_decls;
......@@ -1284,39 +1281,6 @@ gfc_build_dummy_array_decl (gfc_symbol * sym, tree dummy)
return decl;
}
/* For symbol SYM with GFC_DECL_SAVED_DESCRIPTOR used in contained
function add a VAR_DECL to the current function with DECL_VALUE_EXPR
pointing to the artificial variable for debug info purposes. */
static void
gfc_nonlocal_dummy_array_decl (gfc_symbol *sym)
{
tree decl, dummy;
if (! nonlocal_dummy_decl_pset)
nonlocal_dummy_decl_pset = new hash_set<tree>;
if (nonlocal_dummy_decl_pset->add (sym->backend_decl))
return;
dummy = GFC_DECL_SAVED_DESCRIPTOR (sym->backend_decl);
decl = build_decl (input_location, VAR_DECL, DECL_NAME (dummy),
TREE_TYPE (sym->backend_decl));
DECL_ARTIFICIAL (decl) = 0;
TREE_USED (decl) = 1;
TREE_PUBLIC (decl) = 0;
TREE_STATIC (decl) = 0;
DECL_EXTERNAL (decl) = 0;
if (DECL_BY_REFERENCE (dummy))
DECL_BY_REFERENCE (decl) = 1;
DECL_LANG_SPECIFIC (decl) = DECL_LANG_SPECIFIC (sym->backend_decl);
SET_DECL_VALUE_EXPR (decl, sym->backend_decl);
DECL_HAS_VALUE_EXPR_P (decl) = 1;
DECL_CONTEXT (decl) = DECL_CONTEXT (sym->backend_decl);
DECL_CHAIN (decl) = nonlocal_dummy_decls;
nonlocal_dummy_decls = decl;
}
/* Return a constant or a variable to use as a string length. Does not
add the decl to the current scope. */
......@@ -1643,12 +1607,6 @@ gfc_get_symbol_decl (gfc_symbol * sym)
gfc_add_assign_aux_vars (sym);
}
if ((sym->attr.dimension || IS_CLASS_ARRAY (sym))
&& DECL_LANG_SPECIFIC (sym->backend_decl)
&& GFC_DECL_SAVED_DESCRIPTOR (sym->backend_decl)
&& DECL_CONTEXT (sym->backend_decl) != current_function_decl)
gfc_nonlocal_dummy_array_decl (sym);
if (sym->ts.type == BT_CLASS && sym->backend_decl)
GFC_DECL_CLASS(sym->backend_decl) = 1;
......@@ -2950,13 +2908,14 @@ gfc_get_fake_result_decl (gfc_symbol * sym, int parent_flag)
&& sym->ns->proc_name->attr.entry_master
&& sym != sym->ns->proc_name)
{
tree t = NULL, var;
tree t = NULL, var, field;
if (this_fake_result_decl != NULL)
for (t = TREE_CHAIN (this_fake_result_decl); t; t = TREE_CHAIN (t))
if (strcmp (IDENTIFIER_POINTER (TREE_PURPOSE (t)), sym->name) == 0)
break;
if (t)
return TREE_VALUE (t);
decl = gfc_get_fake_result_decl (sym->ns->proc_name, parent_flag);
if (parent_flag)
......@@ -2964,20 +2923,17 @@ gfc_get_fake_result_decl (gfc_symbol * sym, int parent_flag)
else
this_fake_result_decl = current_fake_result_decl;
if (decl && sym->ns->proc_name->attr.mixed_entry_master)
{
tree field;
if (!sym->ns->proc_name->attr.mixed_entry_master)
return decl;
for (field = TYPE_FIELDS (TREE_TYPE (decl));
field; field = DECL_CHAIN (field))
if (strcmp (IDENTIFIER_POINTER (DECL_NAME (field)),
sym->name) == 0)
break;
for (field = TYPE_FIELDS (TREE_TYPE (decl));
field; field = DECL_CHAIN (field))
if (strcmp (IDENTIFIER_POINTER (DECL_NAME (field)), sym->name) == 0)
break;
gcc_assert (field != NULL_TREE);
decl = fold_build3_loc (input_location, COMPONENT_REF,
TREE_TYPE (field), decl, field, NULL_TREE);
}
gcc_assert (field != NULL_TREE);
decl = fold_build3_loc (input_location, COMPONENT_REF,
TREE_TYPE (field), decl, field, NULL_TREE);
var = create_tmp_var_raw (TREE_TYPE (decl), sym->name);
if (parent_flag)
......@@ -6442,9 +6398,6 @@ gfc_generate_function_code (gfc_namespace * ns)
gfc_generate_contained_functions (ns);
nonlocal_dummy_decls = NULL;
nonlocal_dummy_decl_pset = NULL;
has_coarray_vars = false;
generate_local_vars (ns);
......@@ -6644,15 +6597,6 @@ gfc_generate_function_code (gfc_namespace * ns)
= build3_v (BIND_EXPR, decl, DECL_SAVED_TREE (fndecl),
DECL_INITIAL (fndecl));
if (nonlocal_dummy_decls)
{
BLOCK_VARS (DECL_INITIAL (fndecl))
= chainon (BLOCK_VARS (DECL_INITIAL (fndecl)), nonlocal_dummy_decls);
delete nonlocal_dummy_decl_pset;
nonlocal_dummy_decls = NULL;
nonlocal_dummy_decl_pset = NULL;
}
/* Output the GENERIC tree. */
dump_function (TDI_original, fndecl);
......
......@@ -2674,12 +2674,6 @@ gimplify_conversion (tree *expr_p)
return GS_OK;
}
/* Nonlocal VLAs seen in the current function. */
static hash_set<tree> *nonlocal_vlas;
/* The VAR_DECLs created for nonlocal VLAs for debug info purposes. */
static tree nonlocal_vla_vars;
/* Gimplify a VAR_DECL or PARM_DECL. Return GS_OK if we expanded a
DECL_VALUE_EXPR, and it's worth re-examining things. */
......@@ -2710,38 +2704,7 @@ gimplify_var_or_parm_decl (tree *expr_p)
/* If the decl is an alias for another expression, substitute it now. */
if (DECL_HAS_VALUE_EXPR_P (decl))
{
tree value_expr = DECL_VALUE_EXPR (decl);
/* For referenced nonlocal VLAs add a decl for debugging purposes
to the current function. */
if (VAR_P (decl)
&& TREE_CODE (DECL_SIZE_UNIT (decl)) != INTEGER_CST
&& nonlocal_vlas != NULL
&& TREE_CODE (value_expr) == INDIRECT_REF
&& TREE_CODE (TREE_OPERAND (value_expr, 0)) == VAR_DECL
&& decl_function_context (decl) != current_function_decl)
{
struct gimplify_omp_ctx *ctx = gimplify_omp_ctxp;
while (ctx
&& (ctx->region_type == ORT_WORKSHARE
|| ctx->region_type == ORT_SIMD
|| ctx->region_type == ORT_ACC))
ctx = ctx->outer_context;
if (!ctx && !nonlocal_vlas->add (decl))
{
tree copy = copy_node (decl);
lang_hooks.dup_lang_specific_decl (copy);
SET_DECL_RTL (copy, 0);
TREE_USED (copy) = 1;
DECL_CHAIN (copy) = nonlocal_vla_vars;
nonlocal_vla_vars = copy;
SET_DECL_VALUE_EXPR (copy, unshare_expr (value_expr));
DECL_HAS_VALUE_EXPR_P (copy) = 1;
}
}
*expr_p = unshare_expr (value_expr);
*expr_p = unshare_expr (DECL_VALUE_EXPR (decl));
return GS_OK;
}
......@@ -12591,7 +12554,6 @@ gimplify_body (tree fndecl, bool do_parms)
gimple_seq parm_stmts, parm_cleanup = NULL, seq;
gimple *outer_stmt;
gbind *outer_bind;
struct cgraph_node *cgn;
timevar_push (TV_TREE_GIMPLIFY);
......@@ -12618,10 +12580,6 @@ gimplify_body (tree fndecl, bool do_parms)
unshare_body (fndecl);
unvisit_body (fndecl);
cgn = cgraph_node::get (fndecl);
if (cgn && cgn->origin)
nonlocal_vlas = new hash_set<tree>;
/* Make sure input_location isn't set to something weird. */
input_location = DECL_SOURCE_LOCATION (fndecl);
......@@ -12674,27 +12632,6 @@ gimplify_body (tree fndecl, bool do_parms)
}
}
if (nonlocal_vlas)
{
if (nonlocal_vla_vars)
{
/* tree-nested.c may later on call declare_vars (..., true);
which relies on BLOCK_VARS chain to be the tail of the
gimple_bind_vars chain. Ensure we don't violate that
assumption. */
if (gimple_bind_block (outer_bind)
== DECL_INITIAL (current_function_decl))
declare_vars (nonlocal_vla_vars, outer_bind, true);
else
BLOCK_VARS (DECL_INITIAL (current_function_decl))
= chainon (BLOCK_VARS (DECL_INITIAL (current_function_decl)),
nonlocal_vla_vars);
nonlocal_vla_vars = NULL_TREE;
}
delete nonlocal_vlas;
nonlocal_vlas = NULL;
}
if ((flag_openacc || flag_openmp || flag_openmp_simd)
&& gimplify_omp_ctxp)
{
......
2018-06-17 Eric Botcazou <ebotcazou@adacore.com>
* gcc.dg/debug/dwarf2/pr37726.c: Move to...
* gcc.dg/guality/pr37726.c: ...here and turn into GDB test.
* gnat.dg/stack_usage5.adb: New test.
2018-06-16 Kugan Vivekanandarajah <kuganv@linaro.org>
PR middle-end/82479
......
/* PR debug/37726 */
/* { dg-do compile } */
/* { dg-options "-gdwarf -O0 -dA -fno-merge-debug-strings" } */
/* { dg-do run } */
/* { dg-options "-g" } */
/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */
int foo (int parm)
{
int var = 0;
int bar (void)
{
return parm + var;
return parm + var; /* BREAK */
}
parm++;
parm++; /* BREAK */
var++;
return bar ();
}
......@@ -20,6 +21,7 @@ main (void)
return foo (4) - 6;
}
/* Both parm and var variables should be in debug info for both foo and bar. */
/* { dg-final { scan-assembler-times "\"parm\[^\n\]*\"\[^\n\]*DW_AT_name" 2 } } */
/* { dg-final { scan-assembler-times "\"var\[^\n\]*\"\[^\n\]*DW_AT_name" 2 } } */
/* { dg-final { gdb-test 11 "parm" "5" } } */
/* { dg-final { gdb-test 11 "var" "1" } } */
/* { dg-final { gdb-test 13 "parm" "4" } } */
/* { dg-final { gdb-test 13 "var" "0" } } */
-- { dg-do compile }
-- { dg-options "-Wstack-usage=512" }
procedure Stack_Usage5 (C : Character) is
S : String (1 .. 300);
procedure Set is
begin
S (1) := C;
end;
begin
Set;
end;
......@@ -6337,7 +6337,15 @@ decl_value_expr_lookup (tree from)
h = value_expr_for_decl->find_with_hash (&in, DECL_UID (from));
if (h)
return h->to;
{
/* Chains of value expressions may run afoul of garbage collection. */
gcc_checking_assert (!(h->to
&& (TREE_CODE (h->to) == PARM_DECL
|| TREE_CODE (h->to) == VAR_DECL)
&& DECL_HAS_VALUE_EXPR_P (h->to)));
return h->to;
}
return NULL_TREE;
}
......@@ -6348,6 +6356,12 @@ decl_value_expr_insert (tree from, tree to)
{
struct tree_decl_map *h;
/* Chains of value expressions may run afoul of garbage collection. */
gcc_checking_assert (!(to
&& (TREE_CODE (to) == PARM_DECL
|| TREE_CODE (to) == VAR_DECL)
&& DECL_HAS_VALUE_EXPR_P (to)));
h = ggc_alloc<tree_decl_map> ();
h->base.from = from;
h->to = to;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment