/* Set for building all the VUSE operands. */
static VEC(tree,heap) *build_vuses;
+/* Bitmap obstack for our datastructures that needs to survive across
+ compilations of multiple functions. */
+static bitmap_obstack operands_bitmap_obstack;
/* Set for building all the loaded symbols. */
static bitmap build_loads;
#define OP_SIZE_2 110
#define OP_SIZE_3 511
-/* Current size of the operand memory buffer. */
-static unsigned int ssa_operand_mem_size;
-
/* Initialize the operand cache routines. */
void
build_uses = VEC_alloc (tree, heap, 10);
build_vuses = VEC_alloc (tree, heap, 25);
build_vdefs = VEC_alloc (tree, heap, 25);
- build_loads = BITMAP_ALLOC (NULL);
- build_stores = BITMAP_ALLOC (NULL);
+ bitmap_obstack_initialize (&operands_bitmap_obstack);
+ build_loads = BITMAP_ALLOC (&operands_bitmap_obstack);
+ build_stores = BITMAP_ALLOC (&operands_bitmap_obstack);
scb_stack = VEC_alloc (scb_t, heap, 20);
}
gcc_assert (gimple_ssa_operands (cfun)->operand_memory == NULL);
gcc_assert (gimple_ssa_operands (cfun)->mpt_table == NULL);
- gimple_ssa_operands (cfun)->operand_memory_index = ssa_operand_mem_size;
+ gimple_ssa_operands (cfun)->operand_memory_index
+ = gimple_ssa_operands (cfun)->ssa_operand_mem_size;
gimple_ssa_operands (cfun)->ops_active = true;
memset (&clobber_stats, 0, sizeof (clobber_stats));
init_vop_buckets ();
- ssa_operand_mem_size = OP_SIZE_INIT;
+ gimple_ssa_operands (cfun)->ssa_operand_mem_size = OP_SIZE_INIT;
}
gimple_ssa_operands (cfun)->ops_active = false;
+ if (!n_initialized)
+ bitmap_obstack_release (&operands_bitmap_obstack);
if (dump_file && (dump_flags & TDF_STATS))
{
fprintf (dump_file, "Original clobbered vars: %d\n",
char *ptr;
if (gimple_ssa_operands (cfun)->operand_memory_index + size
- >= ssa_operand_mem_size)
+ >= gimple_ssa_operands (cfun)->ssa_operand_mem_size)
{
struct ssa_operand_memory_d *ptr;
- if (ssa_operand_mem_size == OP_SIZE_INIT)
- ssa_operand_mem_size = OP_SIZE_1 * sizeof (struct voptype_d);
+ if (gimple_ssa_operands (cfun)->ssa_operand_mem_size == OP_SIZE_INIT)
+ gimple_ssa_operands (cfun)->ssa_operand_mem_size
+ = OP_SIZE_1 * sizeof (struct voptype_d);
else
- if (ssa_operand_mem_size == OP_SIZE_1 * sizeof (struct voptype_d))
- ssa_operand_mem_size = OP_SIZE_2 * sizeof (struct voptype_d);
+ if (gimple_ssa_operands (cfun)->ssa_operand_mem_size
+ == OP_SIZE_1 * sizeof (struct voptype_d))
+ gimple_ssa_operands (cfun)->ssa_operand_mem_size
+ = OP_SIZE_2 * sizeof (struct voptype_d);
else
- ssa_operand_mem_size = OP_SIZE_3 * sizeof (struct voptype_d);
+ gimple_ssa_operands (cfun)->ssa_operand_mem_size
+ = OP_SIZE_3 * sizeof (struct voptype_d);
/* Go right to the maximum size if the request is too large. */
- if (size > ssa_operand_mem_size)
- ssa_operand_mem_size = OP_SIZE_3 * sizeof (struct voptype_d);
+ if (size > gimple_ssa_operands (cfun)->ssa_operand_mem_size)
+ gimple_ssa_operands (cfun)->ssa_operand_mem_size
+ = OP_SIZE_3 * sizeof (struct voptype_d);
- /* Fail if there is not enough space. If thre are this many operands
- required, first make sure there isn't a different probem causing this
+ /* Fail if there is not enough space. If there are this many operands
+ required, first make sure there isn't a different problem causing this
many operands. If the decision is that this is OK, then we can
specially allocate a buffer just for this request. */
- gcc_assert (size <= ssa_operand_mem_size);
+ gcc_assert (size <= gimple_ssa_operands (cfun)->ssa_operand_mem_size);
ptr = (struct ssa_operand_memory_d *)
ggc_alloc (sizeof (struct ssa_operand_memory_d)
- + ssa_operand_mem_size - 1);
+ + gimple_ssa_operands (cfun)->ssa_operand_mem_size - 1);
ptr->next = gimple_ssa_operands (cfun)->operand_memory;
gimple_ssa_operands (cfun)->operand_memory = ptr;
gimple_ssa_operands (cfun)->operand_memory_index = 0;
/* Return a virtual op pointer with NUM elements which are all initialized to OP
- and are linked into the immeidate uses for STMT. The new vop is appended
+ and are linked into the immediate uses for STMT. The new vop is appended
after PREV. */
static inline voptype_p
if (!bitmap_empty_p (build_stores))
{
if (ann->operands.stores == NULL)
- ann->operands.stores = BITMAP_ALLOC (NULL);
+ ann->operands.stores = BITMAP_ALLOC (&operands_bitmap_obstack);
bitmap_copy (ann->operands.stores, build_stores);
}
if (!bitmap_empty_p (build_loads))
{
if (ann->operands.loads == NULL)
- ann->operands.loads = BITMAP_ALLOC (NULL);
+ ann->operands.loads = BITMAP_ALLOC (&operands_bitmap_obstack);
bitmap_copy (ann->operands.loads, build_loads);
}
aliases = v_ann->may_aliases;
if (aliases == NULL)
{
+ if (s_ann && !gimple_aliases_computed_p (cfun))
+ s_ann->has_volatile_ops = true;
/* The variable is not aliased or it is an alias tag. */
if (flags & opf_def)
append_vdef (var);
stmt_ann_t s_ann = stmt_ann (stmt);
s_ann->references_memory = true;
+ if (s_ann && TREE_THIS_VOLATILE (expr))
+ s_ann->has_volatile_ops = true;
if (SSA_VAR_P (ptr))
{
if (v_ann->symbol_mem_tag)
add_virtual_operand (v_ann->symbol_mem_tag, s_ann, flags,
full_ref, offset, size, false);
+ /* Aliasing information is missing; mark statement as volatile so we
+ won't optimize it out too actively. */
+ else if (s_ann && !gimple_aliases_computed_p (cfun)
+ && (flags & opf_def))
+ s_ann->has_volatile_ops = true;
}
}
else if (TREE_CODE (ptr) == INTEGER_CST)
makes no memory references. */
ann->has_volatile_ops = false;
ann->references_memory = false;
+ /* Just clear the bitmap so we don't end up reallocating it over and over. */
+ if (ann->addresses_taken)
+ bitmap_clear (ann->addresses_taken);
start_ssa_stmt_operands ();
parse_ssa_operands (stmt);
operand_build_sort_virtual (build_vdefs);
finalize_ssa_stmt_operands (stmt);
+ if (ann->addresses_taken && bitmap_empty_p (ann->addresses_taken))
+ ann->addresses_taken = NULL;
/* For added safety, assume that statements with volatile operands
also reference memory. */
if (ann->has_volatile_ops)
if (LOADED_SYMS (src))
{
- dest_ann->operands.loads = BITMAP_ALLOC (NULL);
+ dest_ann->operands.loads = BITMAP_ALLOC (&operands_bitmap_obstack);
bitmap_copy (dest_ann->operands.loads, LOADED_SYMS (src));
}
if (STORED_SYMS (src))
{
- dest_ann->operands.stores = BITMAP_ALLOC (NULL);
+ dest_ann->operands.stores = BITMAP_ALLOC (&operands_bitmap_obstack);
bitmap_copy (dest_ann->operands.stores, STORED_SYMS (src));
}
MTAG_GLOBAL (mpt) = 1;
add_referenced_var (mpt);
VEC_safe_push (tree, heap, gimple_ssa_operands (cfun)->mpt_table, mpt);
- MPT_SYMBOLS (mpt) = BITMAP_ALLOC (NULL);
+ MPT_SYMBOLS (mpt) = BITMAP_ALLOC (&operands_bitmap_obstack);
set_memory_partition (sym, mpt);
}