Skip to content

Commit 43b58c2

Browse files
authored
JIT: three fixes for OSR (#62367)
Found when trying to enable OSR by default and prospecting for arm64 support. * Explicitly initalize the OSR step variable. * Prevent `fgOptimizeUncondBranchToSimpleCond` from changing the scratch entry BB to have conditional flow. * Retain runtime supplied patchpoint info when cleaning up after an altjit failure.
1 parent 9f4809e commit 43b58c2

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/coreclr/jit/fgopt.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,14 +1494,18 @@ void Compiler::fgPostImportationCleanup()
14941494

14951495
// We'll need a state variable to control the branching.
14961496
//
1497-
// It will be zero when the OSR method is entered and set to one
1497+
// It will be initialized to zero when the OSR method is entered and set to one
14981498
// once flow reaches the osrEntry.
14991499
//
1500-
unsigned const entryStateVar = lvaGrabTemp(false DEBUGARG("OSR entry state var"));
1501-
lvaTable[entryStateVar].lvType = TYP_INT;
1502-
lvaTable[entryStateVar].lvMustInit = true;
1500+
unsigned const entryStateVar = lvaGrabTemp(false DEBUGARG("OSR entry state var"));
1501+
lvaTable[entryStateVar].lvType = TYP_INT;
15031502

1504-
// Set the state variable when we reach the entry.
1503+
// Zero the entry state at method entry.
1504+
//
1505+
GenTree* const initEntryState = gtNewTempAssign(entryStateVar, gtNewZeroConNode(TYP_INT));
1506+
fgNewStmtAtBeg(fgFirstBB, initEntryState);
1507+
1508+
// Set the state variable once control flow reaches the OSR entry.
15051509
//
15061510
GenTree* const setEntryState = gtNewTempAssign(entryStateVar, gtNewOneConNode(TYP_INT));
15071511
fgNewStmtAtBeg(osrEntry, setEntryState);
@@ -3413,6 +3417,11 @@ bool Compiler::fgOptimizeUncondBranchToSimpleCond(BasicBlock* block, BasicBlock*
34133417
return false;
34143418
}
34153419

3420+
if (fgBBisScratch(block))
3421+
{
3422+
return false;
3423+
}
3424+
34163425
unsigned lclNum = BAD_VAR_NUM;
34173426

34183427
// First check if the successor tests a local and then branches on the result

src/coreclr/vm/jitinterface.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,8 +726,6 @@ class CEEJitInfo : public CEEInfo
726726
delete [] ((BYTE*) m_pPatchpointInfoFromJit);
727727

728728
m_pPatchpointInfoFromJit = NULL;
729-
m_pPatchpointInfoFromRuntime = NULL;
730-
m_ilOffset = 0;
731729
#endif
732730

733731
#ifdef FEATURE_EH_FUNCLETS

0 commit comments

Comments
 (0)