aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog20
-rw-r--r--gcc/common.opt4
-rw-r--r--gcc/doc/invoke.texi5
-rw-r--r--gcc/passes.c1
-rw-r--r--gcc/tree-ssa-structalias.c52
5 files changed, 62 insertions, 20 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5814a63..974f56d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,23 @@
+2006-02-19 Daniel Berlin <dberlin@dberlin.org>
+
+ * doc/invoke.texi: Document -fipa-pta.
+ * common.opt: Add ipa-pta option.
+ * tree-ssa-structalias.c (DONT_PROPAGATE_WITH_ANYTHING): Removed.
+ (do_sd_constraint): Enable DONT_PROPAGATE_WITH_ANYTHING code.
+ (do_ds_constraint): Ditto.
+ (get_constraint_for): Only add to referenced_vars if
+ referenced_vars exists.
+ (insert_into_field_list): Rewrite to do this unsorted.
+ (insert_into_field_list_sorted): Rename old insert_into_field_list
+ to this.
+ (create_function_info_for): Use insert_into_field_list_sorted.
+ (create_variable_info_for): Rewrite so it uses unsorted version,
+ since the field list is sorted.
+ (intra_create_variable_infos): Only add to referenced_vars if
+ referenced_vars exists.
+ (ipa_pta_execute): Init heapvars, and delete when done.
+ * passes.c (init_optimization_passes): Add call to pass_ipa_pta.
+
2006-02-19 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
* doc/install.texi: Add missing `@samp'.
diff --git a/gcc/common.opt b/gcc/common.opt
index c7e6899..448c6bc 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -523,6 +523,10 @@ fipa-pure-const
Common Report Var(flag_ipa_pure_const) Init(0)
Discover pure and const functions
+fipa-pta
+Common Report Var(flag_ipa_pta) Init(0)
+Perform interprocedural points-to analysis
+
fipa-reference
Common Report Var(flag_ipa_reference) Init(0)
Discover readonly and non addressable static variables
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 4b8bf59..740ac9b 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -343,7 +343,7 @@ Objective-C and Objective-C++ Dialects}.
-ftree-loop-linear -ftree-loop-im -ftree-loop-ivcanon -fivopts @gol
-ftree-dominator-opts -ftree-dse -ftree-copyrename -ftree-sink @gol
-ftree-ch -ftree-sra -ftree-ter -ftree-lrs -ftree-fre -ftree-vectorize @gol
--ftree-vect-loop-version -ftree-salias -fweb @gol
+-ftree-vect-loop-version -ftree-salias -fipa-pta -fweb @gol
-ftree-copy-prop -ftree-store-ccp -ftree-store-copy-prop -fwhole-program @gol
--param @var{name}=@var{value}
-O -O0 -O1 -O2 -O3 -Os}
@@ -5033,6 +5033,9 @@ default at @option{-O2} and higher.
Perform structural alias analysis on trees. This flag
is enabled by default at @option{-O} and higher.
+@item -fipa-pta
+Perform interprocedural pointer analysis.
+
@item -ftree-sink
Perform forward store motion on trees. This flag is
enabled by default at @option{-O} and higher.
diff --git a/gcc/passes.c b/gcc/passes.c
index 2845ab7..e088be1 100644
--- a/gcc/passes.c
+++ b/gcc/passes.c
@@ -447,6 +447,7 @@ init_optimization_passes (void)
NEXT_PASS (pass_ipa_reference);
NEXT_PASS (pass_ipa_pure_const);
NEXT_PASS (pass_ipa_type_escape);
+ NEXT_PASS (pass_ipa_pta);
*p = NULL;
/* All passes needed to lower the function into shape optimizers can
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c
index c7eae96..e7a9892 100644
--- a/gcc/tree-ssa-structalias.c
+++ b/gcc/tree-ssa-structalias.c
@@ -1535,8 +1535,6 @@ type_safe (unsigned int n, unsigned HOST_WIDE_INT *offset)
return (get_varinfo (n)->offset + *offset) < get_varinfo (n)->fullsize;
}
-#define DONT_PROPAGATE_WITH_ANYTHING 0
-
/* Process a constraint C that represents *x = &y. */
static void
@@ -1593,7 +1591,6 @@ do_sd_constraint (constraint_graph_t graph, constraint_t c,
unsigned int j;
bitmap_iterator bi;
-#if DONT_PROPAGATE_WITH_ANYTHING
if (bitmap_bit_p (delta, anything_id))
{
flag = !bitmap_bit_p (sol, anything_id);
@@ -1601,7 +1598,6 @@ do_sd_constraint (constraint_graph_t graph, constraint_t c,
bitmap_set_bit (sol, anything_id);
goto done;
}
-#endif
/* For each variable j in delta (Sol(y)), add
an edge in the graph from j to x, and union Sol(j) into Sol(x). */
EXECUTE_IF_SET_IN_BITMAP (delta, 0, j, bi)
@@ -1629,9 +1625,8 @@ do_sd_constraint (constraint_graph_t graph, constraint_t c,
fprintf (dump_file, "Untypesafe usage in do_sd_constraint\n");
}
-#if DONT_PROPAGATE_WITH_ANYTHING
+
done:
-#endif
/* If the LHS solution changed, mark the var as changed. */
if (flag)
{
@@ -1655,7 +1650,6 @@ do_ds_constraint (constraint_graph_t graph, constraint_t c, bitmap delta)
unsigned int j;
bitmap_iterator bi;
-#if DONT_PROPAGATE_WITH_ANYTHING
if (bitmap_bit_p (sol, anything_id))
{
EXECUTE_IF_SET_IN_BITMAP (delta, 0, j, bi)
@@ -1683,7 +1677,6 @@ do_ds_constraint (constraint_graph_t graph, constraint_t c, bitmap delta)
}
return;
}
-#endif
/* For each member j of delta (Sol(x)), add an edge from y to j and
union Sol(y) into Sol(j) */
@@ -2538,7 +2531,8 @@ get_constraint_for (tree t, VEC (ce_s, heap) **results)
{
heapvar = create_tmp_var_raw (ptr_type_node, "HEAP");
DECL_EXTERNAL (heapvar) = 1;
- add_referenced_tmp_var (heapvar);
+ if (referenced_vars)
+ add_referenced_tmp_var (heapvar);
heapvar_insert (t, heapvar);
}
@@ -3531,11 +3525,24 @@ first_vi_for_offset (varinfo_t start, unsigned HOST_WIDE_INT offset)
}
+/* Insert the varinfo FIELD into the field list for BASE, at the front
+ of the list. */
+
+static void
+insert_into_field_list (varinfo_t base, varinfo_t field)
+{
+ varinfo_t prev = base;
+ varinfo_t curr = base->next;
+
+ field->next = curr;
+ prev->next = field;
+}
+
/* Insert the varinfo FIELD into the field list for BASE, ordered by
offset. */
static void
-insert_into_field_list (varinfo_t base, varinfo_t field)
+insert_into_field_list_sorted (varinfo_t base, varinfo_t field)
{
varinfo_t prev = base;
varinfo_t curr = base->next;
@@ -3793,6 +3800,7 @@ create_function_info_for (tree decl, const char *name)
arg = DECL_ARGUMENTS (decl);
+
/* Set up variables for each argument. */
for (i = 1; i < vi->fullsize; i++)
{
@@ -3817,7 +3825,7 @@ create_function_info_for (tree decl, const char *name)
argvi->size = 1;
argvi->fullsize = vi->fullsize;
argvi->has_union = false;
- insert_into_field_list (vi, argvi);
+ insert_into_field_list_sorted (vi, argvi);
stats.total_vars ++;
if (arg)
{
@@ -3825,7 +3833,7 @@ create_function_info_for (tree decl, const char *name)
arg = TREE_CHAIN (arg);
}
}
-
+
/* Create a variable for the return var. */
if (DECL_RESULT (decl) != NULL
|| !VOID_TYPE_P (TREE_TYPE (TREE_TYPE (decl))))
@@ -3838,7 +3846,6 @@ create_function_info_for (tree decl, const char *name)
vi->fullsize ++;
-
if (DECL_RESULT (decl))
resultdecl = DECL_RESULT (decl);
@@ -3854,7 +3861,7 @@ create_function_info_for (tree decl, const char *name)
resultvi->size = 1;
resultvi->fullsize = vi->fullsize;
resultvi->has_union = false;
- insert_into_field_list (vi, resultvi);
+ insert_into_field_list_sorted (vi, resultvi);
stats.total_vars ++;
if (DECL_RESULT (decl))
insert_id_for_tree (DECL_RESULT (decl), newindex);
@@ -3991,7 +3998,9 @@ create_variable_info_for (tree decl, const char *name)
vi->size = TREE_INT_CST_LOW (fo->size);
vi->offset = fo->offset;
- for (i = 1; VEC_iterate (fieldoff_s, fieldstack, i, fo); i++)
+ for (i = VEC_length (fieldoff_s, fieldstack) - 1;
+ i >= 1 && VEC_iterate (fieldoff_s, fieldstack, i, fo);
+ i--)
{
varinfo_t newvi;
const char *newname;
@@ -4077,9 +4086,11 @@ intra_create_variable_infos (void)
unsigned int id;
if (heapvar == NULL_TREE)
{
- heapvar = create_tmp_var_raw (TREE_TYPE (TREE_TYPE (t)), "PARM_NOALIAS");
+ heapvar = create_tmp_var_raw (TREE_TYPE (TREE_TYPE (t)),
+ "PARM_NOALIAS");
DECL_EXTERNAL (heapvar) = 1;
- add_referenced_tmp_var (heapvar);
+ if (referenced_vars)
+ add_referenced_tmp_var (heapvar);
heapvar_insert (t, heapvar);
}
id = create_variable_info_for (heapvar,
@@ -4560,6 +4571,7 @@ static bool
gate_ipa_pta (void)
{
return (flag_unit_at_a_time != 0
+ && flag_ipa_pta
/* Don't bother doing anything if the program has errors. */
&& !(errorcount || sorrycount));
}
@@ -4570,9 +4582,9 @@ ipa_pta_execute (void)
{
struct cgraph_node *node;
in_ipa_mode = 1;
-
+ init_alias_heapvars ();
init_alias_vars ();
-
+
for (node = cgraph_nodes; node; node = node->next)
{
if (!node->analyzed || cgraph_is_master_clone (node))
@@ -4658,6 +4670,8 @@ ipa_pta_execute (void)
if (dump_file)
dump_sa_points_to_info (dump_file);
in_ipa_mode = 0;
+ delete_alias_heapvars ();
+ delete_points_to_sets ();
}
struct tree_opt_pass pass_ipa_pta =