aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.8/gcc/tree-object-size.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.8/gcc/tree-object-size.c')
-rw-r--r--gcc-4.8/gcc/tree-object-size.c48
1 files changed, 27 insertions, 21 deletions
diff --git a/gcc-4.8/gcc/tree-object-size.c b/gcc-4.8/gcc/tree-object-size.c
index 2b8311a6c..6dc971a85 100644
--- a/gcc-4.8/gcc/tree-object-size.c
+++ b/gcc-4.8/gcc/tree-object-size.c
@@ -64,7 +64,7 @@ static void check_for_plus_in_loops_1 (struct object_size_info *, tree,
the subobject (innermost array or field with address taken).
object_sizes[2] is lower bound for number of bytes till the end of
the object and object_sizes[3] lower bound for subobject. */
-static unsigned HOST_WIDE_INT *object_sizes[4];
+static vec<unsigned HOST_WIDE_INT> object_sizes[4];
/* Bitmaps what object sizes have been computed already. */
static bitmap computed[4];
@@ -493,7 +493,7 @@ compute_builtin_object_size (tree ptr, int object_size_type)
if (TREE_CODE (ptr) == SSA_NAME
&& POINTER_TYPE_P (TREE_TYPE (ptr))
- && object_sizes[object_size_type] != NULL)
+ && computed[object_size_type] != NULL)
{
if (!bitmap_bit_p (computed[object_size_type], SSA_NAME_VERSION (ptr)))
{
@@ -501,6 +501,8 @@ compute_builtin_object_size (tree ptr, int object_size_type)
bitmap_iterator bi;
unsigned int i;
+ if (num_ssa_names > object_sizes[object_size_type].length ())
+ object_sizes[object_size_type].safe_grow (num_ssa_names);
if (dump_file)
{
fprintf (dump_file, "Computing %s %sobject size for ",
@@ -1162,12 +1164,12 @@ init_object_sizes (void)
{
int object_size_type;
- if (object_sizes[0])
+ if (computed[0])
return;
for (object_size_type = 0; object_size_type <= 3; object_size_type++)
{
- object_sizes[object_size_type] = XNEWVEC (unsigned HOST_WIDE_INT, num_ssa_names);
+ object_sizes[object_size_type].safe_grow (num_ssa_names);
computed[object_size_type] = BITMAP_ALLOC (NULL);
}
@@ -1184,9 +1186,8 @@ fini_object_sizes (void)
for (object_size_type = 0; object_size_type <= 3; object_size_type++)
{
- free (object_sizes[object_size_type]);
+ object_sizes[object_size_type].release ();
BITMAP_FREE (computed[object_size_type]);
- object_sizes[object_size_type] = NULL;
}
}
@@ -1202,16 +1203,9 @@ compute_object_sizes (void)
gimple_stmt_iterator i;
for (i = gsi_start_bb (bb); !gsi_end_p (i); gsi_next (&i))
{
- tree callee, result;
+ tree result;
gimple call = gsi_stmt (i);
-
- if (gimple_code (call) != GIMPLE_CALL)
- continue;
-
- callee = gimple_call_fndecl (call);
- if (!callee
- || DECL_BUILT_IN_CLASS (callee) != BUILT_IN_NORMAL
- || DECL_FUNCTION_CODE (callee) != BUILT_IN_OBJECT_SIZE)
+ if (!gimple_call_builtin_p (call, BUILT_IN_OBJECT_SIZE))
continue;
init_object_sizes ();
@@ -1240,20 +1234,32 @@ compute_object_sizes (void)
continue;
}
+ gcc_assert (TREE_CODE (result) == INTEGER_CST);
+
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "Simplified\n ");
print_gimple_stmt (dump_file, call, 0, dump_flags);
+ fprintf (dump_file, " to ");
+ print_generic_expr (dump_file, result, 0);
+ fprintf (dump_file, "\n");
}
- if (!update_call_from_tree (&i, result))
- gcc_unreachable ();
+ tree lhs = gimple_call_lhs (call);
+ if (!lhs)
+ continue;
- if (dump_file && (dump_flags & TDF_DETAILS))
+ /* Propagate into all uses and fold those stmts. */
+ gimple use_stmt;
+ imm_use_iterator iter;
+ FOR_EACH_IMM_USE_STMT (use_stmt, iter, lhs)
{
- fprintf (dump_file, "to\n ");
- print_gimple_stmt (dump_file, gsi_stmt (i), 0, dump_flags);
- fprintf (dump_file, "\n");
+ use_operand_p use_p;
+ FOR_EACH_IMM_USE_ON_STMT (use_p, iter)
+ SET_USE (use_p, result);
+ gimple_stmt_iterator gsi = gsi_for_stmt (use_stmt);
+ fold_stmt (&gsi);
+ update_stmt (gsi_stmt (gsi));
}
}
}