Skip to content

Commit

Permalink
JIT: Allow cloning addresses even before initobj (#79341)
Browse files Browse the repository at this point in the history
Roslyn emits ldloca + dup + initobj when initializing structs. Normally
we clone address trees instead of creating a local for them (which will
address expose the local), but we treat this initobj pattern specially.

Remove this special treatment. It means we sometimes end up with
slightly larger code because we no longer have a register with the
address in it (could potentially be fixed by CSE), but avoiding the
address exposure seems like the right trade off to me.

Fix #42354
Fix #57055
  • Loading branch information
jakobbotsch authored Dec 8, 2022
1 parent 8767b38 commit eb8d5f7
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8387,8 +8387,7 @@ void Compiler::impImportBlockCode(BasicBlock* block)
{
clone = true;
}
else if (op1->TypeIs(TYP_BYREF, TYP_I_IMPL) && impIsAddressInLocal(op1) &&
(OPCODE)impGetNonPrefixOpcode(codeAddr + sz, codeEndp) != CEE_INITOBJ)
else if (op1->TypeIs(TYP_BYREF, TYP_I_IMPL) && impIsAddressInLocal(op1))
{
// We mark implicit byrefs with GTF_GLOB_REF (see gtNewFieldRef for why).
// Avoid cloning for these.
Expand Down

0 comments on commit eb8d5f7

Please sign in to comment.