This fixes part 2 of PR56295, it un-does MEM_REF wrapping on the writer side. Otherwise code-generation differences at compile-time appear -flto vs. -fno-lto (with fat LTO objects).
LTO bootstrap & regtest running on x86_64-unknown-linux-gnu. Richard. 2013-02-13 Richard Biener <rguent...@suse.de> PR lto/56295 * gimple-streamer-out.c (output_gimple_stmt): Undo wrapping globals in MEM_REFs. Index: gcc/gimple-streamer-out.c =================================================================== *** gcc/gimple-streamer-out.c (revision 195997) --- gcc/gimple-streamer-out.c (working copy) *************** output_gimple_stmt (struct output_block *** 116,128 **** for (i = 0; i < gimple_num_ops (stmt); i++) { tree op = gimple_op (stmt, i); /* Wrap all uses of non-automatic variables inside MEM_REFs so that we do not have to deal with type mismatches on merged symbols during IL read in. The first operand of GIMPLE_DEBUG must be a decl, not MEM_REF, though. */ if (op && (i || !is_gimple_debug (stmt))) { ! tree *basep = &op; while (handled_component_p (*basep)) basep = &TREE_OPERAND (*basep, 0); if (TREE_CODE (*basep) == VAR_DECL --- 116,129 ---- for (i = 0; i < gimple_num_ops (stmt); i++) { tree op = gimple_op (stmt, i); + tree *basep = NULL; /* Wrap all uses of non-automatic variables inside MEM_REFs so that we do not have to deal with type mismatches on merged symbols during IL read in. The first operand of GIMPLE_DEBUG must be a decl, not MEM_REF, though. */ if (op && (i || !is_gimple_debug (stmt))) { ! basep = &op; while (handled_component_p (*basep)) basep = &TREE_OPERAND (*basep, 0); if (TREE_CODE (*basep) == VAR_DECL *************** output_gimple_stmt (struct output_block *** 136,143 **** --- 137,149 ---- (TREE_TYPE (*basep)), 0)); TREE_THIS_VOLATILE (*basep) = volatilep; } + else + basep = NULL; } stream_write_tree (ob, op, true); + /* Restore the original base if we wrapped it inside a MEM_REF. */ + if (basep) + *basep = TREE_OPERAND (TREE_OPERAND (*basep, 0), 0); } if (is_gimple_call (stmt)) {