@@ -34,12 +34,21 @@ BackwardPass::BackwardPass(Func * func, GlobOpt * globOpt, Js::Phase tag)
34
34
#endif
35
35
}
36
36
37
- bool
38
- BackwardPass::DoSetDead () const
37
+ void
38
+ BackwardPass::DoSetDead (IR::Opnd * opnd, bool isDead ) const
39
39
{
40
40
// Note: Dead bit on the Opnd records flow-based liveness.
41
41
// 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
+ }
43
52
}
44
53
45
54
bool
@@ -4554,10 +4563,7 @@ BackwardPass::ProcessUse(IR::Opnd * opnd)
4554
4563
this ->CollectCloneStrCandidate (opnd);
4555
4564
}
4556
4565
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 ()));
4561
4567
4562
4568
if (IsCollectionPass ())
4563
4569
{
@@ -4602,10 +4608,8 @@ BackwardPass::ProcessUse(IR::Opnd * opnd)
4602
4608
{
4603
4609
IR::SymOpnd *symOpnd = opnd->AsSymOpnd ();
4604
4610
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 ()));
4609
4613
4610
4614
if (IsCollectionPass ())
4611
4615
{
@@ -4641,18 +4645,12 @@ BackwardPass::ProcessUse(IR::Opnd * opnd)
4641
4645
IR::IndirOpnd * indirOpnd = opnd->AsIndirOpnd ();
4642
4646
IR::RegOpnd * baseOpnd = indirOpnd->GetBaseOpnd ();
4643
4647
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 ()));
4648
4649
4649
4650
IR::RegOpnd * indexOpnd = indirOpnd->GetIndexOpnd ();
4650
4651
if (indexOpnd)
4651
4652
{
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 ()));
4656
4654
}
4657
4655
4658
4656
if (IsCollectionPass ())
@@ -5996,10 +5994,8 @@ BackwardPass::ProcessDef(IR::Opnd * opnd)
5996
5994
}
5997
5995
}
5998
5996
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
+
6003
5999
ProcessStackSymUse (propertySym->m_stackSym , isJITOptimizedReg);
6004
6000
if (tag == Js::BackwardPhase)
6005
6001
{
0 commit comments