Commit 8971094d by Daniel Berlin Committed by Daniel Berlin

re PR tree-optimization/22615 (ICE in first_vi_for_offset, at tree-ssa-structalias.c:2858)

2005-08-14  Daniel Berlin  <dberlin@dberlin.org>

	Fix PR tree-optimization/22615

	* tree-ssa-structalias.c (solution_set_add): Handle
	first_vi_for_offset returning NULL.
	(do_da_constraint): Ditto.
	(do_sd_constraint): Ditto.
	(do_ds_constraint): Ditto
	(find_func_aliases): Ditto.
	(build_constraint_graph): RHS is allowed be ANYTHING.
	(first_vi_for_offset): Return NULL if we couldn't find anything at
	the offset.

From-SVN: r103083
parent c5b2a111
2005-08-14 Daniel Berlin <dberlin@dberlin.org>
Fix PR tree-optimization/22615
* tree-ssa-structalias.c (solution_set_add): Handle
first_vi_for_offset returning NULL.
(do_da_constraint): Ditto.
(do_sd_constraint): Ditto.
(do_ds_constraint): Ditto
(find_func_aliases): Ditto.
(build_constraint_graph): RHS is allowed be ANYTHING.
(first_vi_for_offset): Return NULL if we couldn't find anything at
the offset.
2005-08-14 Ulrich Weigand <uweigand@de.ibm.com> 2005-08-14 Ulrich Weigand <uweigand@de.ibm.com>
* config/s390/s390.c (s390_canonicalize_comparison): Prefer register * config/s390/s390.c (s390_canonicalize_comparison): Prefer register
......
/* { dg-do compile } */
/* { dg-options "-O2" } */
/* Ensure that we don't crash when people decide to return the address of padding. */
struct A
{
char c;
int i;
};
A a;
struct B
{
char c, d;
};
union C
{
A *p;
B *q;
C() : p(&a) {}
char& foo() { return q->d; }
};
void bar() { C().foo() = 0; }
...@@ -612,6 +612,8 @@ solution_set_add (bitmap set, unsigned HOST_WIDE_INT offset) ...@@ -612,6 +612,8 @@ solution_set_add (bitmap set, unsigned HOST_WIDE_INT offset)
{ {
unsigned HOST_WIDE_INT fieldoffset = get_varinfo (i)->offset + offset; unsigned HOST_WIDE_INT fieldoffset = get_varinfo (i)->offset + offset;
varinfo_t v = first_vi_for_offset (get_varinfo (i), fieldoffset); varinfo_t v = first_vi_for_offset (get_varinfo (i), fieldoffset);
if (!v)
continue;
bitmap_set_bit (result, v->id); bitmap_set_bit (result, v->id);
} }
else if (get_varinfo (i)->is_artificial_var else if (get_varinfo (i)->is_artificial_var
...@@ -997,7 +999,7 @@ build_constraint_graph (void) ...@@ -997,7 +999,7 @@ build_constraint_graph (void)
/* x = &y */ /* x = &y */
bitmap_set_bit (get_varinfo (lhs.var)->solution, rhs.var); bitmap_set_bit (get_varinfo (lhs.var)->solution, rhs.var);
} }
else if (rhs.var > anything_id && lhs.var > anything_id) else if (lhs.var > anything_id)
{ {
/* Ignore 0 weighted self edges, as they can't possibly contribute /* Ignore 0 weighted self edges, as they can't possibly contribute
anything */ anything */
...@@ -1332,6 +1334,8 @@ do_da_constraint (constraint_graph_t graph ATTRIBUTE_UNUSED, ...@@ -1332,6 +1334,8 @@ do_da_constraint (constraint_graph_t graph ATTRIBUTE_UNUSED,
unsigned HOST_WIDE_INT fieldoffset = get_varinfo (j)->offset + offset; unsigned HOST_WIDE_INT fieldoffset = get_varinfo (j)->offset + offset;
v = first_vi_for_offset (get_varinfo (j), fieldoffset); v = first_vi_for_offset (get_varinfo (j), fieldoffset);
if (!v)
continue;
t = v->node; t = v->node;
sol = get_varinfo (t)->solution; sol = get_varinfo (t)->solution;
if (!bitmap_bit_p (sol, rhs)) if (!bitmap_bit_p (sol, rhs))
...@@ -1375,6 +1379,8 @@ do_sd_constraint (constraint_graph_t graph, constraint_t c, ...@@ -1375,6 +1379,8 @@ do_sd_constraint (constraint_graph_t graph, constraint_t c,
unsigned int t; unsigned int t;
v = first_vi_for_offset (get_varinfo (j), fieldoffset); v = first_vi_for_offset (get_varinfo (j), fieldoffset);
if (!v)
continue;
t = v->node; t = v->node;
if (int_add_graph_edge (graph, lhs, t, 0)) if (int_add_graph_edge (graph, lhs, t, 0))
flag |= bitmap_ior_into (sol, get_varinfo (t)->solution); flag |= bitmap_ior_into (sol, get_varinfo (t)->solution);
...@@ -1419,6 +1425,8 @@ do_ds_constraint (constraint_graph_t graph, constraint_t c, bitmap delta) ...@@ -1419,6 +1425,8 @@ do_ds_constraint (constraint_graph_t graph, constraint_t c, bitmap delta)
unsigned HOST_WIDE_INT fieldoffset = get_varinfo (j)->offset + loff; unsigned HOST_WIDE_INT fieldoffset = get_varinfo (j)->offset + loff;
v = first_vi_for_offset (get_varinfo (j), fieldoffset); v = first_vi_for_offset (get_varinfo (j), fieldoffset);
if (!v)
continue;
t = v->node; t = v->node;
if (int_add_graph_edge (graph, t, rhs, roff)) if (int_add_graph_edge (graph, t, rhs, roff))
{ {
...@@ -2878,7 +2886,7 @@ find_func_aliases (tree t, struct alias_info *ai) ...@@ -2878,7 +2886,7 @@ find_func_aliases (tree t, struct alias_info *ai)
OFFSET. OFFSET.
Effectively, walk the chain of fields for the variable START to find the Effectively, walk the chain of fields for the variable START to find the
first field that overlaps with OFFSET. first field that overlaps with OFFSET.
Abort if we can't find one. */ Return NULL if we can't find one. */
static varinfo_t static varinfo_t
first_vi_for_offset (varinfo_t start, unsigned HOST_WIDE_INT offset) first_vi_for_offset (varinfo_t start, unsigned HOST_WIDE_INT offset)
...@@ -2894,8 +2902,7 @@ first_vi_for_offset (varinfo_t start, unsigned HOST_WIDE_INT offset) ...@@ -2894,8 +2902,7 @@ first_vi_for_offset (varinfo_t start, unsigned HOST_WIDE_INT offset)
return curr; return curr;
curr = curr->next; curr = curr->next;
} }
return NULL;
gcc_unreachable ();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment