[lto][patch] Avoid stale references to tree nodes discarded by declaration merging
Bill Maddox
maddox@google.com
Wed Aug 20 05:51:00 GMT 2008
When streaming in types and declarations, it is possible to resolve
references to a
type or declaration while it is still under construction. (This may
occur either due to
trivial self-reference, or longer cycles in the IR, which, despite our
sloppy terminology,
is not a tree at all.) When a declaration is fully internalized, it
may be merged with
an existing declaration. In this case, the older declaration node is
modified if necessary
to conform to the desired merged result, and the new node just created
is discarded.
Future references at the same global vector index will now resolve to
the merged result.
Any references that have already been resolved, however, will continue
to point to the
old node. Besides its incorrect semantics, this situation was causing
memory corruption
and segfaults due to the use of ggc_free to aggressively release the
discarded nodes.
This patch implements a backpatching scheme so that the
previously-resolved references
may be corrected.
2008-08-19 Bill Maddox <maddox@google.com>
* lto-tree-flags.def: Stream private_flag for
PARM_DECL and RESULT_DECL.
* lto-function-out.c (output_type): Use debug token
"fields" for unions as well as records.
* lto-function-in.c (typedef tree_ptr): New.
Also, declared vec.h-style vector of same.
(global_vector_enter): Added need_fixups parameter,
and code to mark vector entry for backpatching.
(global_vector_fixup): Implement backpatching of
references to the replaced vector entry. Add comments.
Call ggc_free on the replaced node.
(input_field_decl, input_function_decl, input_var_decl,
input_parm_decl, input_result_decl, input_type_decl,
input_namespace_decl, input_translation_unit_decl,
input_binfo, input_type): Use new API for reading
backpatchable fields.
(input_type): Use debug token "fields" for unions
as well as records.
(input_tree_operand): Assert if reference is resolved
to a backpatchable node without providing a location
to backpatch. Add comment. Allow for backpatching
of operands of TREE_VEC, TREE_LIST, and various
expression operators.
(input_tree): Added slot parameter, providing location
to backpatch. Added code to register this location
for backpatching if needed.
* lto-tree-in.h (input_tree): Added slot parameter
to function prototype.
* lto.c (lto_read_decls): Provide dummy argument to input_tree
to conform to its new signature.
* lto-symtab.c (lto_symtab_merge_decl): Do not invoke ggc_free
on discarded node here, now called in global_vector_fixup.
--Bill
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: streamer-fixup-patch-08-19.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20080820/0f772c44/attachment.txt>
More information about the Gcc-patches
mailing list