#include "basic-block.h"
#include "output.h"
#include "errors.h"
-#include "expr.h"
#include "diagnostic.h"
#include "tree.h"
#include "c-common.h"
static unsigned int changed_count;
static sbitmap changed;
-DEF_VEC_I(uint);
-DEF_VEC_ALLOC_I(uint,heap);
+DEF_VEC_I(unsigned);
+DEF_VEC_ALLOC_I(unsigned,heap);
/* Strongly Connected Component visitation info. */
sbitmap in_component;
int current_index;
unsigned int *visited_index;
- VEC(uint,heap) *scc_stack;
- VEC(uint,heap) *unification_queue;
+ VEC(unsigned,heap) *scc_stack;
+ VEC(unsigned,heap) *unification_queue;
};
{
unsigned int t = si->visited_index[n];
SET_BIT (si->in_component, n);
- while (VEC_length (uint, si->scc_stack) != 0
- && t < si->visited_index[VEC_last (uint, si->scc_stack)])
+ while (VEC_length (unsigned, si->scc_stack) != 0
+ && t < si->visited_index[VEC_last (unsigned, si->scc_stack)])
{
- unsigned int w = VEC_pop (uint, si->scc_stack);
+ unsigned int w = VEC_pop (unsigned, si->scc_stack);
get_varinfo (w)->node = n;
SET_BIT (si->in_component, w);
/* Mark this node for collapsing. */
- VEC_safe_push (uint, heap, si->unification_queue, w);
+ VEC_safe_push (unsigned, heap, si->unification_queue, w);
}
}
else
- VEC_safe_push (uint, heap, si->scc_stack, n);
+ VEC_safe_push (unsigned, heap, si->scc_stack, n);
}
changed rep's solution.
Delete any 0 weighted self-edges we now have for rep. */
- while (i != VEC_length (uint, si->unification_queue))
+ while (i != VEC_length (unsigned, si->unification_queue))
{
- unsigned int tounify = VEC_index (uint, si->unification_queue, i);
+ unsigned int tounify = VEC_index (unsigned, si->unification_queue, i);
unsigned int n = get_varinfo (tounify)->node;
if (dump_file && (dump_flags & TDF_DETAILS))
/* If we've either finished processing the entire queue, or
finished processing all nodes for component n, update the solution for
n. */
- if (i == VEC_length (uint, si->unification_queue)
- || get_varinfo (VEC_index (uint, si->unification_queue, i))->node != n)
+ if (i == VEC_length (unsigned, si->unification_queue)
+ || get_varinfo (VEC_index (unsigned, si->unification_queue, i))->node != n)
{
struct constraint_edge edge;
sbitmap visited;
/* Array that stores the topological order of the graph, *in
reverse*. */
- VEC(uint,heap) *topo_order;
+ VEC(unsigned,heap) *topo_order;
};
struct topo_info *ti = xmalloc (sizeof (struct topo_info));
ti->visited = sbitmap_alloc (size);
sbitmap_zero (ti->visited);
- ti->topo_order = VEC_alloc (uint, heap, 1);
+ ti->topo_order = VEC_alloc (unsigned, heap, 1);
return ti;
}
free_topo_info (struct topo_info *ti)
{
sbitmap_free (ti->visited);
- VEC_free (uint, heap, ti->topo_order);
+ VEC_free (unsigned, heap, ti->topo_order);
free (ti);
}
if (!TEST_BIT (ti->visited, c->dest))
topo_visit (graph, ti, c->dest);
}
- VEC_safe_push (uint, heap, ti->topo_order, n);
+ VEC_safe_push (unsigned, heap, ti->topo_order, n);
}
/* Return true if variable N + OFFSET is a legal field of N. */
si->in_component = sbitmap_alloc (size);
sbitmap_ones (si->in_component);
si->visited_index = xcalloc (sizeof (unsigned int), size + 1);
- si->scc_stack = VEC_alloc (uint, heap, 1);
- si->unification_queue = VEC_alloc (uint, heap, 1);
+ si->scc_stack = VEC_alloc (unsigned, heap, 1);
+ si->unification_queue = VEC_alloc (unsigned, heap, 1);
return si;
}
sbitmap_free (si->visited);
sbitmap_free (si->in_component);
free (si->visited_index);
- VEC_free (uint, heap, si->scc_stack);
- VEC_free (uint, heap, si->unification_queue);
+ VEC_free (unsigned, heap, si->scc_stack);
+ VEC_free (unsigned, heap, si->unification_queue);
free(si);
}
node in topological order. */
compute_topo_order (graph, ti);
- while (VEC_length (uint, ti->topo_order) != 0)
+ while (VEC_length (unsigned, ti->topo_order) != 0)
{
- unsigned int i = VEC_pop (uint, ti->topo_order);
+ unsigned int i = VEC_pop (unsigned, ti->topo_order);
unsigned int pred;
varinfo_t vi = get_varinfo (i);
bool okay_to_elim = false;
compute_topo_order (graph, ti);
- while (VEC_length (uint, ti->topo_order) != 0)
+ while (VEC_length (unsigned, ti->topo_order) != 0)
{
- i = VEC_pop (uint, ti->topo_order);
+ i = VEC_pop (unsigned, ti->topo_order);
gcc_assert (get_varinfo (i)->node == i);
/* If the node has changed, we need to process the
}
+/* Return true if an access to [ACCESSPOS, ACCESSSIZE]
+ overlaps with a field at [FIELDPOS, FIELDSIZE] */
+
+static bool
+offset_overlaps_with_access (const unsigned HOST_WIDE_INT fieldpos,
+ const unsigned HOST_WIDE_INT fieldsize,
+ const unsigned HOST_WIDE_INT accesspos,
+ const unsigned HOST_WIDE_INT accesssize)
+{
+ if (fieldpos == accesspos && fieldsize == accesssize)
+ return true;
+ if (accesspos >= fieldpos && accesspos < (fieldpos + fieldsize))
+ return true;
+ if (accesspos < fieldpos && (accesspos + accesssize > fieldpos))
+ return true;
+
+ return false;
+}
+
/* Given a COMPONENT_REF T, return the constraint_expr for it. */
static struct constraint_expr
we may have to do something cute here. */
if (result.offset < get_varinfo (result.var)->fullsize)
- result.var = first_vi_for_offset (get_varinfo (result.var),
- result.offset)->id;
+ {
+ /* It's also not true that the constraint will actually start at the
+ right offset, it may start in some padding. We only care about
+ setting the constraint to the first actual field it touches, so
+ walk to find it. */
+ varinfo_t curr;
+ for (curr = get_varinfo (result.var); curr; curr = curr->next)
+ {
+ if (offset_overlaps_with_access (curr->offset, curr->size,
+ result.offset, bitsize))
+ {
+ result.var = curr->id;
+ break;
+
+ }
+ }
+ /* assert that we found *some* field there. The user couldn't be
+ accessing *only* padding. */
+
+ gcc_assert (curr);
+ }
else
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "Access to past the end of variable, ignoring\n");
subvar_t svars = get_subvars_for_var (vi->decl);
subvar_t sv;
for (sv = svars; sv; sv = sv->next)
- bitmap_set_bit (into, var_ann (sv->var)->uid);
+ bitmap_set_bit (into, DECL_UID (sv->var));
}
/* We may end up with labels in the points-to set because people
take their address, and they are _DECL's. */
else if (TREE_CODE (vi->decl) == VAR_DECL
|| TREE_CODE (vi->decl) == PARM_DECL)
- bitmap_set_bit (into, var_ann (vi->decl)->uid);
+ bitmap_set_bit (into, DECL_UID (vi->decl));
}