Mercurial > hg > CbC > CbC_gcc
diff gcc/ipa-type-escape.c @ 55:77e2b8dfacca gcc-4.4.5
update it from 4.4.3 to 4.5.0
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 12 Feb 2010 23:39:51 +0900 |
parents | a06113de4d67 |
children | b7f97abdc517 |
line wrap: on
line diff
--- a/gcc/ipa-type-escape.c Sun Feb 07 18:28:00 2010 +0900 +++ b/gcc/ipa-type-escape.c Fri Feb 12 23:39:51 2010 +0900 @@ -43,10 +43,10 @@ #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 @@ 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 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 @@ 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 @@ } 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 @@ /* 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 @@ int value = strcmp(k1->name, k2->name); if (value == 0) return k2->seq - k1->seq; - else + else return value; } @@ -281,7 +281,7 @@ case VECTOR_TYPE: case VOID_TYPE: return true; - + default: return false; } @@ -291,7 +291,7 @@ 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 @@ 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 @@ 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 @@ } /* 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 @@ } /* 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 @@ { 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 @@ 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 @@ 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 @@ 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 @@ /* 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 @@ 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 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ /* 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 @@ { 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 @@ 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 @@ 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 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ { if (!def_stmt || !var) return false; - + if (gimple_code (def_stmt) == GIMPLE_PHI) return false; @@ -812,13 +812,13 @@ 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, 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ /* 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 @@ { 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 @@ /* 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 @@ 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); } } @@ -1080,7 +1080,7 @@ /* 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 @@ 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_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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ /* 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 @@ 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 @@ 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 @@ 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,14 +1327,14 @@ 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))) @@ -1352,15 +1349,15 @@ 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. */ @@ -1373,15 +1370,15 @@ { 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 +1387,7 @@ 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 +1415,10 @@ 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 +1427,7 @@ /* 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 +1446,28 @@ 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 +1493,7 @@ /* 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 +1574,22 @@ 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 +1600,8 @@ /* 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 +1629,7 @@ 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 +1654,11 @@ 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 +1680,7 @@ 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 +1695,31 @@ 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 +1751,17 @@ /* 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 +1781,7 @@ /* 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 +1814,13 @@ 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 +1831,7 @@ 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 +1842,7 @@ 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 +1858,7 @@ /* 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 +1866,13 @@ 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 +1897,7 @@ /* 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 +1911,21 @@ /* 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 +1949,9 @@ { 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 +1981,10 @@ 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) analyze_function (node); @@ -2037,7 +2032,7 @@ 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 +2050,7 @@ { 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 +2062,7 @@ } 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 +2073,7 @@ 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"); } }