/* Nested function decomposition for GIMPLE.
- Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
This file is part of GCC.
Note also that it's represented as a parameter. This is more
close to the truth, since the initial value does come from
the caller. */
- decl = build_decl (PARM_DECL, create_tmp_var_name ("CHAIN"), type);
+ decl = build_decl (DECL_SOURCE_LOCATION (info->context),
+ PARM_DECL, create_tmp_var_name ("CHAIN"), type);
DECL_ARTIFICIAL (decl) = 1;
DECL_IGNORED_P (decl) = 1;
TREE_USED (decl) = 1;
static GTY(()) tree trampoline_type;
static tree
-get_trampoline_type (void)
+get_trampoline_type (struct nesting_info *info)
{
unsigned align, size;
tree t;
t = build_index_type (build_int_cst (NULL_TREE, size - 1));
t = build_array_type (char_type_node, t);
- t = build_decl (FIELD_DECL, get_identifier ("__data"), t);
+ t = build_decl (DECL_SOURCE_LOCATION (info->context),
+ FIELD_DECL, get_identifier ("__data"), t);
DECL_ALIGN (t) = align;
DECL_USER_ALIGN (t) = 1;
{
tree field = make_node (FIELD_DECL);
DECL_NAME (field) = DECL_NAME (decl);
- TREE_TYPE (field) = get_trampoline_type ();
+ TREE_TYPE (field) = get_trampoline_type (info);
TREE_ADDRESSABLE (field) = 1;
insert_field_into_struct (get_frame_type (info), field);
x = build1 (INDIRECT_REF, TREE_TYPE (TREE_TYPE (x)), x);
/* ??? We should be remapping types as well, surely. */
- new_decl = build_decl (VAR_DECL, DECL_NAME (decl), TREE_TYPE (decl));
+ new_decl = build_decl (DECL_SOURCE_LOCATION (decl),
+ VAR_DECL, DECL_NAME (decl), TREE_TYPE (decl));
DECL_CONTEXT (new_decl) = info->context;
- DECL_SOURCE_LOCATION (new_decl) = DECL_SOURCE_LOCATION (decl);
DECL_ARTIFICIAL (new_decl) = DECL_ARTIFICIAL (decl);
DECL_IGNORED_P (new_decl) = DECL_IGNORED_P (decl);
TREE_THIS_VOLATILE (new_decl) = TREE_THIS_VOLATILE (decl);
{
tree c, decl;
decl = get_chain_decl (info);
- c = build_omp_clause (OMP_CLAUSE_FIRSTPRIVATE);
+ c = build_omp_clause (gimple_location (stmt),
+ OMP_CLAUSE_FIRSTPRIVATE);
OMP_CLAUSE_DECL (c) = decl;
OMP_CLAUSE_CHAIN (c) = gimple_omp_taskreg_clauses (stmt);
gimple_omp_taskreg_set_clauses (stmt, c);
x = info->frame_decl;
x = build3 (COMPONENT_REF, TREE_TYPE (field), x, field, NULL_TREE);
- new_decl = build_decl (VAR_DECL, DECL_NAME (decl), TREE_TYPE (decl));
+ new_decl = build_decl (DECL_SOURCE_LOCATION (decl),
+ VAR_DECL, DECL_NAME (decl), TREE_TYPE (decl));
DECL_CONTEXT (new_decl) = info->context;
- DECL_SOURCE_LOCATION (new_decl) = DECL_SOURCE_LOCATION (decl);
DECL_ARTIFICIAL (new_decl) = DECL_ARTIFICIAL (decl);
DECL_IGNORED_P (new_decl) = DECL_IGNORED_P (decl);
TREE_THIS_VOLATILE (new_decl) = TREE_THIS_VOLATILE (decl);
{
tree c;
(void) get_frame_type (info);
- c = build_omp_clause (OMP_CLAUSE_SHARED);
+ c = build_omp_clause (gimple_location (stmt),
+ OMP_CLAUSE_SHARED);
OMP_CLAUSE_DECL (c) = info->frame_decl;
OMP_CLAUSE_CHAIN (c) = gimple_omp_taskreg_clauses (stmt);
gimple_omp_taskreg_set_clauses (stmt, c);
slot = pointer_map_insert (i->var_map, label);
if (*slot == NULL)
{
- new_label = create_artificial_label ();
+ new_label = create_artificial_label (UNKNOWN_LOCATION);
DECL_NONLOCAL (new_label) = 1;
*slot = new_label;
}
break;
if (c == NULL)
{
- c = build_omp_clause (i ? OMP_CLAUSE_FIRSTPRIVATE
- : OMP_CLAUSE_SHARED);
+ c = build_omp_clause (gimple_location (stmt),
+ i ? OMP_CLAUSE_FIRSTPRIVATE
+ : OMP_CLAUSE_SHARED);
OMP_CLAUSE_DECL (c) = decl;
OMP_CLAUSE_CHAIN (c) = gimple_omp_taskreg_clauses (stmt);
gimple_omp_taskreg_set_clauses (stmt, c);
/* In some cases the frame type will trigger the -Wpadded warning.
This is not helpful; suppress it. */
int save_warn_padded = warn_padded;
+ tree *adjust;
+
warn_padded = 0;
layout_type (root->frame_type);
warn_padded = save_warn_padded;
layout_decl (root->frame_decl, 0);
+
+ /* Remove root->frame_decl from root->new_local_var_chain, so
+ that we can declare it also in the lexical blocks, which
+ helps ensure virtual regs that end up appearing in its RTL
+ expression get substituted in instantiate_virtual_regs(). */
+ for (adjust = &root->new_local_var_chain;
+ *adjust != root->frame_decl;
+ adjust = &TREE_CHAIN (*adjust))
+ gcc_assert (TREE_CHAIN (*adjust));
+ *adjust = TREE_CHAIN (*adjust);
+
+ TREE_CHAIN (root->frame_decl) = NULL_TREE;
+ declare_vars (root->frame_decl,
+ gimple_seq_first_stmt (gimple_body (context)), true);
}
/* If any parameters were referenced non-locally, then we need to
while (root);
}
+/* Gimplify a function and all its nested functions. */
+static void
+gimplify_all_functions (struct cgraph_node *root)
+{
+ struct cgraph_node *iter;
+ if (!gimple_body (root->decl))
+ gimplify_function_tree (root->decl);
+ for (iter = root->nested; iter; iter = iter->next_nested)
+ gimplify_all_functions (iter);
+}
+
/* Main entry point for this pass. Process FNDECL and all of its nested
subroutines and turn them into something less tightly bound. */
if (!cgn->nested)
return;
+ gimplify_all_functions (cgn);
+
bitmap_obstack_initialize (&nesting_info_bitmap_obstack);
root = create_nesting_tree (cgn);
walk_all_functions (convert_nonlocal_reference_stmt,