summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-structalias.c
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2009-11-07 21:33:29 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2009-11-07 21:33:29 +0000
commit4bfcb72d8572d4b608233e6842708021a0a16c0e (patch)
treef494c5d22400a88fca7119cac14a033d67dca658 /gcc/tree-ssa-structalias.c
parent1e4adcfc349ec3fd567987ddbc4e1160c7479a1c (diff)
downloadgcc-4bfcb72d8572d4b608233e6842708021a0a16c0e.tar.gz
2009-11-07 Richard Guenther <rguenther@suse.de>
* tree-ssa-structalias.c (build_succ_graph): Feed stores to anything only to variables that can take pointers. (get_constraint_for_ssa_var): Properly exclude full variables from expanding. (first_vi_for_offset): Avoid overflow in arithmetic. (first_or_preceding_vi_for_offset): Likewise. (count_num_arguments): Fix implementation. (gate_ipa_pta): Do not run when not optimizing. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154002 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-structalias.c')
-rw-r--r--gcc/tree-ssa-structalias.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index 74dc6d2c1ba..619875c048d 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -1269,11 +1269,13 @@ build_succ_graph (void)
}
}
- /* Add edges from STOREDANYTHING to all non-direct nodes. */
+ /* Add edges from STOREDANYTHING to all non-direct nodes that can
+ receive pointers. */
t = find (storedanything_id);
for (i = integer_id + 1; i < FIRST_REF_NODE; ++i)
{
- if (!TEST_BIT (graph->direct_nodes, i))
+ if (!TEST_BIT (graph->direct_nodes, i)
+ && get_varinfo (i)->may_have_pointers)
add_graph_edge (graph, find (i), t);
}
}
@@ -2720,7 +2722,8 @@ get_constraint_for_ssa_var (tree t, VEC(ce_s, heap) **results, bool address_p)
/* If we are not taking the address of the constraint expr, add all
sub-fiels of the variable as well. */
- if (!address_p)
+ if (!address_p
+ && !vi->is_full_var)
{
for (; vi; vi = vi->next)
{
@@ -4032,7 +4035,7 @@ first_vi_for_offset (varinfo_t start, unsigned HOST_WIDE_INT offset)
In that case, however, offset should still be within the size
of the variable. */
if (offset >= start->offset
- && offset < (start->offset + start->size))
+ && (offset - start->offset) < start->size)
return start;
start= start->next;
@@ -4062,7 +4065,7 @@ first_or_preceding_vi_for_offset (varinfo_t start,
directly preceding offset which may be the last field. */
while (start->next
&& offset >= start->offset
- && !(offset < (start->offset + start->size)))
+ && !((offset - start->offset) < start->size))
start = start->next;
return start;
@@ -4286,21 +4289,22 @@ push_fields_onto_fieldstack (tree type, VEC(fieldoff_s,heap) **fieldstack,
static unsigned int
count_num_arguments (tree decl, bool *is_varargs)
{
- unsigned int i = 0;
+ unsigned int num = 0;
tree t;
- for (t = TYPE_ARG_TYPES (TREE_TYPE (decl));
- t;
- t = TREE_CHAIN (t))
- {
- if (TREE_VALUE (t) == void_type_node)
- break;
- i++;
- }
+ /* Capture named arguments for K&R functions. They do not
+ have a prototype and thus no TYPE_ARG_TYPES. */
+ for (t = DECL_ARGUMENTS (decl); t; t = TREE_CHAIN (t))
+ ++num;
+ /* Check if the function has variadic arguments. */
+ for (t = TYPE_ARG_TYPES (TREE_TYPE (decl)); t; t = TREE_CHAIN (t))
+ if (TREE_VALUE (t) == void_type_node)
+ break;
if (!t)
*is_varargs = true;
- return i;
+
+ return num;
}
/* Creation function node for DECL, using NAME, and return the index
@@ -5654,7 +5658,8 @@ struct gimple_opt_pass pass_build_ealias =
static bool
gate_ipa_pta (void)
{
- return (flag_ipa_pta
+ return (optimize
+ && flag_ipa_pta
/* Don't bother doing anything if the program has errors. */
&& !(errorcount || sorrycount));
}