-/* Type based alias analysis.
- Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation,
- Inc.
+/* Escape analysis for types.
+ Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010
+ Free Software Foundation, Inc.
Contributed by Kenneth Zadeck <zadeck@naturalbridge.com>
This file is part of GCC.
#include "flags.h"
#include "timevar.h"
#include "diagnostic.h"
+#include "tree-pretty-print.h"
#include "langhooks.h"
/* Some of the aliasing is called very early, before this phase is
}
uid = TYPE_UID (type);
- if (bitmap_bit_p (map, uid))
+ if (!bitmap_set_bit (map, uid))
return type;
- else
- {
- bitmap_set_bit (map, uid);
- if (escape_status == FULL_ESCAPE)
- {
- /* Efficiency hack. When things are bad, do not mess around
- with this type anymore. */
- bitmap_set_bit (global_types_exposed_parameter, uid);
- }
- }
+ else if (escape_status == FULL_ESCAPE)
+ /* Efficiency hack. When things are bad, do not mess around
+ with this type anymore. */
+ bitmap_set_bit (global_types_exposed_parameter, uid);
+
return type;
}
from the TYPE_ARG_LIST. However, Geoff is wrong, this code
does seem to be live. */
- for (arg = DECL_ARGUMENTS (fn); arg; arg = TREE_CHAIN (arg))
+ for (arg = DECL_ARGUMENTS (fn); arg; arg = DECL_CHAIN (arg))
{
tree type = get_canon_type (TREE_TYPE (arg), false, false);
if (escapes)
{
unsigned int cast = 0;
- if (is_gimple_cast (t) || TREE_CODE (t) == VIEW_CONVERT_EXPR)
+ if (CONVERT_EXPR_P (t) || TREE_CODE (t) == VIEW_CONVERT_EXPR)
{
tree castfromvar = TREE_OPERAND (t, 0);
cast = cast | check_cast (TREE_TYPE (t), castfromvar);
/* There may be const decls with interesting right hand sides. */
if (DECL_STRUCT_FUNCTION (decl))
{
- tree step;
- for (step = DECL_STRUCT_FUNCTION (decl)->local_decls;
- step;
- step = TREE_CHAIN (step))
+ tree var;
+ unsigned ix;
+
+ FOR_EACH_LOCAL_DECL (DECL_STRUCT_FUNCTION (decl), ix, var)
{
- tree var = TREE_VALUE (step);
if (TREE_CODE (var) == VAR_DECL
&& DECL_INITIAL (var)
&& !TREE_STATIC (var))
uid = TYPE_UID (type);
- if (bitmap_bit_p (been_there_done_that, uid))
+ if (!bitmap_set_bit (been_there_done_that, uid))
return;
- bitmap_set_bit (been_there_done_that, uid);
/* If we are doing a language with a type hierarchy, mark all of
the superclasses. */
subfields. */
for (field = TYPE_FIELDS (type);
field;
- field = TREE_CHAIN (field))
+ field = DECL_CHAIN (field))
{
tree field_type;
if (TREE_CODE (field) != FIELD_DECL)
uid = TYPE_UID (type);
gcc_assert (!POINTER_TYPE_P (type));
- if (bitmap_bit_p (been_there_done_that, uid))
+ if (!bitmap_set_bit (been_there_done_that, uid))
return;
- bitmap_set_bit (been_there_done_that, uid);
/* If the field is a struct or union type, mark all of the
subfields. */
return;
uid = TYPE_UID (type);
- if (bitmap_bit_p (been_there_done_that, uid))
+ if (!bitmap_set_bit (been_there_done_that, uid))
return;
- bitmap_set_bit (been_there_done_that, uid);
subtype_map = subtype_map_for_uid (uid, false);
else
return NULL;
- if (bitmap_bit_p (been_there_done_that, uid))
+ if (!bitmap_set_bit (been_there_done_that, uid))
return map;
- bitmap_set_bit (been_there_done_that, uid);
/* If the type escapes, get rid of the addressof map, it will not be
needed. */
static bool
gate_type_escape_vars (void)
{
- return (flag_ipa_type_escape
- /* Don't bother doing anything if the program has errors. */
- && !(errorcount || sorrycount));
+ return flag_ipa_struct_reorg && flag_whole_program && (optimize > 0);
}
struct simple_ipa_opt_pass pass_ipa_type_escape =