/* Struct-reorg optimization.
- Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
Contributed by Olga Golovanevsky <olga@il.ibm.com>
(Initial version of this code was developed
by Caroline Tice and Mostafa Hagog.)
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
+Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
for more details.
You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING. If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA. */
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
#include "config.h"
#include "system.h"
#include "langhooks.h"
#include "pointer-set.h"
#include "hashtab.h"
-#include "c-tree.h"
#include "toplev.h"
#include "flags.h"
#include "debug.h"
#include "opts.h"
#include "ipa-type-escape.h"
#include "tree-dump.h"
-#include "c-common.h"
#include "gimple.h"
/* This optimization implements structure peeling.
finalize_var_creation (tree new_decl)
{
add_referenced_var (new_decl);
- if (is_global_var (new_decl))
- mark_call_clobbered (new_decl, ESCAPE_UNKNOWN);
mark_sym_for_renaming (new_decl);
}
if (exact_log2 (struct_size_int) == -1)
{
tree size = build_int_cst (TREE_TYPE (num), struct_size_int);
- new_stmt = gimple_build_assign_with_ops (MULT_EXPR, *res, num, size);
+ new_stmt = gimple_build_assign (*res, fold_build2 (MULT_EXPR,
+ TREE_TYPE (num),
+ num, size));
}
else
{
tree C = build_int_cst (TREE_TYPE (num), exact_log2 (struct_size_int));
- new_stmt = gimple_build_assign_with_ops (LSHIFT_EXPR, *res, num, C);
+ new_stmt = gimple_build_assign (*res, fold_build2 (LSHIFT_EXPR,
+ TREE_TYPE (num),
+ num, C));
}
finalize_stmt (new_stmt);
{
gimple phi = gsi_stmt (si);
arg = PHI_ARG_DEF_FROM_EDGE (phi, e);
- add_phi_arg (phi, arg, new_e);
+ add_phi_arg (phi, arg, new_e, gimple_phi_arg_location_from_edge (phi, e));
}
return new_e;
gimple new_stmt = gimple_copy (old_stmt);
unsigned i;
+ /* We are really building a new stmt, clear the virtual operands. */
+ if (gimple_has_mem_ops (new_stmt))
+ {
+ gimple_set_vuse (new_stmt, NULL_TREE);
+ gimple_set_vdef (new_stmt, NULL_TREE);
+ }
+
for (i = 0; VEC_iterate (tree, acc->vars, i, var); i++)
{
tree *pos;
tree new_var = find_new_var_of_type (var, new_type);
- tree lhs, rhs;
+ tree lhs, rhs = NULL_TREE;
gcc_assert (new_var);
finalize_var_creation (new_var);
{
pos = find_pos_in_stmt (new_stmt, var);
gcc_assert (pos);
+ /* ??? This misses adjustments to the type of the
+ INDIRECT_REF we possibly replace the operand of. */
*pos = new_var;
}
}
wr.wrap = 0;
wr.domain = NULL_TREE;
}
- else if (TREE_CODE (type_orig) == ARRAY_TYPE)
+ else
{
+ gcc_assert (TREE_CODE (type_orig) == ARRAY_TYPE);
wr.wrap = 1;
wr.domain = TYPE_DOMAIN (type_orig);
}
num = gen_num_of_structs_in_malloc (stmt, str->decl, &new_stmts);
if (new_stmts)
{
- last_stmt = gimple_seq_last_stmt (new_stmts);
+ gimple last_stmt_tmp = gimple_seq_last_stmt (new_stmts);
insert_seq_after_stmt (last_stmt, new_stmts);
+ last_stmt = last_stmt_tmp;
}
/* Generate an allocation sites for each new structure type. */
type = gen_struct_type (orig_decl, type);
if (is_global_var (orig_decl))
- new_decl = build_decl (VAR_DECL, new_name, type);
+ new_decl = build_decl (DECL_SOURCE_LOCATION (orig_decl),
+ VAR_DECL, new_name, type);
else
{
const char *name = new_name ? IDENTIFIER_POINTER (new_name) : NULL;
bitmap_obstack_initialize (NULL);
for (node = cgraph_nodes; node; node = node->next)
- if (node->analyzed && node->decl && !node->next_clone)
+ if (node->analyzed && node->decl)
{
push_cfun (DECL_STRUCT_FUNCTION (node->decl));
current_function_decl = node->decl;
if (dump_file)
- fprintf (dump_file, "\nFunction to do reorg is %s: \n",
+ fprintf (dump_file, "\nFunction to do reorg is %s: \n",
(const char *) IDENTIFIER_POINTER (DECL_NAME (node->decl)));
do_reorg_for_func (node);
free_dominance_info (CDI_DOMINATORS);
{
struct function *func = DECL_STRUCT_FUNCTION (c_node->decl);
- if (!c_node->next_clone)
- collect_accesses_in_func (func);
+ collect_accesses_in_func (func);
exclude_alloc_and_field_accs (c_node);
}
}