In #67247 I revised how the JIT determines if a local requires special
handling for OSR, but for implicit byrefs we may move locals for promoted
fields back and forth between parents and this messes with the new logic.
The fix is to reset the `lvIsOSRLocal` bit explicitly when creating the
fields for an implicit byref promotion.
Also added a bit of sanity checking to `lvaIsOSRLocal`.
Fixes #67488.
LclVarDsc* const varDsc = lvaGetDesc(varNum);
#ifdef DEBUG
- if (!opts.IsOSR())
+ if (opts.IsOSR())
+ {
+ if (varDsc->lvIsOSRLocal)
+ {
+ // Sanity check for promoted fields of OSR locals.
+ //
+ if (varNum >= info.compLocalsCount)
+ {
+ assert(varDsc->lvIsStructField);
+ assert(varDsc->lvParentLcl < info.compLocalsCount);
+ }
+ }
+ }
+ else
{
assert(!varDsc->lvIsOSRLocal);
}
#if FEATURE_MULTIREG_ARGS
fieldVarDsc->SetOtherArgReg(REG_NA);
#endif
+ // Promoted fields of implicit byrefs can't be OSR locals.
+ //
+ if (fieldVarDsc->lvIsOSRLocal)
+ {
+ assert(opts.IsOSR());
+ fieldVarDsc->lvIsOSRLocal = false;
+ }
}
// Hijack lvFieldLclStart to record the new temp number.