Skip to content

Commit 47797ad

Browse files
authored
Force storing GC state until we see a labeled IG (#114475)
* Force storing GC state until we see a labelled IG * review feedback
1 parent 258b1ee commit 47797ad

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/coreclr/jit/emit.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,13 @@ insGroup* emitter::emitSavIG(bool emitAdd)
10081008
emitPrevGCrefRegs = emitThisGCrefRegs;
10091009
emitPrevByrefRegs = emitThisByrefRegs;
10101010

1011-
emitForceStoreGCState = false;
1011+
if (emitAddedLabel)
1012+
{
1013+
// Reset emitForceStoreGCState only after seeing label. It will keep
1014+
// marking IGs with IGF_GC_VARS flag until that.
1015+
emitForceStoreGCState = false;
1016+
emitAddedLabel = false;
1017+
}
10121018
}
10131019

10141020
#ifdef DEBUG
@@ -1277,6 +1283,7 @@ void emitter::emitBegFN(bool hasFramePtr
12771283
emitPrevByrefRegs = RBM_NONE;
12781284

12791285
emitForceStoreGCState = false;
1286+
emitAddedLabel = false;
12801287

12811288
#ifdef DEBUG
12821289

@@ -2839,6 +2846,8 @@ void* emitter::emitAddLabel(VARSET_VALARG_TP GCvars, regMaskTP gcrefRegs, regMas
28392846
}
28402847
}
28412848

2849+
emitAddedLabel = true;
2850+
28422851
/* Create a new IG if the current one is non-empty */
28432852

28442853
if (emitCurIGnonEmpty())

src/coreclr/jit/emit.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2761,6 +2761,14 @@ class emitter
27612761

27622762
bool emitForceStoreGCState;
27632763

2764+
// This flag is used together with `emitForceStoreGCState`. After we set
2765+
// emitForceStoreGCState = true, we will mark `emitAddedLabel` to true whenever
2766+
// we see a label IG. In emitSavIG, we will reset `emitForceStoreGCState = false`
2767+
// only after seeing `emitAddedLabel == true`. Until then, we will keep recording
2768+
// GC_VARS on the IGs.
2769+
2770+
bool emitAddedLabel;
2771+
27642772
// emitThis* variables are used during emission, to track GC updates
27652773
// on a per-instruction basis. During code generation, per-instruction
27662774
// tracking is done with variables gcVarPtrSetCur, gcRegGCrefSetCur,

0 commit comments

Comments
 (0)