Skip to content

Commit 8a96ee7

Browse files
authored
JIT: Optimize zero inits out only for locals that aren't candidates to be tracked (#82042)
Otherwise we may track it after lowering and invalidate the assumptions made by the optimization. Fix #82020
1 parent 33b552f commit 8a96ee7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/coreclr/jit/optimizer.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10344,10 +10344,13 @@ void Compiler::optRemoveRedundantZeroInits()
1034410344

1034510345
if (!bbInALoop || bbIsReturn)
1034610346
{
10347+
bool neverTracked = lclDsc->IsAddressExposed() || lclDsc->lvPinned ||
10348+
(lclDsc->lvPromoted && varTypeIsStruct(lclDsc));
10349+
1034710350
if (BitVecOps::IsMember(&bitVecTraits, zeroInitLocals, lclNum) ||
1034810351
(lclDsc->lvIsStructField &&
1034910352
BitVecOps::IsMember(&bitVecTraits, zeroInitLocals, lclDsc->lvParentLcl)) ||
10350-
((!lclDsc->lvTracked || !isEntire) &&
10353+
((neverTracked || !isEntire) &&
1035110354
!fgVarNeedsExplicitZeroInit(lclNum, bbInALoop, bbIsReturn)))
1035210355
{
1035310356
// We are guaranteed to have a zero initialization in the prolog or a

0 commit comments

Comments
 (0)