Skip to content

Commit 6d22241

Browse files
committed
Memop confusing type-spec syms and var syms
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.
1 parent f8adb1b commit 6d22241

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
@@ -8845,7 +8845,11 @@ BackwardPass::RestoreInductionVariableValuesAfterMemOp(Loop *loop)
88458845
opCode = Js::OpCode::Sub_I4;
88468846
}
88478847
Func *localFunc = loop->GetFunc();
8848-
StackSym *sym = localFunc->m_symTable->FindStackSym(symId)->GetInt32EquivSym(localFunc);
8848+
StackSym *sym = localFunc->m_symTable->FindStackSym(symId);
8849+
if (!sym->IsInt32())
8850+
{
8851+
sym = sym->GetInt32EquivSym(localFunc);
8852+
}
88498853

88508854
IR::Opnd *inductionVariableOpnd = IR::RegOpnd::New(sym, IRType::TyInt32, localFunc);
88518855
IR::Opnd *tempInductionVariableOpnd = IR::RegOpnd::New(IRType::TyInt32, localFunc);
@@ -8929,7 +8933,7 @@ BackwardPass::IsEmptyLoopAfterMemOp(Loop *loop)
89298933
{
89308934
Assert(instr->GetDst());
89318935
if (instr->GetDst()->GetStackSym()
8932-
&& loop->memOpInfo->inductionVariablesUsedAfterLoop->Test(globOpt->GetVarSymID(instr->GetDst()->GetStackSym())))
8936+
&& loop->memOpInfo->inductionVariablesUsedAfterLoop->Test(instr->GetDst()->GetStackSym()->m_id))
89338937
{
89348938
// We have use after the loop for a variable defined inside the loop. So the loop can't be removed.
89358939
return false;

lib/Backend/GlobOpt.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2216,10 +2216,20 @@ GlobOpt::CollectMemOpInfo(IR::Instr *instrBegin, IR::Instr *instr, Value *src1Va
22162216
if (!loop->memOpInfo->inductionVariableChangeInfoMap->ContainsKey(inductionSymID))
22172217
{
22182218
loop->memOpInfo->inductionVariableChangeInfoMap->Add(inductionSymID, inductionVariableChangeInfo);
2219+
if (sym->m_id != inductionSymID)
2220+
{
2221+
// Backwards pass uses this bit-vector to lookup upwardExposedUsed/bytecodeUpwardExposedUsed symbols, which are not necessarily vars. Just add both.
2222+
loop->memOpInfo->inductionVariableChangeInfoMap->Add(sym->m_id, inductionVariableChangeInfo);
2223+
}
22192224
}
22202225
else
22212226
{
22222227
loop->memOpInfo->inductionVariableChangeInfoMap->Item(inductionSymID, inductionVariableChangeInfo);
2228+
if (sym->m_id != inductionSymID)
2229+
{
2230+
// Backwards pass uses this bit-vector to lookup upwardExposedUsed/bytecodeUpwardExposedUsed symbols, which are not necessarily vars. Just add both.
2231+
loop->memOpInfo->inductionVariableChangeInfoMap->Item(sym->m_id, inductionVariableChangeInfo);
2232+
}
22232233
}
22242234
}
22252235
else
@@ -2228,6 +2238,11 @@ GlobOpt::CollectMemOpInfo(IR::Instr *instrBegin, IR::Instr *instr, Value *src1Va
22282238
{
22292239
Loop::InductionVariableChangeInfo inductionVariableChangeInfo = { 1, isIncr };
22302240
loop->memOpInfo->inductionVariableChangeInfoMap->Add(inductionSymID, inductionVariableChangeInfo);
2241+
if (sym->m_id != inductionSymID)
2242+
{
2243+
// Backwards pass uses this bit-vector to lookup upwardExposedUsed/bytecodeUpwardExposedUsed symbols, which are not necessarily vars. Just add both.
2244+
loop->memOpInfo->inductionVariableChangeInfoMap->Add(sym->m_id, inductionVariableChangeInfo);
2245+
}
22312246
}
22322247
else
22332248
{
@@ -2242,6 +2257,11 @@ GlobOpt::CollectMemOpInfo(IR::Instr *instrBegin, IR::Instr *instr, Value *src1Va
22422257
}
22432258
inductionVariableChangeInfo.isIncremental = isIncr;
22442259
loop->memOpInfo->inductionVariableChangeInfoMap->Item(inductionSymID, inductionVariableChangeInfo);
2260+
if (sym->m_id != inductionSymID)
2261+
{
2262+
// Backwards pass uses this bit-vector to lookup upwardExposedUsed/bytecodeUpwardExposedUsed symbols, which are not necessarily vars. Just add both.
2263+
loop->memOpInfo->inductionVariableChangeInfoMap->Item(sym->m_id, inductionVariableChangeInfo);
2264+
}
22452265
}
22462266
}
22472267
break;

0 commit comments

Comments
 (0)