https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97673
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> --- So the issue is that we are inlining # .MEM_5 = VDEF <.MEM_1(D)> master.0.sub3noiso.constprop (1, z_2(D), y_3(D), x_4(D), 0B, 0B, 1, 1, 0, 0); $12 = void and duplicate the clones BLOCK tree via if (DECL_INITIAL (fn)) { if (gimple_block (stmt)) { tree *var; prepend_lexical_block (id->block, remap_blocks (DECL_INITIAL (fn), id)); but the actual stmts we copy refer to the original function BLOCKs. That's likely because we ask for the untransformed body but that process does not "update" the scope tree? Adding diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index cd3fad1fa98..84f71d9c6cc 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -6513,6 +6513,7 @@ tree_function_versioning (tree old_decl, tree new_decl, delete param_body_adjs; free_dominance_info (CDI_DOMINATORS); free_dominance_info (CDI_POST_DOMINATORS); + verify_gimple_in_cfg (cfun, false); gcc_assert (!id.debug_stmts.exists ()); pop_cfun (); yields > ./f951 -quiet t.f90 -O3 -fno-early-inlining --param large-stack-frame=4000 t.f90:9:20: 9 | entry sub3noisoEntry(x,y,z) | ^ Error: location references block not in block tree # .MEM_5 = VDEF <.MEM_4(D)> D.4037 = {}; during IPA pass: inline t.f90:9:20: internal compiler error: verify_gimple failed 0x157e641 verify_gimple_in_cfg(function*, bool) /home/rguenther/src/gcc2/gcc/tree-cfg.c:5467 0x15fd84b tree_function_versioning(tree_node*, tree_node*, vec<ipa_replace_map*, va_gc, vl_embed>*, ipa_param_adjustments*, bool, bitmap_head*, basic_block_def*) /home/rguenther/src/gcc2/gcc/tree-inline.c:6516 0xd97875 cgraph_node::materialize_clone() /home/rguenther/src/gcc2/gcc/cgraphclones.c:1131 0xd7cfb0 cgraph_node::get_untransformed_body() /home/rguenther/src/gcc2/gcc/cgraph.c:3903 0x15f727c expand_call_inline /home/rguenther/src/gcc2/gcc/tree-inline.c:4850