Skip to content

Commit 65a465a

Browse files
committed
[MERGE #6073 @LouisLaf] Memop confusing type-spec syms and var syms
Merge pull request #6073 from LouisLaf:memop Memop had a bitvector containing only var syms, but the backwards pass was querying it using bits from upwardExposed and bytecodeUpwardExposed bitvectors, which contain type-spec syms.
2 parents 3c7ff01 + 6d22241 commit 65a465a

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

lib/Backend/BackwardPass.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8853,7 +8853,11 @@ BackwardPass::RestoreInductionVariableValuesAfterMemOp(Loop *loop)
88538853
opCode = Js::OpCode::Sub_I4;
88548854
}
88558855
Func *localFunc = loop->GetFunc();
8856-
StackSym *sym = localFunc->m_symTable->FindStackSym(symId)->GetInt32EquivSym(localFunc);
8856+
StackSym *sym = localFunc->m_symTable->FindStackSym(symId);
8857+
if (!sym->IsInt32())
8858+
{
8859+
sym = sym->GetInt32EquivSym(localFunc);
8860+
}
88578861

88588862
IR::Opnd *inductionVariableOpnd = IR::RegOpnd::New(sym, IRType::TyInt32, localFunc);
88598863
IR::Opnd *tempInductionVariableOpnd = IR::RegOpnd::New(IRType::TyInt32, localFunc);
@@ -8937,7 +8941,7 @@ BackwardPass::IsEmptyLoopAfterMemOp(Loop *loop)
89378941
{
89388942
Assert(instr->GetDst());
89398943
if (instr->GetDst()->GetStackSym()
8940-
&& loop->memOpInfo->inductionVariablesUsedAfterLoop->Test(globOpt->GetVarSymID(instr->GetDst()->GetStackSym())))
8944+
&& loop->memOpInfo->inductionVariablesUsedAfterLoop->Test(instr->GetDst()->GetStackSym()->m_id))
89418945
{
89428946
// We have use after the loop for a variable defined inside the loop. So the loop can't be removed.
89438947
return false;

lib/Backend/GlobOpt.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2222,10 +2222,20 @@ GlobOpt::CollectMemOpInfo(IR::Instr *instrBegin, IR::Instr *instr, Value *src1Va
22222222
if (!loop->memOpInfo->inductionVariableChangeInfoMap->ContainsKey(inductionSymID))
22232223
{
22242224
loop->memOpInfo->inductionVariableChangeInfoMap->Add(inductionSymID, inductionVariableChangeInfo);
2225+
if (sym->m_id != inductionSymID)
2226+
{
2227+
// Backwards pass uses this bit-vector to lookup upwardExposedUsed/bytecodeUpwardExposedUsed symbols, which are not necessarily vars. Just add both.
2228+
loop->memOpInfo->inductionVariableChangeInfoMap->Add(sym->m_id, inductionVariableChangeInfo);
2229+
}
22252230
}
22262231
else
22272232
{
22282233
loop->memOpInfo->inductionVariableChangeInfoMap->Item(inductionSymID, inductionVariableChangeInfo);
2234+
if (sym->m_id != inductionSymID)
2235+
{
2236+
// Backwards pass uses this bit-vector to lookup upwardExposedUsed/bytecodeUpwardExposedUsed symbols, which are not necessarily vars. Just add both.
2237+
loop->memOpInfo->inductionVariableChangeInfoMap->Item(sym->m_id, inductionVariableChangeInfo);
2238+
}
22292239
}
22302240
}
22312241
else
@@ -2234,6 +2244,11 @@ GlobOpt::CollectMemOpInfo(IR::Instr *instrBegin, IR::Instr *instr, Value *src1Va
22342244
{
22352245
Loop::InductionVariableChangeInfo inductionVariableChangeInfo = { 1, isIncr };
22362246
loop->memOpInfo->inductionVariableChangeInfoMap->Add(inductionSymID, inductionVariableChangeInfo);
2247+
if (sym->m_id != inductionSymID)
2248+
{
2249+
// Backwards pass uses this bit-vector to lookup upwardExposedUsed/bytecodeUpwardExposedUsed symbols, which are not necessarily vars. Just add both.
2250+
loop->memOpInfo->inductionVariableChangeInfoMap->Add(sym->m_id, inductionVariableChangeInfo);
2251+
}
22372252
}
22382253
else
22392254
{
@@ -2248,6 +2263,11 @@ GlobOpt::CollectMemOpInfo(IR::Instr *instrBegin, IR::Instr *instr, Value *src1Va
22482263
}
22492264
inductionVariableChangeInfo.isIncremental = isIncr;
22502265
loop->memOpInfo->inductionVariableChangeInfoMap->Item(inductionSymID, inductionVariableChangeInfo);
2266+
if (sym->m_id != inductionSymID)
2267+
{
2268+
// Backwards pass uses this bit-vector to lookup upwardExposedUsed/bytecodeUpwardExposedUsed symbols, which are not necessarily vars. Just add both.
2269+
loop->memOpInfo->inductionVariableChangeInfoMap->Item(sym->m_id, inductionVariableChangeInfo);
2270+
}
22512271
}
22522272
}
22532273
break;

0 commit comments

Comments
 (0)