Skip to content

Commit 1fce646

Browse files
committed
Reset variable lifetime to be valid if not dead in DeadStorePhase
1 parent 79b870a commit 1fce646

File tree

3 files changed

+21
-25
lines changed

3 files changed

+21
-25
lines changed

lib/Backend/BackwardPass.cpp

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,21 @@ BackwardPass::BackwardPass(Func * func, GlobOpt * globOpt, Js::Phase tag)
3434
#endif
3535
}
3636

37-
bool
38-
BackwardPass::DoSetDead() const
37+
void
38+
BackwardPass::DoSetDead(IR::Opnd * opnd, bool isDead) const
3939
{
4040
// Note: Dead bit on the Opnd records flow-based liveness.
4141
// This is distinct from isLastUse, which records lexical last-ness.
42-
return this->tag == Js::BackwardPhase && !this->IsPrePass();
42+
if (isDead && this->tag == Js::BackwardPhase && !this->IsPrePass())
43+
{
44+
opnd->SetIsDead();
45+
}
46+
else if (this->tag == Js::DeadStorePhase)
47+
{
48+
// Set or reset in DeadStorePhase.
49+
// CSE could make previous dead operand not the last use, so reset it.
50+
opnd->SetIsDead(isDead);
51+
}
4352
}
4453

4554
bool
@@ -4554,10 +4563,7 @@ BackwardPass::ProcessUse(IR::Opnd * opnd)
45544563
this->CollectCloneStrCandidate(opnd);
45554564
}
45564565

4557-
if (!this->ProcessSymUse(sym, true, regOpnd->GetIsJITOptimizedReg()) && this->DoSetDead())
4558-
{
4559-
regOpnd->SetIsDead();
4560-
}
4566+
this->DoSetDead(regOpnd, !this->ProcessSymUse(sym, true, regOpnd->GetIsJITOptimizedReg()));
45614567

45624568
if (IsCollectionPass())
45634569
{
@@ -4602,10 +4608,8 @@ BackwardPass::ProcessUse(IR::Opnd * opnd)
46024608
{
46034609
IR::SymOpnd *symOpnd = opnd->AsSymOpnd();
46044610
Sym * sym = symOpnd->m_sym;
4605-
if (!this->ProcessSymUse(sym, false, opnd->GetIsJITOptimizedReg()) && this->DoSetDead())
4606-
{
4607-
symOpnd->SetIsDead();
4608-
}
4611+
4612+
this->DoSetDead(symOpnd, !this->ProcessSymUse(sym, false, opnd->GetIsJITOptimizedReg()));
46094613

46104614
if (IsCollectionPass())
46114615
{
@@ -4641,18 +4645,12 @@ BackwardPass::ProcessUse(IR::Opnd * opnd)
46414645
IR::IndirOpnd * indirOpnd = opnd->AsIndirOpnd();
46424646
IR::RegOpnd * baseOpnd = indirOpnd->GetBaseOpnd();
46434647

4644-
if (!this->ProcessSymUse(baseOpnd->m_sym, false, baseOpnd->GetIsJITOptimizedReg()) && this->DoSetDead())
4645-
{
4646-
baseOpnd->SetIsDead();
4647-
}
4648+
this->DoSetDead(baseOpnd, !this->ProcessSymUse(baseOpnd->m_sym, false, baseOpnd->GetIsJITOptimizedReg()));
46484649

46494650
IR::RegOpnd * indexOpnd = indirOpnd->GetIndexOpnd();
46504651
if (indexOpnd)
46514652
{
4652-
if (!this->ProcessSymUse(indexOpnd->m_sym, false, indexOpnd->GetIsJITOptimizedReg()) && this->DoSetDead())
4653-
{
4654-
indexOpnd->SetIsDead();
4655-
}
4653+
this->DoSetDead(indexOpnd, !this->ProcessSymUse(indexOpnd->m_sym, false, indexOpnd->GetIsJITOptimizedReg()));
46564654
}
46574655

46584656
if(IsCollectionPass())
@@ -5996,10 +5994,8 @@ BackwardPass::ProcessDef(IR::Opnd * opnd)
59965994
}
59975995
}
59985996

5999-
if (!block->upwardExposedFields->TestAndClear(propertySym->m_id) && this->DoSetDead())
6000-
{
6001-
opnd->SetIsDead();
6002-
}
5997+
this->DoSetDead(opnd, !block->upwardExposedFields->TestAndClear(propertySym->m_id));
5998+
60035999
ProcessStackSymUse(propertySym->m_stackSym, isJITOptimizedReg);
60046000
if (tag == Js::BackwardPhase)
60056001
{

lib/Backend/BackwardPass.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class BackwardPass
9696
bool ProcessBailOnNoProfile(IR::Instr *instr, BasicBlock *block);
9797

9898
bool DoByteCodeUpwardExposedUsed() const;
99-
bool DoSetDead() const;
99+
void DoSetDead(IR::Opnd * opnd, bool isDead) const;
100100
bool DoFieldHoistCandidates() const;
101101
bool DoFieldHoistCandidates(Loop * loop) const;
102102
bool DoMarkTempObjects() const;

lib/Backend/PreLowerPeeps.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
IR::Instr *Lowerer::PreLowerPeepInstr(IR::Instr *instr, IR::Instr **pInstrPrev)
88
{
9-
if (!PHASE_ON(Js::PreLowererPeepsPhase, this->m_func))
9+
if (!PHASE_OFF(Js::PreLowererPeepsPhase, this->m_func))
1010
{
1111
return instr;
1212
}

0 commit comments

Comments
 (0)