Skip to content

Commit 82ce118

Browse files
authored
JIT: Check return value of InitializeCursors (#105017)
We were missing checking the return value of `InitializeCursors`. Typically this would just cause us to end up with an empty set of cursors as we abort the search as soon as we fail to create one cursor, and the cursor we would typically fail to create is always the first one. Running the next logic with an empty set of cursors causes no ill effects, so this has no diffs.
1 parent 467b36f commit 82ce118

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/coreclr/jit/inductionvariableopts.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,10 @@ bool StrengthReductionContext::TryStrengthReduce()
13391339

13401340
ScevAddRec* primaryIV = static_cast<ScevAddRec*>(candidate);
13411341

1342-
InitializeCursors(primaryIVLcl, primaryIV);
1342+
if (!InitializeCursors(primaryIVLcl, primaryIV))
1343+
{
1344+
continue;
1345+
}
13431346

13441347
ArrayStack<CursorInfo>* cursors = &m_cursors1;
13451348
ArrayStack<CursorInfo>* nextCursors = &m_cursors2;
@@ -1517,7 +1520,7 @@ bool StrengthReductionContext::InitializeCursors(GenTreeLclVarCommon* primaryIVL
15171520

15181521
if (!m_loopLocals.VisitOccurrences(m_loop, primaryIVLcl->GetLclNum(), visitor) || (m_cursors1.Height() <= 0))
15191522
{
1520-
JITDUMP(" Could not create cursors for all loop uses of primary IV");
1523+
JITDUMP(" Could not create cursors for all loop uses of primary IV\n");
15211524
return false;
15221525
}
15231526

0 commit comments

Comments
 (0)