Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(643)

Unified Diff: gcc/gcc/ipa-type-escape.c

Issue 3050029: [gcc] GCC 4.5.0=>4.5.1 (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/nacl-toolchain.git
Patch Set: Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gcc/gcc/ipa-type-escape.h ('k') | gcc/gcc/ipa-utils.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gcc/gcc/ipa-type-escape.c
diff --git a/gcc/gcc/ipa-type-escape.c b/gcc/gcc/ipa-type-escape.c
index 48d95049b4f3c355c852c49d9dc1d3a6ca18f058..0807d0b107a2819f5705ab14bcd25b144f55af97 100644
--- a/gcc/gcc/ipa-type-escape.c
+++ b/gcc/gcc/ipa-type-escape.c
@@ -1,6 +1,6 @@
/* Type based alias analysis.
- Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation,
- Inc.
+ 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.
@@ -43,10 +43,10 @@ along with GCC; see the file COPYING3. If not see
#include "tree-pass.h"
#include "langhooks.h"
#include "pointer-set.h"
+#include "splay-tree.h"
#include "ggc.h"
#include "ipa-utils.h"
#include "ipa-type-escape.h"
-#include "c-common.h"
#include "gimple.h"
#include "cgraph.h"
#include "output.h"
@@ -90,7 +90,7 @@ enum escape_t
previous cases above. During the analysis phase, a bit is set in
one of these vectors if an operation of the offending class is
discovered to happen on the associated type. */
-
+
static bitmap global_types_exposed_parameter;
static bitmap global_types_full_escape;
@@ -134,7 +134,7 @@ static struct pointer_set_t *visited_stmts;
static bitmap_obstack ipa_obstack;
-/* Static functions from this file that are used
+/* Static functions from this file that are used
before being defined. */
static unsigned int look_for_casts (tree);
static bool is_cast_from_non_pointer (tree, gimple, void *);
@@ -144,11 +144,11 @@ static const char*
get_name_of_type (tree type)
{
tree name = TYPE_NAME (type);
-
+
if (!name)
/* Unnamed type, do what you like here. */
return "<UNNAMED>";
-
+
/* It will be a TYPE_DECL in the case of a typedef, otherwise, an
identifier_node */
if (TREE_CODE (name) == TYPE_DECL)
@@ -164,11 +164,11 @@ get_name_of_type (tree type)
}
else if (TREE_CODE (name) == IDENTIFIER_NODE)
return IDENTIFIER_POINTER (name);
- else
+ else
return "<UNNAMED>";
}
-struct type_brand_s
+struct type_brand_s
{
const char* name;
int seq;
@@ -176,7 +176,7 @@ struct type_brand_s
/* Splay tree comparison function on type_brand_s structures. */
-static int
+static int
compare_type_brand (splay_tree_key sk1, splay_tree_key sk2)
{
struct type_brand_s * k1 = (struct type_brand_s *) sk1;
@@ -185,7 +185,7 @@ compare_type_brand (splay_tree_key sk1, splay_tree_key sk2)
int value = strcmp(k1->name, k2->name);
if (value == 0)
return k2->seq - k1->seq;
- else
+ else
return value;
}
@@ -281,7 +281,7 @@ type_to_consider (tree type)
case VECTOR_TYPE:
case VOID_TYPE:
return true;
-
+
default:
return false;
}
@@ -291,7 +291,7 @@ type_to_consider (tree type)
the POINTER_TOs and if SEE_THRU_ARRAYS is true, remove all of the
ARRAY_OFs and POINTER_TOs. */
-static tree
+static tree
get_canon_type (tree type, bool see_thru_ptrs, bool see_thru_arrays)
{
splay_tree_node result;
@@ -300,16 +300,16 @@ get_canon_type (tree type, bool see_thru_ptrs, bool see_thru_arrays)
return NULL;
type = TYPE_MAIN_VARIANT (type);
- if (see_thru_arrays)
+ if (see_thru_arrays)
while (POINTER_TYPE_P (type) || TREE_CODE (type) == ARRAY_TYPE)
type = TYPE_MAIN_VARIANT (TREE_TYPE (type));
- else if (see_thru_ptrs)
+ else if (see_thru_ptrs)
while (POINTER_TYPE_P (type))
type = TYPE_MAIN_VARIANT (TREE_TYPE (type));
result = splay_tree_lookup (type_to_canon_type, (splay_tree_key) type);
-
+
if (result == NULL)
return discover_unique_type (type);
else return (tree) result->value;
@@ -331,9 +331,9 @@ get_canon_type_uid (tree type, bool see_thru_ptrs, bool see_thru_arrays)
number if TYPE is a pointer to a record or union. The number is
the number of pointer types stripped to get to the record or union
type. Return -1 if TYPE is none of the above. */
-
+
int
-ipa_type_escape_star_count_of_interesting_type (tree type)
+ipa_type_escape_star_count_of_interesting_type (tree type)
{
int count = 0;
/* Strip the *'s off. */
@@ -347,22 +347,22 @@ ipa_type_escape_star_count_of_interesting_type (tree type)
}
/* We are interested in records, and unions only. */
- if (TREE_CODE (type) == RECORD_TYPE
- || TREE_CODE (type) == QUAL_UNION_TYPE
+ if (TREE_CODE (type) == RECORD_TYPE
+ || TREE_CODE (type) == QUAL_UNION_TYPE
|| TREE_CODE (type) == UNION_TYPE)
return count;
- else
+ else
return -1;
-}
+}
/* Return 0 if TYPE is a record or union type. Return a positive
number if TYPE is a pointer to a record or union. The number is
the number of pointer types stripped to get to the record or union
type. Return -1 if TYPE is none of the above. */
-
+
int
-ipa_type_escape_star_count_of_interesting_or_array_type (tree type)
+ipa_type_escape_star_count_of_interesting_or_array_type (tree type)
{
int count = 0;
/* Strip the *'s off. */
@@ -376,15 +376,15 @@ ipa_type_escape_star_count_of_interesting_or_array_type (tree type)
}
/* We are interested in records, and unions only. */
- if (TREE_CODE (type) == RECORD_TYPE
- || TREE_CODE (type) == QUAL_UNION_TYPE
+ if (TREE_CODE (type) == RECORD_TYPE
+ || TREE_CODE (type) == QUAL_UNION_TYPE
|| TREE_CODE (type) == UNION_TYPE)
return count;
- else
+ else
return -1;
-}
-
-
+}
+
+
/* Return true if the record, or union TYPE passed in escapes this
compilation unit. Note that all of the pointer-to's are removed
before testing since these may not be correct. */
@@ -394,19 +394,19 @@ ipa_type_escape_type_contained_p (tree type)
{
if (!initialized)
return false;
- return !bitmap_bit_p (global_types_full_escape,
+ return !bitmap_bit_p (global_types_full_escape,
get_canon_type_uid (type, true, false));
}
/* Return true if a modification to a field of type FIELD_TYPE cannot
clobber a record of RECORD_TYPE. */
-bool
+bool
ipa_type_escape_field_does_not_clobber_p (tree record_type, tree field_type)
-{
+{
splay_tree_node result;
int uid;
-
+
if (!initialized)
return false;
@@ -418,25 +418,25 @@ ipa_type_escape_field_does_not_clobber_p (tree record_type, tree field_type)
while (POINTER_TYPE_P (record_type))
{
record_type = TYPE_MAIN_VARIANT (TREE_TYPE (record_type));
- if (POINTER_TYPE_P (field_type))
+ if (POINTER_TYPE_P (field_type))
field_type = TYPE_MAIN_VARIANT (TREE_TYPE (field_type));
- else
+ else
/* However, if field_type is a union, this quick test is not
correct since one of the variants of the union may be a
pointer to type and we cannot see across that here. So we
just strip the remaining pointer tos off the record type
and fall thru to the more precise code. */
- if (TREE_CODE (field_type) == QUAL_UNION_TYPE
+ if (TREE_CODE (field_type) == QUAL_UNION_TYPE
|| TREE_CODE (field_type) == UNION_TYPE)
{
while (POINTER_TYPE_P (record_type))
record_type = TYPE_MAIN_VARIANT (TREE_TYPE (record_type));
break;
- }
- else
+ }
+ else
return true;
}
-
+
record_type = get_canon_type (record_type, true, true);
/* The record type must be contained. The field type may
escape. */
@@ -445,8 +445,8 @@ ipa_type_escape_field_does_not_clobber_p (tree record_type, tree field_type)
uid = TYPE_UID (record_type);
result = splay_tree_lookup (uid_to_addressof_down_map, (splay_tree_key) uid);
-
- if (result)
+
+ if (result)
{
bitmap field_type_map = (bitmap) result->value;
uid = get_canon_type_uid (field_type, true, true);
@@ -470,10 +470,10 @@ mark_type (tree type, enum escape_t escape_status)
int uid;
type = get_canon_type (type, true, true);
- if (!type)
+ if (!type)
return NULL;
- switch (escape_status)
+ switch (escape_status)
{
case EXPOSED_PARAMETER:
map = global_types_exposed_parameter;
@@ -494,7 +494,7 @@ mark_type (tree type, enum escape_t escape_status)
/* Efficiency hack. When things are bad, do not mess around
with this type anymore. */
bitmap_set_bit (global_types_exposed_parameter, uid);
- }
+ }
}
return type;
}
@@ -503,7 +503,7 @@ mark_type (tree type, enum escape_t escape_status)
EXPOSED_PARAMETER and the TYPE is a pointer type, the set is
changed to FULL_ESCAPE. */
-static void
+static void
mark_interesting_type (tree type, enum escape_t escape_status)
{
if (!type) return;
@@ -522,24 +522,24 @@ mark_interesting_type (tree type, enum escape_t escape_status)
/* Return true if PARENT is supertype of CHILD. Both types must be
known to be structures or unions. */
-
+
static bool
parent_type_p (tree parent, tree child)
{
int i;
tree binfo, base_binfo;
- if (TYPE_BINFO (parent))
+ if (TYPE_BINFO (parent))
for (binfo = TYPE_BINFO (parent), i = 0;
BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
{
tree binfotype = BINFO_TYPE (base_binfo);
- if (binfotype == child)
+ if (binfotype == child)
return true;
else if (parent_type_p (binfotype, child))
return true;
}
if (TREE_CODE (parent) == UNION_TYPE
- || TREE_CODE (parent) == QUAL_UNION_TYPE)
+ || TREE_CODE (parent) == QUAL_UNION_TYPE)
{
tree field;
/* Search all of the variants in the union to see if one of them
@@ -551,9 +551,9 @@ parent_type_p (tree parent, tree child)
tree field_type;
if (TREE_CODE (field) != FIELD_DECL)
continue;
-
+
field_type = TREE_TYPE (field);
- if (field_type == child)
+ if (field_type == child)
return true;
}
@@ -566,16 +566,16 @@ parent_type_p (tree parent, tree child)
tree field_type;
if (TREE_CODE (field) != FIELD_DECL)
continue;
-
+
field_type = TREE_TYPE (field);
- if (TREE_CODE (field_type) == RECORD_TYPE
- || TREE_CODE (field_type) == QUAL_UNION_TYPE
+ if (TREE_CODE (field_type) == RECORD_TYPE
+ || TREE_CODE (field_type) == QUAL_UNION_TYPE
|| TREE_CODE (field_type) == UNION_TYPE)
- if (parent_type_p (field_type, child))
+ if (parent_type_p (field_type, child))
return true;
}
}
-
+
if (TREE_CODE (parent) == RECORD_TYPE)
{
tree field;
@@ -586,19 +586,19 @@ parent_type_p (tree parent, tree child)
tree field_type;
if (TREE_CODE (field) != FIELD_DECL)
continue;
-
+
field_type = TREE_TYPE (field);
- if (field_type == child)
+ if (field_type == child)
return true;
/* You can only cast to the first field so if it does not
match, quit. */
- if (TREE_CODE (field_type) == RECORD_TYPE
- || TREE_CODE (field_type) == QUAL_UNION_TYPE
+ if (TREE_CODE (field_type) == RECORD_TYPE
+ || TREE_CODE (field_type) == QUAL_UNION_TYPE
|| TREE_CODE (field_type) == UNION_TYPE)
{
- if (parent_type_p (field_type, child))
+ if (parent_type_p (field_type, child))
return true;
- else
+ else
break;
}
}
@@ -609,7 +609,7 @@ parent_type_p (tree parent, tree child)
/* Return the number of pointer tos for TYPE and return TYPE with all
of these stripped off. */
-static int
+static int
count_stars (tree* type_ptr)
{
tree type = *type_ptr;
@@ -646,7 +646,7 @@ check_cast_type (tree to_type, tree from_type)
{
int to_stars = count_stars (&to_type);
int from_stars = count_stars (&from_type);
- if (to_stars != from_stars)
+ if (to_stars != from_stars)
return CT_SIDEWAYS;
if (to_type == from_type)
@@ -655,9 +655,9 @@ check_cast_type (tree to_type, tree from_type)
if (parent_type_p (to_type, from_type)) return CT_UP;
if (parent_type_p (from_type, to_type)) return CT_DOWN;
return CT_SIDEWAYS;
-}
+}
-/* This function returns nonzero if VAR is result of call
+/* This function returns nonzero if VAR is result of call
to malloc function. */
static bool
@@ -667,12 +667,12 @@ is_malloc_result (tree var)
if (!var)
return false;
-
+
if (SSA_NAME_IS_DEFAULT_DEF (var))
return false;
def_stmt = SSA_NAME_DEF_STMT (var);
-
+
if (!is_gimple_call (def_stmt))
return false;
@@ -685,9 +685,9 @@ is_malloc_result (tree var)
/* Check a cast FROM this variable, TO_TYPE. Mark the escaping types
if appropriate. Returns cast_type as detected. */
-
+
static enum cast_type
-check_cast (tree to_type, tree from)
+check_cast (tree to_type, tree from)
{
tree from_type = get_canon_type (TREE_TYPE (from), false, false);
bool to_interesting_type, from_interesting_type;
@@ -697,12 +697,12 @@ check_cast (tree to_type, tree from)
if (!from_type || !to_type || from_type == to_type)
return cast;
- to_interesting_type =
+ to_interesting_type =
ipa_type_escape_star_count_of_interesting_type (to_type) >= 0;
- from_interesting_type =
+ from_interesting_type =
ipa_type_escape_star_count_of_interesting_type (from_type) >= 0;
- if (to_interesting_type)
+ if (to_interesting_type)
if (from_interesting_type)
{
/* Both types are interesting. This can be one of four types
@@ -712,7 +712,7 @@ check_cast (tree to_type, tree from)
interesting here because if type is marked as escaping, all
of its subtypes escape. */
cast = check_cast_type (to_type, from_type);
- switch (cast)
+ switch (cast)
{
case CT_UP:
case CT_USELESS:
@@ -731,18 +731,18 @@ check_cast (tree to_type, tree from)
else
{
/* This code excludes two cases from marking as escaped:
-
+
1. if this is a cast of index of array of structures/unions
- that happens before accessing array element, we should not
+ that happens before accessing array element, we should not
mark it as escaped.
2. if this is a cast from the local that is a result from a
- call to malloc, do not mark the cast as bad.
+ call to malloc, do not mark the cast as bad.
*/
-
+
if (POINTER_TYPE_P (to_type) && !POINTER_TYPE_P (from_type))
cast = CT_FROM_NON_P;
- else if (TREE_CODE (from) == SSA_NAME
+ else if (TREE_CODE (from) == SSA_NAME
&& is_malloc_result (from))
cast = CT_FROM_MALLOC;
else
@@ -786,16 +786,16 @@ look_for_casts_stmt (gimple s)
cast = CT_NO_CAST;
return cast;
-}
+}
-typedef struct cast
+typedef struct cast
{
int type;
gimple stmt;
} cast_t;
-/* This function is a callback for walk_use_def_chains function called
+/* This function is a callback for walk_use_def_chains function called
from is_array_access_through_pointer_and_index. */
static bool
@@ -803,7 +803,7 @@ is_cast_from_non_pointer (tree var, gimple def_stmt, void *data)
{
if (!def_stmt || !var)
return false;
-
+
if (gimple_code (def_stmt) == GIMPLE_PHI)
return false;
@@ -812,13 +812,13 @@ is_cast_from_non_pointer (tree var, gimple def_stmt, void *data)
if (is_gimple_assign (def_stmt))
{
- use_operand_p use_p;
+ use_operand_p use_p;
ssa_op_iter iter;
unsigned int cast = look_for_casts_stmt (def_stmt);
/* Check that only one cast happened, and it's of non-pointer
type. */
- if ((cast & CT_FROM_NON_P) == (CT_FROM_NON_P)
+ if ((cast & CT_FROM_NON_P) == (CT_FROM_NON_P)
&& (cast & ~(CT_FROM_NON_P)) == 0)
{
((cast_t *)data)->stmt = def_stmt;
@@ -845,20 +845,20 @@ is_cast_from_non_pointer (tree var, gimple def_stmt, void *data)
is_cast_from_non_pointer, data, false);
if (((cast_t*)data)->type == -1)
break;
- }
+ }
}
/* The cast is harmful. */
else
((cast_t *)data)->type = -1;
- }
+ }
if (((cast_t*)data)->type == -1)
return true;
-
+
return false;
}
-/* When array element a_p[i] is accessed through the pointer a_p
+/* When array element a_p[i] is accessed through the pointer a_p
and index i, it's translated into the following sequence
in gimple:
@@ -868,41 +868,41 @@ is_cast_from_non_pointer (tree var, gimple def_stmt, void *data)
a_p.2_8 = a_p;
D.1608_9 = D.1606_7 + a_p.2_8;
- OP0 and OP1 are of the same pointer types and stand for
+ OP0 and OP1 are of the same pointer types and stand for
D.1606_7 and a_p.2_8 or vise versa.
This function checks that:
- 1. one of OP0 and OP1 (D.1606_7) has passed only one cast from
+ 1. one of OP0 and OP1 (D.1606_7) has passed only one cast from
non-pointer type (D.1606_7 = (struct str_t *) D.1605_6;).
- 2. one of OP0 and OP1 which has passed the cast from
- non-pointer type (D.1606_7), is actually generated by multiplication of
+ 2. one of OP0 and OP1 which has passed the cast from
+ non-pointer type (D.1606_7), is actually generated by multiplication of
index by size of type to which both OP0 and OP1 point to
(in this case D.1605_6 = i.1_5 * 16; ).
- 3. an address of def of the var to which was made cast (D.1605_6)
+ 3. an address of def of the var to which was made cast (D.1605_6)
was not taken.(How can it happen?)
The following items are checked implicitly by the end of algorithm:
- 4. one of OP0 and OP1 (a_p.2_8) have never been cast
- (because if it was cast to pointer type, its type, that is also
- the type of OP0 and OP1, will be marked as escaped during
- analysis of casting stmt (when check_cast() is called
- from scan_for_refs for this stmt)).
+ 4. one of OP0 and OP1 (a_p.2_8) have never been cast
+ (because if it was cast to pointer type, its type, that is also
+ the type of OP0 and OP1, will be marked as escaped during
+ analysis of casting stmt (when check_cast() is called
+ from scan_for_refs for this stmt)).
5. defs of OP0 and OP1 are not passed into externally visible function
(because if they are passed then their type, that is also the type of OP0
- and OP1, will be marked and escaped during check_call function called from
+ and OP1, will be marked and escaped during check_call function called from
scan_for_refs with call stmt).
- In total, 1-5 guaranty that it's an access to array by pointer and index.
+ In total, 1-5 guaranty that it's an access to array by pointer and index.
*/
bool
-is_array_access_through_pointer_and_index (enum tree_code code, tree op0,
+is_array_access_through_pointer_and_index (enum tree_code code, tree op0,
tree op1, tree *base, tree *offset,
gimple *offset_cast_stmt)
{
@@ -945,7 +945,7 @@ is_array_access_through_pointer_and_index (enum tree_code code, tree op0,
false);
pointer_set_destroy (visited_stmts);
- visited_stmts = pointer_set_create ();
+ visited_stmts = pointer_set_create ();
walk_use_def_chains (op1, is_cast_from_non_pointer,(void *)(&op1_cast),
false);
pointer_set_destroy (visited_stmts);
@@ -959,15 +959,15 @@ is_array_access_through_pointer_and_index (enum tree_code code, tree op0,
else if (op0_cast.type == 0 && op1_cast.type == 1)
{
*base = op0;
- *offset = op1;
+ *offset = op1;
*offset_cast_stmt = op1_cast.stmt;
}
else
return false;
}
-
- /* Check 2.
- offset_cast_stmt is of the form:
+
+ /* Check 2.
+ offset_cast_stmt is of the form:
D.1606_7 = (struct str_t *) D.1605_6; */
if (*offset_cast_stmt)
@@ -975,10 +975,10 @@ is_array_access_through_pointer_and_index (enum tree_code code, tree op0,
before_cast = SINGLE_SSA_TREE_OPERAND (*offset_cast_stmt, SSA_OP_USE);
if (!before_cast)
return false;
-
+
if (SSA_NAME_IS_DEFAULT_DEF (before_cast))
return false;
-
+
before_cast_def_stmt = SSA_NAME_DEF_STMT (before_cast);
if (!before_cast_def_stmt)
return false;
@@ -988,7 +988,7 @@ is_array_access_through_pointer_and_index (enum tree_code code, tree op0,
/* before_cast_def_stmt should be of the form:
D.1605_6 = i.1_5 * 16; */
-
+
if (is_gimple_assign (before_cast_def_stmt))
{
/* We expect temporary here. */
@@ -999,14 +999,14 @@ is_array_access_through_pointer_and_index (enum tree_code code, tree op0,
{
tree arg0 = gimple_assign_rhs1 (before_cast_def_stmt);
tree arg1 = gimple_assign_rhs2 (before_cast_def_stmt);
- tree unit_size =
+ tree unit_size =
TYPE_SIZE_UNIT (TREE_TYPE (TYPE_MAIN_VARIANT (TREE_TYPE (op0))));
- if (!(CONSTANT_CLASS_P (arg0)
+ if (!(CONSTANT_CLASS_P (arg0)
&& simple_cst_equal (arg0, unit_size))
- && !(CONSTANT_CLASS_P (arg1)
+ && !(CONSTANT_CLASS_P (arg1)
&& simple_cst_equal (arg1, unit_size)))
- return false;
+ return false;
}
else
return false;
@@ -1024,11 +1024,11 @@ is_array_access_through_pointer_and_index (enum tree_code code, tree op0,
/* Register the parameter and return types of function FN. The type
ESCAPES if the function is visible outside of the compilation
unit. */
-static void
-check_function_parameter_and_return_types (tree fn, bool escapes)
+static void
+check_function_parameter_and_return_types (tree fn, bool escapes)
{
tree arg;
-
+
if (TYPE_ARG_TYPES (TREE_TYPE (fn)))
{
for (arg = TYPE_ARG_TYPES (TREE_TYPE (fn));
@@ -1057,7 +1057,7 @@ check_function_parameter_and_return_types (tree fn, bool escapes)
if (escapes)
{
tree type = get_canon_type (TREE_TYPE (TREE_TYPE (fn)), false, false);
- mark_interesting_type (type, EXPOSED_PARAMETER);
+ mark_interesting_type (type, EXPOSED_PARAMETER);
}
}
@@ -1072,7 +1072,7 @@ has_proper_scope_for_analysis (tree t)
tree type = get_canon_type (TREE_TYPE (t), false, false);
if (!type) return;
- if (lookup_attribute ("used", DECL_ATTRIBUTES (t)))
+ if (DECL_PRESERVE_P (t))
{
mark_interesting_type (type, FULL_ESCAPE);
return;
@@ -1080,7 +1080,7 @@ has_proper_scope_for_analysis (tree t)
/* Do not want to do anything with volatile except mark any
function that uses one to be not const or pure. */
- if (TREE_THIS_VOLATILE (t))
+ if (TREE_THIS_VOLATILE (t))
return;
/* Do not care about a local automatic that is not static. */
@@ -1093,12 +1093,12 @@ has_proper_scope_for_analysis (tree t)
constant, we can allow this variable in pure or const
functions but the scope is too large for our analysis to set
these bits ourselves. */
-
+
if (TREE_READONLY (t)
&& DECL_INITIAL (t)
&& is_gimple_min_invariant (DECL_INITIAL (t)))
; /* Read of a constant, do not change the function state. */
- else
+ else
{
/* The type escapes for all public and externs. */
mark_interesting_type (type, FULL_ESCAPE);
@@ -1120,7 +1120,7 @@ check_operand (tree t)
check_function_parameter_and_return_types (t, true);
else if (TREE_CODE (t) == VAR_DECL)
- has_proper_scope_for_analysis (t);
+ has_proper_scope_for_analysis (t);
}
/* Examine tree T for references. */
@@ -1128,9 +1128,6 @@ check_operand (tree t)
static void
check_tree (tree t)
{
- if ((TREE_CODE (t) == EXC_PTR_EXPR) || (TREE_CODE (t) == FILTER_EXPR))
- return;
-
/* We want to catch here also REALPART_EXPR and IMAGEPART_EXPR,
but they already included in handled_component_p. */
while (handled_component_p (t))
@@ -1159,11 +1156,11 @@ mark_interesting_addressof (tree to_type, tree from_type)
int from_uid;
int to_uid;
bitmap type_map;
- splay_tree_node result;
+ splay_tree_node result;
from_type = get_canon_type (from_type, false, false);
to_type = get_canon_type (to_type, false, false);
-
+
if (!from_type || !to_type)
return;
@@ -1171,41 +1168,41 @@ mark_interesting_addressof (tree to_type, tree from_type)
to_uid = TYPE_UID (to_type);
gcc_assert (ipa_type_escape_star_count_of_interesting_type (from_type) == 0);
-
+
/* Process the Y into X map pointer. */
- result = splay_tree_lookup (uid_to_addressof_down_map,
+ result = splay_tree_lookup (uid_to_addressof_down_map,
(splay_tree_key) from_uid);
-
- if (result)
- type_map = (bitmap) result->value;
- else
+
+ if (result)
+ type_map = (bitmap) result->value;
+ else
{
type_map = BITMAP_ALLOC (&ipa_obstack);
splay_tree_insert (uid_to_addressof_down_map,
- from_uid,
+ from_uid,
(splay_tree_value)type_map);
}
bitmap_set_bit (type_map, TYPE_UID (to_type));
-
+
/* Process the X into Y reverse map pointer. */
- result =
+ result =
splay_tree_lookup (uid_to_addressof_up_map, (splay_tree_key) to_uid);
-
- if (result)
- type_map = (bitmap) result->value;
- else
+
+ if (result)
+ type_map = (bitmap) result->value;
+ else
{
type_map = BITMAP_ALLOC (&ipa_obstack);
splay_tree_insert (uid_to_addressof_up_map,
- to_uid,
+ to_uid,
(splay_tree_value)type_map);
}
- bitmap_set_bit (type_map, TYPE_UID (from_type));
+ bitmap_set_bit (type_map, TYPE_UID (from_type));
}
/* Scan tree T to see if there are any addresses taken in within T. */
-static void
+static void
look_for_address_of (tree t)
{
if (TREE_CODE (t) == ADDR_EXPR)
@@ -1214,14 +1211,14 @@ look_for_address_of (tree t)
tree cref = TREE_OPERAND (t, 0);
/* If we have an expression of the form "&a.b.c.d", mark a.b,
- b.c and c.d. as having its address taken. */
+ b.c and c.d. as having its address taken. */
tree fielddecl = NULL_TREE;
while (cref!= x)
{
if (TREE_CODE (cref) == COMPONENT_REF)
{
fielddecl = TREE_OPERAND (cref, 1);
- mark_interesting_addressof (TREE_TYPE (fielddecl),
+ mark_interesting_addressof (TREE_TYPE (fielddecl),
DECL_FIELD_CONTEXT (fielddecl));
}
else if (TREE_CODE (cref) == ARRAY_REF)
@@ -1230,7 +1227,7 @@ look_for_address_of (tree t)
cref = TREE_OPERAND (cref, 0);
}
- if (TREE_CODE (x) == VAR_DECL)
+ if (TREE_CODE (x) == VAR_DECL)
has_proper_scope_for_analysis (x);
}
}
@@ -1238,7 +1235,7 @@ look_for_address_of (tree t)
/* Scan tree T to see if there are any casts within it. */
-static unsigned int
+static unsigned int
look_for_casts (tree t)
{
unsigned int cast = 0;
@@ -1248,7 +1245,7 @@ look_for_casts (tree t)
tree castfromvar = TREE_OPERAND (t, 0);
cast = cast | check_cast (TREE_TYPE (t), castfromvar);
}
- else
+ else
while (handled_component_p (t))
{
t = TREE_OPERAND (t, 0);
@@ -1267,7 +1264,7 @@ look_for_casts (tree t)
if (!cast)
cast = CT_NO_CAST;
return cast;
-}
+}
/* Check to see if T is a read or address of operation on a static var
we are interested in analyzing. */
@@ -1305,7 +1302,7 @@ check_asm (gimple stmt)
for (i = 0; i < gimple_asm_ninputs (stmt); i++)
check_rhs_var (gimple_asm_input_op (stmt, i));
-
+
/* There is no code here to check for asm memory clobbers. The
casual maintainer might think that such code would be necessary,
but that appears to be wrong. In other parts of the compiler,
@@ -1330,20 +1327,21 @@ check_call (gimple call)
for (i = 0; i < gimple_call_num_args (call); i++)
check_rhs_var (gimple_call_arg (call, i));
-
+
if (callee_t)
{
tree arg_type;
tree last_arg_type = NULL;
callee = cgraph_node(callee_t);
avail = cgraph_function_body_availability (callee);
-
+
/* Check that there are no implicit casts in the passing of
parameters. */
if (TYPE_ARG_TYPES (TREE_TYPE (callee_t)))
{
for (arg_type = TYPE_ARG_TYPES (TREE_TYPE (callee_t)), i = 0;
- arg_type && TREE_VALUE (arg_type) != void_type_node;
+ arg_type && TREE_VALUE (arg_type) != void_type_node
+ && i < gimple_call_num_args (call);
arg_type = TREE_CHAIN (arg_type), i++)
{
tree operand = gimple_call_arg (call, i);
@@ -1352,20 +1350,20 @@ check_call (gimple call)
last_arg_type = TREE_VALUE(arg_type);
check_cast (last_arg_type, operand);
}
- else
+ else
/* The code reaches here for some unfortunate
builtin functions that do not have a list of
argument types. */
- break;
+ break;
}
- }
- else
- {
+ }
+ else
+ {
/* FIXME - According to Geoff Keating, we should never
have to do this; the front ends should always process
the arg list from the TYPE_ARG_LIST. */
for (arg_type = DECL_ARGUMENTS (callee_t), i = 0;
- arg_type;
+ arg_type && i < gimple_call_num_args (call);
arg_type = TREE_CHAIN (arg_type), i++)
{
tree operand = gimple_call_arg (call, i);
@@ -1373,15 +1371,15 @@ check_call (gimple call)
{
last_arg_type = TREE_TYPE (arg_type);
check_cast (last_arg_type, operand);
- }
- else
+ }
+ else
/* The code reaches here for some unfortunate
builtin functions that do not have a list of
argument types. */
- break;
+ break;
}
}
-
+
/* In the case where we have a var_args function, we need to
check the remaining parameters against the last argument. */
arg_type = last_arg_type;
@@ -1390,7 +1388,7 @@ check_call (gimple call)
tree operand = gimple_call_arg (call, i);
if (arg_type)
check_cast (arg_type, operand);
- else
+ else
{
/* The code reaches here for some unfortunate
builtin functions that do not have a list of
@@ -1418,10 +1416,10 @@ check_call (gimple call)
tree type = get_canon_type (TREE_TYPE (operand), false, false);
mark_interesting_type (type, EXPOSED_PARAMETER);
}
-
- if (callee_t)
+
+ if (callee_t)
{
- tree type =
+ tree type =
get_canon_type (TREE_TYPE (TREE_TYPE (callee_t)), false, false);
mark_interesting_type (type, EXPOSED_PARAMETER);
}
@@ -1430,7 +1428,7 @@ check_call (gimple call)
/* CODE is the operation on OP0 and OP1. OP0 is the operand that we
*know* is a pointer type. OP1 may be a pointer type. */
-static bool
+static bool
okay_pointer_operation (enum tree_code code, tree op0, tree op1)
{
tree op0type = TYPE_MAIN_VARIANT (TREE_TYPE (op0));
@@ -1449,28 +1447,28 @@ okay_pointer_operation (enum tree_code code, tree op0, tree op1)
gimple offset_cast_stmt;
if (POINTER_TYPE_P (op0type)
- && TREE_CODE (op0) == SSA_NAME
- && TREE_CODE (op1) == SSA_NAME
- && is_array_access_through_pointer_and_index (code, op0, op1,
- &base,
- &offset,
+ && TREE_CODE (op0) == SSA_NAME
+ && TREE_CODE (op1) == SSA_NAME
+ && is_array_access_through_pointer_and_index (code, op0, op1,
+ &base,
+ &offset,
&offset_cast_stmt))
return true;
else
{
tree size_of_op0_points_to = TYPE_SIZE_UNIT (TREE_TYPE (op0type));
-
+
if (CONSTANT_CLASS_P (op1)
&& size_of_op0_points_to
- && multiple_of_p (TREE_TYPE (size_of_op0_points_to),
+ && multiple_of_p (TREE_TYPE (size_of_op0_points_to),
op1, size_of_op0_points_to))
return true;
- if (CONSTANT_CLASS_P (op0)
+ if (CONSTANT_CLASS_P (op0)
&& size_of_op0_points_to
- && multiple_of_p (TREE_TYPE (size_of_op0_points_to),
+ && multiple_of_p (TREE_TYPE (size_of_op0_points_to),
op0, size_of_op0_points_to))
- return true;
+ return true;
}
}
break;
@@ -1496,7 +1494,7 @@ check_assign (gimple t)
/* Next check the operands on the rhs to see if they are ok. */
switch (TREE_CODE_CLASS (gimple_assign_rhs_code (t)))
{
- case tcc_binary:
+ case tcc_binary:
{
tree op0 = gimple_assign_rhs1 (t);
tree type0 = get_canon_type (TREE_TYPE (op0), false, false);
@@ -1577,22 +1575,22 @@ check_assign (gimple t)
static void
scan_for_refs (gimple t)
{
- switch (gimple_code (t))
+ switch (gimple_code (t))
{
case GIMPLE_ASSIGN:
check_assign (t);
break;
- case GIMPLE_CALL:
+ case GIMPLE_CALL:
/* If this is a call to malloc, squirrel away the result so we
do mark the resulting cast as being bad. */
check_call (t);
break;
-
+
case GIMPLE_ASM:
check_asm (t);
break;
-
+
default:
break;
}
@@ -1603,8 +1601,8 @@ scan_for_refs (gimple t)
/* The init routine for analyzing global static variable usage. See
comments at top for description. */
-static void
-ipa_init (void)
+static void
+ipa_init (void)
{
bitmap_obstack_initialize (&ipa_obstack);
global_types_exposed_parameter = BITMAP_ALLOC (&ipa_obstack);
@@ -1632,7 +1630,7 @@ ipa_init (void)
compilation unit but their right hand sides may contain references
to variables defined within this unit. */
-static void
+static void
analyze_variable (struct varpool_node *vnode)
{
tree global = vnode->decl;
@@ -1657,11 +1655,11 @@ static void
analyze_function (struct cgraph_node *fn)
{
tree decl = fn->decl;
- check_function_parameter_and_return_types (decl,
+ check_function_parameter_and_return_types (decl,
fn->local.externally_visible);
if (dump_file)
fprintf (dump_file, "\n local analysis of %s", cgraph_node_name (fn));
-
+
{
struct function *this_cfun = DECL_STRUCT_FUNCTION (decl);
basic_block this_block;
@@ -1683,7 +1681,7 @@ analyze_function (struct cgraph_node *fn)
step = TREE_CHAIN (step))
{
tree var = TREE_VALUE (step);
- if (TREE_CODE (var) == VAR_DECL
+ if (TREE_CODE (var) == VAR_DECL
&& DECL_INITIAL (var)
&& !TREE_STATIC (var))
check_tree (DECL_INITIAL (var));
@@ -1698,31 +1696,31 @@ analyze_function (struct cgraph_node *fn)
static tree
type_for_uid (int uid)
{
- splay_tree_node result =
+ splay_tree_node result =
splay_tree_lookup (uid_to_canon_type, (splay_tree_key) uid);
-
+
if (result)
- return (tree) result->value;
+ return (tree) result->value;
else return NULL;
}
/* Return a bitmap with the subtypes of the type for UID. If it
does not exist, return either NULL or a new bitmap depending on the
- value of CREATE. */
+ value of CREATE. */
static bitmap
subtype_map_for_uid (int uid, bool create)
{
- splay_tree_node result = splay_tree_lookup (uid_to_subtype_map,
+ splay_tree_node result = splay_tree_lookup (uid_to_subtype_map,
(splay_tree_key) uid);
-
- if (result)
- return (bitmap) result->value;
+
+ if (result)
+ return (bitmap) result->value;
else if (create)
{
bitmap subtype_map = BITMAP_ALLOC (&ipa_obstack);
splay_tree_insert (uid_to_subtype_map,
- uid,
+ uid,
(splay_tree_value)subtype_map);
return subtype_map;
}
@@ -1754,17 +1752,17 @@ close_type_seen (tree type)
/* If we are doing a language with a type hierarchy, mark all of
the superclasses. */
- if (TYPE_BINFO (type))
+ if (TYPE_BINFO (type))
for (binfo = TYPE_BINFO (type), i = 0;
BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
{
tree binfo_type = BINFO_TYPE (base_binfo);
- bitmap subtype_map = subtype_map_for_uid
+ bitmap subtype_map = subtype_map_for_uid
(TYPE_UID (TYPE_MAIN_VARIANT (binfo_type)), true);
bitmap_set_bit (subtype_map, uid);
close_type_seen (get_canon_type (binfo_type, true, true));
}
-
+
/* If the field is a struct or union type, mark all of the
subfields. */
for (field = TYPE_FIELDS (type);
@@ -1784,7 +1782,7 @@ close_type_seen (tree type)
/* Take a TYPE that has been passed by value to an external function
and mark all of the fields that have pointer types as escaping. For
any of the non pointer types that are structures or unions,
- recurse. TYPE is never a pointer type. */
+ recurse. TYPE is never a pointer type. */
static void
close_type_exposed_parameter (tree type)
@@ -1817,13 +1815,13 @@ close_type_exposed_parameter (tree type)
mark_interesting_type (field_type, EXPOSED_PARAMETER);
/* Only recurse for non pointer types of structures and unions. */
- if (ipa_type_escape_star_count_of_interesting_type (field_type) == 0)
+ if (ipa_type_escape_star_count_of_interesting_type (field_type) == 0)
close_type_exposed_parameter (field_type);
}
}
/* The next function handles the case where a type fully escapes.
- This means that not only does the type itself escape,
+ This means that not only does the type itself escape,
a) the type of every field recursively escapes
b) the type of every subtype escapes as well as the super as well
@@ -1834,7 +1832,7 @@ close_type_exposed_parameter (tree type)
Take a TYPE that has had the address taken for an instance of it
and mark all of the types for its fields as having their addresses
- taken. */
+ taken. */
static void
close_type_full_escape (tree type)
@@ -1845,7 +1843,7 @@ close_type_full_escape (tree type)
tree binfo, base_binfo;
bitmap_iterator bi;
bitmap subtype_map;
- splay_tree_node address_result;
+ splay_tree_node address_result;
/* Strip off any pointer or array types. */
type = get_canon_type (type, true, true);
@@ -1861,7 +1859,7 @@ close_type_full_escape (tree type)
/* If we are doing a language with a type hierarchy, mark all of
the superclasses. */
- if (TYPE_BINFO (type))
+ if (TYPE_BINFO (type))
for (binfo = TYPE_BINFO (type), i = 0;
BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
{
@@ -1869,13 +1867,13 @@ close_type_full_escape (tree type)
binfotype = mark_type (binfotype, FULL_ESCAPE);
close_type_full_escape (binfotype);
}
-
+
/* Mark as escaped any types that have been down casted to
this type. */
if (subtype_map)
EXECUTE_IF_SET_IN_BITMAP (subtype_map, 0, i, bi)
{
- tree subtype = type_for_uid (i);
+ tree subtype = type_for_uid (i);
subtype = mark_type (subtype, FULL_ESCAPE);
close_type_full_escape (subtype);
}
@@ -1900,7 +1898,7 @@ close_type_full_escape (tree type)
/* For all of the types A that contain this type B and were part of
an expression like "&...A.B...", mark the A's as escaping. */
- address_result = splay_tree_lookup (uid_to_addressof_up_map,
+ address_result = splay_tree_lookup (uid_to_addressof_up_map,
(splay_tree_key) uid);
if (address_result)
{
@@ -1914,21 +1912,21 @@ close_type_full_escape (tree type)
/* Transitively close the addressof bitmap for the type with UID.
This means that if we had a.b and b.c, a would have both b and c in
- its maps. */
+ its maps. */
static bitmap
-close_addressof_down (int uid)
+close_addressof_down (int uid)
{
bitmap_iterator bi;
- splay_tree_node result =
+ splay_tree_node result =
splay_tree_lookup (uid_to_addressof_down_map, (splay_tree_key) uid);
bitmap map = NULL;
bitmap new_map;
unsigned int i;
-
- if (result)
+
+ if (result)
map = (bitmap) result->value;
- else
+ else
return NULL;
if (bitmap_bit_p (been_there_done_that, uid))
@@ -1952,9 +1950,9 @@ close_addressof_down (int uid)
{
bitmap submap = close_addressof_down (i);
bitmap_set_bit (new_map, i);
- if (submap)
+ if (submap)
bitmap_ior_into (new_map, submap);
- }
+ }
result->value = (splay_tree_value) new_map;
BITMAP_FREE (map);
@@ -1984,12 +1982,10 @@ type_escape_execute (void)
We do not want to process any of the clones so we check that this
is a master clone. However, we do need to process any
AVAIL_OVERWRITABLE functions (these are never clones) because
- they may cause a type variable to escape.
+ they may cause a type variable to escape.
*/
for (node = cgraph_nodes; node; node = node->next)
- if (node->analyzed
- && (cgraph_is_master_clone (node)
- || (cgraph_function_body_availability (node) == AVAIL_OVERWRITABLE)))
+ if (node->analyzed && !node->clone_of)
analyze_function (node);
@@ -2037,7 +2033,7 @@ type_escape_execute (void)
contained an entry for Y if there had been an operation of the
form &X.Y. This step adds all of the fields contained within Y
(recursively) to X's map. */
-
+
result = splay_tree_min (uid_to_addressof_down_map);
while (result)
{
@@ -2055,7 +2051,7 @@ type_escape_execute (void)
{
tree type = (tree) result->value;
tree key = (tree) result->key;
- if (POINTER_TYPE_P (type)
+ if (POINTER_TYPE_P (type)
|| TREE_CODE (type) == ARRAY_TYPE)
{
splay_tree_remove (all_canon_types, (splay_tree_key) result->key);
@@ -2067,7 +2063,7 @@ type_escape_execute (void)
}
if (dump_file)
- {
+ {
EXECUTE_IF_SET_IN_BITMAP (global_types_seen, 0, i, bi)
{
/* The pointer types are in the global_types_full_escape
@@ -2078,7 +2074,7 @@ type_escape_execute (void)
print_generic_expr (dump_file, type, 0);
if (bitmap_bit_p (global_types_full_escape, i))
fprintf(dump_file, " escaped\n");
- else
+ else
fprintf(dump_file, " contained\n");
}
}
« no previous file with comments | « gcc/gcc/ipa-type-escape.h ('k') | gcc/gcc/ipa-utils.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698