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]

[lto][patch] Avoid creating spurious cgraph nodes while reading expressions


This patch corrects an assertion failure in input_cgraph.  There, we
verify that every cgraph node in the cgraph_nodes list  was given
lto_file_data, which will occur only if every node appeared in the
cgraph as it was streamed in.  In some cases, nodes were previously
added to the cgraph_nodes list when streaming in an ADDR_EXPR that
referenced a function decl, even though no reference to the function
would eventually occur in the generated code.  (E.g., references to
virtual methods from a vtable when the vtable is not emitted in the
current compilation.)   These nodes were added by the call
"cgraph_mark_needed_node (cgraph_node (x));" in lto-function-in.c.  It
appears that references to functions are accounted for by a walk over
the tree with record_reference in cgraphbuild.c, which also invokes
cgraph_mark_needed_node.  The result of this analysis was not
preserved across the streaming interface, as the 'needed' flag was
dropped.    Presumably, this was done because input_overwrite_node in
lto-cgraph.c invokes cgraph_mark_needed_node itself based on the
result of its own invocation of cgraph_decide_is_function_needed.  The
latter function, however, examines the 'needed' flag, among other
factors, in making its determination, and expects it to reflect the
result of earlier analysis.

       * lto-cgraph.c (output_node): Stream out 'needed' flag.
       (input_overwrite_node): Stream in 'needed' flag.
       * lto-function-in.c (input_expr_operand, input_tree_operand):
       Remove call to cgraph_mark_needed_node.

--Bill

Attachment: streamer-cgraph-patch-09-01.txt
Description: Text document


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