This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[tree-ssa] Operand management II


This is the follow on patch to the operand management rework.

This puts all the operand memory back into the GC arena.  The various
types of operands are now implemented like varrays, as a dynamic
stucture with a size first, then a list of elements.  I've also removed
the operand_t and voperand_t elements from the stmt annotation, and
replaced it with 4 direct references to the operand types. 

So we use to have a pointer to an operand structure, and a pointer to a
virtual_operand structure.  Each of those structures had pointers to a
def and use list.There is now less indirection. 

This makes the stmt annloation larger by 8 words, but the measurements I
did last week indicated that 50% of all stmts had either a use or a def,
and a further 50% has either a virtual use or def.  So in the end, we
are using less memory since we dont have to allocate any indirect
structures. Fromt he annotation, you have a poinmter directly to the
various operand type.


Now, I've discovered something very interesting along the way. The SSA
verifier is not catching all the problems we have. In fact, when I first
enabled this, I had 45 more failures in the gcc testsuite, all due to
the verifier.

It turns out that an optimization can do something incorrect, like
remove a VDEF which still has uses, and the verifier may not catch it
because when it looks at SSA_NAE_DEF_STMT(ssa_name), it still points to
the old VDEF which was deleted.  AS long as that memory hasn't been
stomped on, it still looks fine. Ahhhh. So what was happening, I was
freeing an operand, overwriting the first word to use as a 'next'
pointer, and voila, it triggers the ssa verifier since it is no longer
correct.

What Ive done is disable the free list for the moment, so I can check in
this patch (its #if 0'd out in 2 places). When I have time, (or if
anyone else is interested in opening bugzilla cases :-), you can turn it
on and investigate the failures which result.  It might even be worth
while changing the code in 'add_optype_freelist()' to always write some
value into the first word when ENABLE_CHECKING is on, which will help to
trigger more of these incorrect cases depending on non-destroyed memory.
 
There is also a very minor bug in tree-ssa-dom.c::cprop_into_stmt that I
missed the first time through and have fixed.

So, this all bootstrapped on x86, passes all the testcases, etc, and I'm
checking it in.  

As a side note, this actually causes a fairly minor reduction in the
speed gained by the original patch, primarily due to the fact that GC is
doing more than it was when I was managing my own memory. It has to
allocate and mark more than it did. Ah well, its fairly minor, and its
still a lot better than it was.

Andrew

2003-12-16  Andrew MacLeod  <amacleod@redhat.com>

	* tree-flow-inline.h (free_vuse, free_vdefs): Moved to 
	tree-ssa-operands.c
	(get_def_ops, get_use_ops, get_vdef_ops, get_vuse_ops): Use the new 
	more direct structure pointer.
	(get_use_op_ptr, get_def_op_ptr): Cast is no longer necessary.
	* tree-flow.h (struct stmt_ann_d): Replace operands and voperands 
	pointers with pointers directly to the operand types.
	* tree-ssa-dom.c (cprop_into_stmt): Use new stmt based interface to 
	free virtual operands.  Check virtual bases of both VUSE and VDEF.
	* tree-ssa-operands.c (struct voperands_d): Declare here, used only
	for previous_vops during stmt operand construction.
	(struct vecmanage_d, vecmanage_add_segmen, vecmanage_add_special,
	vecmanage_init, vecmanage_tree_ptr_init, vecmanage_fini, check_free,
	vecmanage_new_vector, vecmanage_new_tree_ptr_vector, 
	vecmanage_free_vector): Remove.
	(allocate_ssa_op_vec, free_ssa_op_vec, allocate_ssa_virtual_op_vec, 
	allocate_operands_t, allocate_voperands_t): Remove.
	(finalize_new_ssa_operands, inalize_new_ssa_virtual_operand): Remove.
	(struct freelist_d): New. List of free operand structures.
	(check_optype_freelist): New. Choose memory from freelist, if available.
	(add_optype_freelist): New. Add structure to freelist, if appropriate.
	(allocate_def_optype): New. Allocate a def operand list from GC.
	(allocate_use_optype): New. Allocate a useoperand list from GC.
	(allocate_vdef_optype): New. Allocate a vdef operand list from GC.
	(allocate_vuse_optype): New. Allocate a vuse operand list from GC.
	(free_uses, free_defs, free_vuses, free_vdefs): Use GC and the freelist.
	(remove_vuses, remove_vdefs): New.  External interface to remove virtual
	operands.
	(init_ssa_operands, fini_ssa_operands): Ensure the free list is empty.
	(finalize_ssa_defs, finalize_ssa_use, finalize_ssa_vdefs, 
	finalize_ssa_vuses): Use new direct pointers from the stmt annotation.
	(append_vdef, append_vuse): No need to hack prev_vops pointer now.
	(get_stmt_operands): use new freeing interface, keep previous vops in
	their own local structure for now, passing its address around.
	* tree-ssa-operands.h (struct def_optype_d, struct use_optype_d,
	struct vdef_optype_d, struct vuse_optype_d): Implement as a single
	dynamically allocated structure.
	(struct operands_d, struct operands_d): Remove.
	* tree-ssa-pre.c (subst_phis): Remove virtual operands using new funcs.









Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]