https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113520
Richard Biener changed:
What|Removed |Added
Last reconfirmed||2024-01-22
Component|tree-optimization |ipa
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
CC||hubicka at gcc dot gnu.org,
||jamborm at gcc dot gnu.org,
||rguenth at gcc dot gnu.org
Keywords||lto
--- Comment #6 from Richard Biener ---
Hmm, we are supposed to "handle" this during in-streaming. This seems to work
but then for some reason it gets fiddled with again...
Ah, so this is reading of IPA CP summaries where it seems that we do not
apply these "tricks", gimple-streamer-out.cc has
/* 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 (!flag_wpa && op && (i || !is_gimple_debug (stmt)))
{
basep =
if (TREE_CODE (*basep) == ADDR_EXPR)
basep = _OPERAND (*basep, 0);
while (handled_component_p (*basep))
basep = _OPERAND (*basep, 0);
if (VAR_P (*basep)
&& !auto_var_in_fn_p (*basep, fn->decl)
&& !DECL_REGISTER (*basep))
{
bool volatilep = TREE_THIS_VOLATILE (*basep);
tree ptrtype = build_pointer_type (TREE_TYPE (*basep));
*basep = build2 (MEM_REF, TREE_TYPE (*basep),
build1 (ADDR_EXPR, ptrtype, *basep),
build_int_cst (ptrtype, 0));
TREE_THIS_VOLATILE (*basep) = volatilep;
...
and gimple-streamer-in.cc undoes this when the prevailing decls are compatible:
/* At LTO output time we wrap all global decls in MEM_REFs to
allow seamless replacement with prevailing decls. Undo this
here if the prevailing decl allows for this.
??? Maybe we should simply fold all stmts. */
if (TREE_CODE (*opp) == MEM_REF
&& TREE_CODE (TREE_OPERAND (*opp, 0)) == ADDR_EXPR
&& integer_zerop (TREE_OPERAND (*opp, 1))
&& (TREE_THIS_VOLATILE (*opp)
== TREE_THIS_VOLATILE
(TREE_OPERAND (TREE_OPERAND (*opp, 0), 0)))
&& !TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (*opp, 1)))
&& (TREE_TYPE (*opp)
== TREE_TYPE (TREE_TYPE (TREE_OPERAND (*opp, 1
&& (TREE_TYPE (*opp)
== TREE_TYPE (TREE_OPERAND (TREE_OPERAND (*opp, 0), 0
*opp = TREE_OPERAND (TREE_OPERAND (*opp, 0), 0);
I suppose we might want to split these out so summary streaming can apply
this to streamed trees as well?