https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70594
--- Comment #38 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Surprisingly, the actual problem is with __builtin_unreachable. I've instrumented symbol_table::register_symbol, so that it logs this->order and node->name () after assigning node->order, and get: /tmp/orders1:3583 void __builtin_unreachable() /tmp/orders1:3718 void __builtin_unreachable() /tmp/orders1:4151 void __builtin_unreachable() /tmp/orders1:4448 void __builtin_unreachable() /tmp/orders2:3583 void __builtin_unreachable() /tmp/orders2:3718 void __builtin_unreachable() /tmp/orders2:4447 void __builtin_unreachable() the node->order = 4151 case is the one that happens just in one of the copies. The backtrace for that node->order = 4151 is: #0 0x0000000000b305f2 in symbol_table::register_symbol (this=0x7ffff15a10a8, node=0x7fffee1cbb80) at ../../gcc/cgraph.h:2455 #1 0x0000000000b2a530 in symtab_node::register_symbol (this=0x7fffee1cbb80) at ../../gcc/symtab.c:375 #2 0x0000000000b358b5 in cgraph_node::create (decl=<function_decl 0x7ffff1673000 __builtin_unreachable>) at ../../gcc/cgraph.c:507 #3 0x0000000000b359db in cgraph_node::get_create (decl=<function_decl 0x7ffff1673000 __builtin_unreachable>) at ../../gcc/cgraph.c:529 #4 0x0000000000cfd123 in gimple_get_virt_method_for_vtable (token=2, v=<var_decl 0x7fffeeacdd80 CENSORED>, offset=256, can_refer=0x7fffffffa0de) at ../../gcc/gimple-fold.c:5758 #5 0x0000000000cfd1c5 in gimple_get_virt_method_for_binfo (token=2, known_binfo=<tree_binfo 0x7fffee9aed80>, can_refer=0x7fffffffa0de) at ../../gcc/gimple-fold.c:5789 #6 0x0000000000db27a9 in possible_polymorphic_call_targets (otr_type=<record_type 0x7fffef6873f0 CENSORED>, otr_token=2, context=..., completep=0x7fffffffa2e7, cache_token=0x0, speculative=false) at ../../gcc/ipa-devirt.c:3164 #7 0x0000000001247bb3 in eliminate_dom_walker::before_dom_children (this=0x7fffffffa5b0, b=<basic_block 0x7fffed94c888 (20)>) at ../../gcc/tree-ssa-pre.c:4311 #8 0x0000000001944f05 in dom_walker::walk (this=0x7fffffffa5b0, bb=<basic_block 0x7fffed94c888 (20)>) at ../../gcc/domwalk.c:265 #9 0x00000000012484a5 in eliminate (do_pre=false) at ../../gcc/tree-ssa-pre.c:4464 #10 0x00000000012492cb in (anonymous namespace)::pass_fre::execute (this=0x27c9030, fun=0x7fffeea73930) at ../../gcc/tree-ssa-pre.c:4900 #11 0x0000000000f3d84c in execute_one_pass (pass=<opt_pass* 0x27c9030 "fre"(39)>) at ../../gcc/passes.c:2336 #12 0x0000000000f3db82 in execute_pass_list_1 (pass=<opt_pass* 0x27c9030 "fre"(39)>) at ../../gcc/passes.c:2420 #13 0x0000000000f3dbb3 in execute_pass_list_1 (pass=<opt_pass* 0x27c8d70 "early_optimizations"(33)>) at ../../gcc/passes.c:2421 #14 0x0000000000f3dc0b in execute_pass_list (fn=0x7fffeea73930, pass=<opt_pass* 0x27c8bf0 "fixup_cfg"(30)>) at ../../gcc/passes.c:2431 #15 0x0000000000f3c19f in do_per_function_toporder (callback=0xf3dbce <execute_pass_list(function*, opt_pass*)>, data=0x27c8bf0) at ../../gcc/passes.c:1725 #16 0x0000000000f3e7f0 in execute_ipa_pass_list (pass=<opt_pass* 0x27c8b90 "opt_local_passes"(29)>) at ../../gcc/passes.c:2773 #17 0x0000000000b4a7b9 in ipa_passes () at ../../gcc/cgraphunit.c:2265 #18 0x0000000000b4ac2d in symbol_table::compile (this=0x7ffff15a10a8) at ../../gcc/cgraphunit.c:2404 #19 0x0000000000b4afd4 in symbol_table::finalize_compilation_unit (this=0x7ffff15a10a8) at ../../gcc/cgraphunit.c:2564 #20 0x00000000010513f1 in compile_file () at ../../gcc/toplev.c:490 #21 0x0000000001053948 in do_compile () at ../../gcc/toplev.c:1988 #22 0x0000000001053bcc in toplev::main (this=0x7fffffffddf0, argc=32, argv=0x7fffffffdef8) at ../../gcc/toplev.c:2096 #23 0x0000000001a438a6 in main (argc=32, argv=0x7fffffffdef8) at ../../gcc/main.c:39 I'm really puzzled by multiple cgraph nodes being created for __builtin_unreachable, that really should be the same decl each time. The function in which this happens is not constexpr BTW. I see the __builtin_unreachable first registered through: #0 symbol_table::register_symbol (this=0x7ffff15a10a8, node=0x7fffed8e28a0) at ../../gcc/cgraph.h:2448 #1 0x0000000000b2a530 in symtab_node::register_symbol (this=0x7fffed8e28a0) at ../../gcc/symtab.c:375 #2 0x0000000000b358b5 in cgraph_node::create (decl=<function_decl 0x7ffff1673000 __builtin_unreachable>) at ../../gcc/cgraph.c:507 #3 0x0000000000b359db in cgraph_node::get_create (decl=<function_decl 0x7ffff1673000 __builtin_unreachable>) at ../../gcc/cgraph.c:529 #4 0x0000000000cfd123 in gimple_get_virt_method_for_vtable (token=2, v=<var_decl 0x7fffeeacdd80 CENSORED>, offset=256, can_refer=0x7fffffffae1e) at ../../gcc/gimple-fold.c:5758 #5 0x0000000000cfd1c5 in gimple_get_virt_method_for_binfo (token=2, known_binfo=<tree_binfo 0x7fffee9aed80>, can_refer=0x7fffffffae1e) at ../../gcc/gimple-fold.c:5789 #6 0x0000000000db27a9 in possible_polymorphic_call_targets (otr_type=<record_type 0x7fffef6873f0 CENSORED>, otr_token=2, context=..., completep=0x7fffffffb00f, cache_token=0x0, speculative=false) at ../../gcc/ipa-devirt.c:3164 #7 0x0000000000cfee70 in possible_polymorphic_call_targets (ref=<obj_type_ref 0x7fffeee1bd50>, call=<gimple_call 0x7fffed95fd80>, completep=0x7fffffffb00f, cache_token=0x0) at ../../gcc/ipa-utils.h:131 #8 0x0000000000cf4237 in gimple_fold_call (gsi=0x7fffffffb350, inplace=false) at ../../gcc/gimple-fold.c:3027 #9 0x0000000000cf6e9b in fold_stmt_1 (gsi=0x7fffffffb350, inplace=false, valueize=0xcf746d <no_follow_ssa_edges(tree_node*)>) at ../../gcc/gimple-fold.c:3726 #10 0x0000000000cf74e7 in fold_stmt (gsi=0x7fffffffb350) at ../../gcc/gimple-fold.c:3854 #11 0x0000000000d1572d in maybe_fold_stmt (gsi=0x7fffffffb350) at ../../gcc/gimplify.c:2336 during gimplification, then #1 0x0000000000b3e9d6 in symbol_table::release_symbol (this=0x7ffff15a10a8, node=<error reading variable: Cannot access memory at address 0x20>, uid=3301) at ../../gcc/cgraph.h:2514 #2 0x0000000000b3972a in cgraph_node::remove (this=<error reading variable: Cannot access memory at address 0x20>) at ../../gcc/cgraph.c:1896 #3 0x0000000000b2a7cd in symtab_node::remove (this=0x7fffed8e28a0) at ../../gcc/symtab.c:447 #4 0x0000000000b46ee6 in analyze_functions (first_time=true) at ../../gcc/cgraphunit.c:1199 #5 0x0000000000b4af4f in symbol_table::finalize_compilation_unit (this=0x7ffff15a10a8) at ../../gcc/cgraphunit.c:2542 #6 0x00000000010513f1 in compile_file () at ../../gcc/toplev.c:490 throws away that cgraph node, then created again: #0 symbol_table::register_symbol (this=0x7ffff15a10a8, node=0x7ffff16e7450) at ../../gcc/cgraph.h:2448 #1 0x0000000000b2a530 in symtab_node::register_symbol (this=0x7ffff16e7450) at ../../gcc/symtab.c:375 #2 0x0000000000b358b5 in cgraph_node::create (decl=<function_decl 0x7ffff1673000 __builtin_unreachable>) at ../../gcc/cgraph.c:507 #3 0x0000000000b359db in cgraph_node::get_create (decl=<function_decl 0x7ffff1673000 __builtin_unreachable>) at ../../gcc/cgraph.c:529 #4 0x0000000000cfd123 in gimple_get_virt_method_for_vtable (token=2, v=<var_decl 0x7fffeeacdd80 CENSORED>, offset=256, can_refer=0x7fffffffd83e) at ../../gcc/gimple-fold.c:5758 #5 0x0000000000cfd1c5 in gimple_get_virt_method_for_binfo (token=2, known_binfo=<tree_binfo 0x7fffee9aed80>, can_refer=0x7fffffffd83e) at ../../gcc/gimple-fold.c:5789 #6 0x0000000000db27a9 in possible_polymorphic_call_targets (otr_type=<record_type 0x7fffef6873f0 CENSORED>, otr_token=2, context=..., completep=0x7fffffffda57, cache_token=0x7fffffffda58, speculative=false) at ../../gcc/ipa-devirt.c:3164 #7 0x0000000000b4b8d2 in possible_polymorphic_call_targets (e=0x7fffed9653a8, completep=0x7fffffffda57, cache_token=0x7fffffffda58, speculative=false) at ../../gcc/ipa-utils.h:114 #8 0x0000000000df41be in walk_polymorphic_call_targets (reachable_call_targets=0x7fffffffdaf0, edge=0x7fffed9653a8, first=0x7fffffffdb80, reachable=0x7fffffffdb50, before_inlining_p=true) at ../../gcc/ipa.c:167 #9 0x0000000000df4cfb in symbol_table::remove_unreachable_nodes (this=0x7ffff15a10a8, file=0x0) at ../../gcc/ipa.c:428 but surprisingly I then see the node->order = 4151 first backtrace, without release_symbol. So, are cgraph nodes garbage collected?