* Include condition for forward jump loops
* Remove IGF_FINALLY_TARGET and surrounding code
Pass DEBUG_ARG(bbnum) to `emitAddLabel()` to print the BB->IG mapping.
* Revert "Remove IGF_FINALLY_TARGET and surrounding code"
This reverts commit
284c0abc202cca2de22787bf18081076200e5272.
* Pass bbNum to emitAddLabel
* fix Release build break
void CodeGen::genDefineTempLabel(BasicBlock* label)
{
genLogLabel(label);
- label->bbEmitCookie =
- GetEmitter()->emitAddLabel(gcInfo.gcVarPtrSetCur, gcInfo.gcRegGCrefSetCur, gcInfo.gcRegByrefSetCur);
+ label->bbEmitCookie = GetEmitter()->emitAddLabel(gcInfo.gcVarPtrSetCur, gcInfo.gcRegGCrefSetCur,
+ gcInfo.gcRegByrefSetCur, false DEBUG_ARG(label->bbNum));
}
// genDefineInlineTempLabel: Define an inline label that does not affect the GC
// would be executed, which we would prefer not to do.
block->bbUnwindNopEmitCookie =
- GetEmitter()->emitAddLabel(gcInfo.gcVarPtrSetCur, gcInfo.gcRegGCrefSetCur, gcInfo.gcRegByrefSetCur);
+ GetEmitter()->emitAddLabel(gcInfo.gcVarPtrSetCur, gcInfo.gcRegGCrefSetCur, gcInfo.gcRegByrefSetCur,
+ false DEBUG_ARG(block->bbNum));
instGen(INS_nop);
}
// Mark a label and update the current set of live GC refs
block->bbEmitCookie = GetEmitter()->emitAddLabel(gcInfo.gcVarPtrSetCur, gcInfo.gcRegGCrefSetCur,
- gcInfo.gcRegByrefSetCur, FALSE);
+ gcInfo.gcRegByrefSetCur, false DEBUG_ARG(block->bbNum));
}
if (block == compiler->fgFirstColdBlock)
* Mark the current spot as having a label.
*/
-void* emitter::emitAddLabel(VARSET_VALARG_TP GCvars, regMaskTP gcrefRegs, regMaskTP byrefRegs, BOOL isFinallyTarget)
+void* emitter::emitAddLabel(VARSET_VALARG_TP GCvars,
+ regMaskTP gcrefRegs,
+ regMaskTP byrefRegs,
+ bool isFinallyTarget DEBUG_ARG(unsigned bbNum))
{
/* Create a new IG if the current one is non-empty */
#endif // defined(FEATURE_EH_FUNCLETS) && defined(TARGET_ARM)
#ifdef DEBUG
+ JITDUMP("Mapped " FMT_BB " to G_M%03u_IG%02u\n", bbNum, emitComp->compMethodID, emitCurIG->igNum);
+
if (EMIT_GC_VERBOSE)
{
printf("Label: IG%02u, GCvars=%s ", emitCurIG->igNum, VarSetOps::ToString(emitComp, GCvars));
loopSize += igInLoop->igSize;
if (igInLoop->isLoopAlign())
{
- // If igInLoop's next IG is a loop and needs alignment, then igInLoop should be the last IG
- // of the current loop and should have backedge to current loop header.
- assert(igInLoop->igLoopBackEdge == igLoopHeader);
+ // If igInLoop is marked as "IGF_LOOP_ALIGN", the basic block flow detected a loop start.
+ // If the loop was formed because of forward jumps like the loop IG18 below, the backedge is not
+ // set for them and such loops are not aligned. For such cases, the loop size threshold will never
+ // be met and we would break as soon as loopSize > maxLoopSize.
+ //
+ // IG05:
+ // ...
+ // jmp IG18
+ // ...
+ // IG18:
+ // ...
+ // jne IG05
+ //
+ // If igInLoop is a legitimate loop, and igInLoop's next IG is also a loop that needs alignment,
+ // then igInLoop should be the last IG of the current loop and should have backedge to current
+ // loop header.
+ //
+ // Below, IG05 is the last IG of loop IG04-IG05 and its backedge points to IG04.
+ //
+ // IG03:
+ // ...
+ // align
+ // IG04:
+ // ...
+ // ...
+ // IG05:
+ // ...
+ // jne IG04
+ // align ; <---
+ // IG06:
+ // ...
+ // jne IG06
+ //
+ //
+ assert((igInLoop->igLoopBackEdge == nullptr) || (igInLoop->igLoopBackEdge == igLoopHeader));
#ifdef DEBUG
if (isAlignAdjusted)
// Sets the emitter's record of the currently live GC variables
// and registers. The "isFinallyTarget" parameter indicates that the current location is
// the start of a basic block that is returned to after a finally clause in non-exceptional execution.
- void* emitAddLabel(VARSET_VALARG_TP GCvars, regMaskTP gcrefRegs, regMaskTP byrefRegs, BOOL isFinallyTarget = FALSE);
+ void* emitAddLabel(VARSET_VALARG_TP GCvars,
+ regMaskTP gcrefRegs,
+ regMaskTP byrefRegs,
+ bool isFinallyTarget = false DEBUG_ARG(unsigned bbNum = 0));
+
// Same as above, except the label is added and is conceptually "inline" in
// the current block. Thus it extends the previous block and the emitter
// continues to track GC info as if there was no label.