https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77383
--- Comment #2 from Alexander Ivchenko <aivchenk at gmail dot com> --- I debugged it and I suspect that the problem is in tree_function_versioning (which is used for making instrumented clones of all functions in MPX). Deep inside the logic of tree_function_versioning we do a copy of that statement: *D.1824 = retframe_block (); [return slot optimization] : (gdb) pgg orig_stmt *D.1824 = retframe_block (); [return slot optimization] (gdb) pct TYPE_SIZE(TREE_TYPE(gimple_call_lhs(orig_stmt))) D.1820 (gdb) pct TYPE_SIZE(TREE_TYPE(gimple_call_fntype(orig_stmt))) D.1820 And here is the copy of that gimple statement after remap_gimple_stmt (gdb) pgg stmt MEM[(struct block *)D.1842] = retframe_block (); [return slot optimization] (gdb) pct TYPE_SIZE(TREE_TYPE(gimple_call_lhs(stmt))) D.1837 (gdb) pct TYPE_SIZE(TREE_TYPE(gimple_call_fntype(stmt))) D.1820 where D.1820 is a local identifier from original "main" function (gdb) pct get_containing_scope(TYPE_SIZE(TREE_TYPE(gimple_call_fntype(stmt)))) main (gdb) pct get_containing_scope(TYPE_SIZE(TREE_TYPE(gimple_call_lhs(stmt)))) main.chkp After later on MPX deletes bodies of original functions, expand crashes when trying to make an rtl for D.1820 var_decl