diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-11-05 22:25:29 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-11-05 22:25:29 +0000 |
commit | 7deddfded2d013c07a639873a4c90bfed40fd03e (patch) | |
tree | 3df2a52207fec5bec55c28303aa57a8bd9b4e620 /gcc/tree-parloops.c | |
parent | c79b54af83c8031caac515081fb7c56a127b90e3 (diff) | |
download | gcc-7deddfded2d013c07a639873a4c90bfed40fd03e.tar.gz |
2010-11-05 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 166377
2010-11-05 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 166377
* gcc/Makefile.in (MELT_RAW_CFLAGS): removed LIBELFINC
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@166380 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-parloops.c')
-rw-r--r-- | gcc/tree-parloops.c | 71 |
1 files changed, 58 insertions, 13 deletions
diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c index de9faefe778..a634b249a61 100644 --- a/gcc/tree-parloops.c +++ b/gcc/tree-parloops.c @@ -314,10 +314,12 @@ loop_has_blocks_with_irreducible_flag (struct loop *loop) /* Assigns the address of OBJ in TYPE to an ssa name, and returns this name. The assignment statement is placed on edge ENTRY. DECL_ADDRESS maps decls to their addresses that can be reused. The address of OBJ is known to - be invariant in the whole function. */ + be invariant in the whole function. Other needed statements are placed + right before GSI. */ static tree -take_address_of (tree obj, tree type, edge entry, htab_t decl_address) +take_address_of (tree obj, tree type, edge entry, htab_t decl_address, + gimple_stmt_iterator *gsi) { int uid; void **dslot; @@ -346,6 +348,8 @@ take_address_of (tree obj, tree type, edge entry, htab_t decl_address) dslot = htab_find_slot_with_hash (decl_address, &ielt, uid, INSERT); if (!*dslot) { + if (gsi == NULL) + return NULL; addr = TREE_OPERAND (*var_p, 0); bvar = create_tmp_var (TREE_TYPE (addr), get_name (TREE_OPERAND @@ -366,17 +370,20 @@ take_address_of (tree obj, tree type, edge entry, htab_t decl_address) /* Express the address in terms of the canonical SSA name. */ TREE_OPERAND (*var_p, 0) = name; + if (gsi == NULL) + return build_fold_addr_expr_with_type (obj, type); + name = force_gimple_operand (build_addr (obj, current_function_decl), &stmts, true, NULL_TREE); if (!gimple_seq_empty_p (stmts)) - gsi_insert_seq_on_edge_immediate (entry, stmts); + gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT); if (!useless_type_conversion_p (type, TREE_TYPE (name))) { name = force_gimple_operand (fold_convert (type, name), &stmts, true, NULL_TREE); if (!gimple_seq_empty_p (stmts)) - gsi_insert_seq_on_edge_immediate (entry, stmts); + gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT); } return name; @@ -438,7 +445,9 @@ struct elv_data struct walk_stmt_info info; edge entry; htab_t decl_address; + gimple_stmt_iterator *gsi; bool changed; + bool reset; }; /* Eliminates references to local variables in *TP out of the single @@ -462,7 +471,14 @@ eliminate_local_variables_1 (tree *tp, int *walk_subtrees, void *data) type = TREE_TYPE (t); addr_type = build_pointer_type (type); - addr = take_address_of (t, addr_type, dta->entry, dta->decl_address); + addr = take_address_of (t, addr_type, dta->entry, dta->decl_address, + dta->gsi); + if (dta->gsi == NULL && addr == NULL_TREE) + { + dta->reset = true; + return NULL_TREE; + } + *tp = build_simple_mem_ref (addr); dta->changed = true; @@ -492,7 +508,13 @@ eliminate_local_variables_1 (tree *tp, int *walk_subtrees, void *data) return NULL_TREE; addr_type = TREE_TYPE (t); - addr = take_address_of (obj, addr_type, dta->entry, dta->decl_address); + addr = take_address_of (obj, addr_type, dta->entry, dta->decl_address, + dta->gsi); + if (dta->gsi == NULL && addr == NULL_TREE) + { + dta->reset = true; + return NULL_TREE; + } *tp = addr; dta->changed = true; @@ -505,27 +527,40 @@ eliminate_local_variables_1 (tree *tp, int *walk_subtrees, void *data) return NULL_TREE; } -/* Moves the references to local variables in STMT out of the single +/* Moves the references to local variables in STMT at *GSI out of the single entry single exit region starting at ENTRY. DECL_ADDRESS contains addresses of the references that had their address taken already. */ static void -eliminate_local_variables_stmt (edge entry, gimple stmt, +eliminate_local_variables_stmt (edge entry, gimple_stmt_iterator *gsi, htab_t decl_address) { struct elv_data dta; + gimple stmt = gsi_stmt (*gsi); memset (&dta.info, '\0', sizeof (dta.info)); dta.entry = entry; dta.decl_address = decl_address; dta.changed = false; + dta.reset = false; if (gimple_debug_bind_p (stmt)) - walk_tree (gimple_debug_bind_get_value_ptr (stmt), - eliminate_local_variables_1, &dta.info, NULL); + { + dta.gsi = NULL; + walk_tree (gimple_debug_bind_get_value_ptr (stmt), + eliminate_local_variables_1, &dta.info, NULL); + if (dta.reset) + { + gimple_debug_bind_reset_value (stmt); + dta.changed = true; + } + } else - walk_gimple_op (stmt, eliminate_local_variables_1, &dta.info); + { + dta.gsi = gsi; + walk_gimple_op (stmt, eliminate_local_variables_1, &dta.info); + } if (dta.changed) update_stmt (stmt); @@ -549,6 +584,7 @@ eliminate_local_variables (edge entry, edge exit) VEC (basic_block, heap) *body = VEC_alloc (basic_block, heap, 3); unsigned i; gimple_stmt_iterator gsi; + bool has_debug_stmt = false; htab_t decl_address = htab_create (10, int_tree_map_hash, int_tree_map_eq, free); basic_block entry_bb = entry->src; @@ -559,8 +595,17 @@ eliminate_local_variables (edge entry, edge exit) FOR_EACH_VEC_ELT (basic_block, body, i, bb) if (bb != entry_bb && bb != exit_bb) for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) - eliminate_local_variables_stmt (entry, gsi_stmt (gsi), - decl_address); + if (gimple_debug_bind_p (gsi_stmt (gsi))) + has_debug_stmt = true; + else + eliminate_local_variables_stmt (entry, &gsi, decl_address); + + if (has_debug_stmt) + FOR_EACH_VEC_ELT (basic_block, body, i, bb) + if (bb != entry_bb && bb != exit_bb) + for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) + if (gimple_debug_bind_p (gsi_stmt (gsi))) + eliminate_local_variables_stmt (entry, &gsi, decl_address); htab_delete (decl_address); VEC_free (basic_block, heap, body); |