cgraph: Move next/previous from symtab to toplevel_node [PR122955]
Currently the GC marker functions don't support chain_next on non-toplevel
tag structures (and does not error out either). So since
r16-4747-g529c25ed6e0a06
if there are a lot of chained symtab_nodes (happens most likely with LTO), the GC
marker function could cause a stack overflow because of the recusive nature of the marker.
This fixes the problem by moving next/previous to toplevel_node. I had originally
thought about doing chain_next/chain_prev and using is_a<symtab_node *> to get if
it was symtab_node and then used the next/previous from there. But it was noticed that
asm_node had a next too (though not using chain_next) so adding a previous is not going
to much more space anyways; there will not be many toplevel inline-asm anyways.
Bootstraped and tested on x86_64-linux-gnu.
PR ipa/122955
gcc/ChangeLog:
* cgraph.h (toplevel_node): Add next and previous fields.
Add chain_next and chain_prev to GTY.
(symtab_node): Remove next and previous field. Remove chain_next and chain_prev
from the GTY.
(asm_node): Remove next field.
(symtab_node::next_defined_symbol): Use save_as_a<symtab_node*> around next.
(symbol_table::unregister): Likewise
(FOR_EACH_SYMBOL): Likewise
(symbol_table::first_defined_symbol): Likewise
(symbol_table::first_variable): Likewise
(symbol_table::next_variable): Likewise
(symbol_table::first_static_initializer): Likewise
(symbol_table::next_static_initializer): Likewise
(symbol_table::first_defined_variable): Likewise
(symbol_table::next_defined_variable): Likewise
(symbol_table::first_defined_function): Likewise
(symbol_table::next_defined_function): Likewise
(symbol_table::first_function): Likewise
(symbol_table::next_function): Likewise
(symbol_table::first_function_with_gimple_body): Likewise
(symbol_table::next_function_with_gimple_body): Likewise
* cgraphunit.cc (analyze_functions): Likewise
(output_in_order): Likewise
* lto-streamer-out.cc (lto_output): Use save_as_a<asm_node*> around next.
* symtab.cc (symtab_node::verify_symtab_nodes): Likewise.
gcc/lto/ChangeLog:
* lto-partition.cc (lto_1_to_1_map): Use save_as_a<asm_node*> around next.
(create_asm_partition): Likewise.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>