Skip to content

Commit 76b48b6

Browse files
authored
JIT: Generalize check for full interruptibility (#95299)
Get rid of the dependencies on dominators and reachability and switch it to a simple cycle check. Switch MinOpts to also use the cycle check. This has a bit mixed results, but our largest SPMI contexts show that this is beneficial TP wise, and it should generate smaller GC info.
1 parent ed0b223 commit 76b48b6

File tree

6 files changed

+199
-395
lines changed

6 files changed

+199
-395
lines changed

src/coreclr/jit/block.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -495,14 +495,6 @@ void BasicBlock::dspFlags()
495495
{
496496
printf("Loop ");
497497
}
498-
if (bbFlags & BBF_LOOP_CALL0)
499-
{
500-
printf("Loop0 ");
501-
}
502-
if (bbFlags & BBF_LOOP_CALL1)
503-
{
504-
printf("Loop1 ");
505-
}
506498
if (bbFlags & BBF_HAS_LABEL)
507499
{
508500
printf("label ");

src/coreclr/jit/block.h

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -392,43 +392,41 @@ enum BasicBlockFlags : unsigned __int64
392392
BBF_HAS_SUPPRESSGC_CALL = MAKE_BBFLAG(12), // BB contains a call to a method with SuppressGCTransitionAttribute
393393
BBF_RUN_RARELY = MAKE_BBFLAG(13), // BB is rarely run (catch clauses, blocks with throws etc)
394394
BBF_LOOP_HEAD = MAKE_BBFLAG(14), // BB is the head of a loop
395-
BBF_LOOP_CALL0 = MAKE_BBFLAG(15), // BB starts a loop that sometimes won't call
396-
BBF_LOOP_CALL1 = MAKE_BBFLAG(16), // BB starts a loop that will always call
397-
BBF_HAS_LABEL = MAKE_BBFLAG(17), // BB needs a label
398-
BBF_LOOP_ALIGN = MAKE_BBFLAG(18), // Block is lexically the first block in a loop we intend to align.
399-
BBF_HAS_ALIGN = MAKE_BBFLAG(19), // BB ends with 'align' instruction
400-
BBF_HAS_JMP = MAKE_BBFLAG(20), // BB executes a JMP instruction (instead of return)
401-
BBF_GC_SAFE_POINT = MAKE_BBFLAG(21), // BB has a GC safe point (a call). More abstractly, BB does not require a
395+
BBF_HAS_LABEL = MAKE_BBFLAG(15), // BB needs a label
396+
BBF_LOOP_ALIGN = MAKE_BBFLAG(16), // Block is lexically the first block in a loop we intend to align.
397+
BBF_HAS_ALIGN = MAKE_BBFLAG(17), // BB ends with 'align' instruction
398+
BBF_HAS_JMP = MAKE_BBFLAG(18), // BB executes a JMP instruction (instead of return)
399+
BBF_GC_SAFE_POINT = MAKE_BBFLAG(19), // BB has a GC safe point (a call). More abstractly, BB does not require a
402400
// (further) poll -- this may be because this BB has a call, or, in some
403401
// cases, because the BB occurs in a loop, and we've determined that all
404402
// paths in the loop body leading to BB include a call.
405-
BBF_HAS_IDX_LEN = MAKE_BBFLAG(22), // BB contains simple index or length expressions on an SD array local var.
406-
BBF_HAS_MD_IDX_LEN = MAKE_BBFLAG(23), // BB contains simple index, length, or lower bound expressions on an MD array local var.
407-
BBF_HAS_MDARRAYREF = MAKE_BBFLAG(24), // Block has a multi-dimensional array reference
408-
BBF_HAS_NEWOBJ = MAKE_BBFLAG(25), // BB contains 'new' of an object type.
403+
BBF_HAS_IDX_LEN = MAKE_BBFLAG(20), // BB contains simple index or length expressions on an SD array local var.
404+
BBF_HAS_MD_IDX_LEN = MAKE_BBFLAG(21), // BB contains simple index, length, or lower bound expressions on an MD array local var.
405+
BBF_HAS_MDARRAYREF = MAKE_BBFLAG(22), // Block has a multi-dimensional array reference
406+
BBF_HAS_NEWOBJ = MAKE_BBFLAG(23), // BB contains 'new' of an object type.
409407

410-
BBF_RETLESS_CALL = MAKE_BBFLAG(26), // BBJ_CALLFINALLY that will never return (and therefore, won't need a paired
408+
BBF_RETLESS_CALL = MAKE_BBFLAG(24), // BBJ_CALLFINALLY that will never return (and therefore, won't need a paired
411409
// BBJ_ALWAYS); see isBBCallAlwaysPair().
412-
BBF_LOOP_PREHEADER = MAKE_BBFLAG(27), // BB is a loop preheader block
413-
BBF_COLD = MAKE_BBFLAG(28), // BB is cold
414-
BBF_PROF_WEIGHT = MAKE_BBFLAG(29), // BB weight is computed from profile data
415-
BBF_KEEP_BBJ_ALWAYS = MAKE_BBFLAG(30), // A special BBJ_ALWAYS block, used by EH code generation. Keep the jump kind
410+
BBF_LOOP_PREHEADER = MAKE_BBFLAG(25), // BB is a loop preheader block
411+
BBF_COLD = MAKE_BBFLAG(26), // BB is cold
412+
BBF_PROF_WEIGHT = MAKE_BBFLAG(27), // BB weight is computed from profile data
413+
BBF_KEEP_BBJ_ALWAYS = MAKE_BBFLAG(28), // A special BBJ_ALWAYS block, used by EH code generation. Keep the jump kind
416414
// as BBJ_ALWAYS. Used for the paired BBJ_ALWAYS block following the
417415
// BBJ_CALLFINALLY block, as well as, on x86, the final step block out of a
418416
// finally.
419-
BBF_HAS_CALL = MAKE_BBFLAG(31), // BB contains a call
420-
BBF_DOMINATED_BY_EXCEPTIONAL_ENTRY = MAKE_BBFLAG(32), // Block is dominated by exceptional entry.
421-
BBF_BACKWARD_JUMP = MAKE_BBFLAG(33), // BB is surrounded by a backward jump/switch arc
422-
BBF_BACKWARD_JUMP_SOURCE = MAKE_BBFLAG(34), // Block is a source of a backward jump
423-
BBF_BACKWARD_JUMP_TARGET = MAKE_BBFLAG(35), // Block is a target of a backward jump
424-
BBF_PATCHPOINT = MAKE_BBFLAG(36), // Block is a patchpoint
425-
BBF_PARTIAL_COMPILATION_PATCHPOINT = MAKE_BBFLAG(37), // Block is a partial compilation patchpoint
426-
BBF_HAS_HISTOGRAM_PROFILE = MAKE_BBFLAG(38), // BB contains a call needing a histogram profile
427-
BBF_TAILCALL_SUCCESSOR = MAKE_BBFLAG(39), // BB has pred that has potential tail call
428-
BBF_RECURSIVE_TAILCALL = MAKE_BBFLAG(40), // Block has recursive tailcall that may turn into a loop
429-
BBF_NO_CSE_IN = MAKE_BBFLAG(41), // Block should kill off any incoming CSE
430-
BBF_CAN_ADD_PRED = MAKE_BBFLAG(42), // Ok to add pred edge to this block, even when "safe" edge creation disabled
431-
BBF_NONE_QUIRK = MAKE_BBFLAG(43), // Block was created as a BBJ_ALWAYS to the next block,
417+
BBF_HAS_CALL = MAKE_BBFLAG(29), // BB contains a call
418+
BBF_DOMINATED_BY_EXCEPTIONAL_ENTRY = MAKE_BBFLAG(30), // Block is dominated by exceptional entry.
419+
BBF_BACKWARD_JUMP = MAKE_BBFLAG(31), // BB is surrounded by a backward jump/switch arc
420+
BBF_BACKWARD_JUMP_SOURCE = MAKE_BBFLAG(32), // Block is a source of a backward jump
421+
BBF_BACKWARD_JUMP_TARGET = MAKE_BBFLAG(33), // Block is a target of a backward jump
422+
BBF_PATCHPOINT = MAKE_BBFLAG(34), // Block is a patchpoint
423+
BBF_PARTIAL_COMPILATION_PATCHPOINT = MAKE_BBFLAG(35), // Block is a partial compilation patchpoint
424+
BBF_HAS_HISTOGRAM_PROFILE = MAKE_BBFLAG(36), // BB contains a call needing a histogram profile
425+
BBF_TAILCALL_SUCCESSOR = MAKE_BBFLAG(37), // BB has pred that has potential tail call
426+
BBF_RECURSIVE_TAILCALL = MAKE_BBFLAG(38), // Block has recursive tailcall that may turn into a loop
427+
BBF_NO_CSE_IN = MAKE_BBFLAG(39), // Block should kill off any incoming CSE
428+
BBF_CAN_ADD_PRED = MAKE_BBFLAG(40), // Ok to add pred edge to this block, even when "safe" edge creation disabled
429+
BBF_NONE_QUIRK = MAKE_BBFLAG(41), // Block was created as a BBJ_ALWAYS to the next block,
432430
// and should be treated as if it falls through.
433431
// This is just to reduce diffs from removing BBJ_NONE.
434432
// (TODO: Remove this quirk after refactoring Compiler::fgFindInsertPoint)
@@ -437,7 +435,7 @@ enum BasicBlockFlags : unsigned __int64
437435

438436
// Flags that relate blocks to loop structure.
439437

440-
BBF_LOOP_FLAGS = BBF_LOOP_PREHEADER | BBF_LOOP_HEAD | BBF_LOOP_CALL0 | BBF_LOOP_CALL1 | BBF_LOOP_ALIGN,
438+
BBF_LOOP_FLAGS = BBF_LOOP_PREHEADER | BBF_LOOP_HEAD | BBF_LOOP_ALIGN,
441439

442440
// Flags to update when two blocks are compacted
443441

@@ -446,7 +444,7 @@ enum BasicBlockFlags : unsigned __int64
446444

447445
// Flags a block should not have had before it is split.
448446

449-
BBF_SPLIT_NONEXIST = BBF_LOOP_HEAD | BBF_LOOP_CALL0 | BBF_LOOP_CALL1 | BBF_RETLESS_CALL | BBF_LOOP_PREHEADER | BBF_COLD,
447+
BBF_SPLIT_NONEXIST = BBF_LOOP_HEAD | BBF_RETLESS_CALL | BBF_LOOP_PREHEADER | BBF_COLD,
450448

451449
// Flags lost by the top block when a block is split.
452450
// Note, this is a conservative guess.

src/coreclr/jit/compiler.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5778,6 +5778,7 @@ class Compiler
57785778
typedef bool(fgSplitPredicate)(GenTree* tree, GenTree* parent, fgWalkData* data);
57795779

57805780
PhaseStatus fgSetBlockOrder();
5781+
bool fgHasCycleWithoutGCSafePoint();
57815782

57825783
FlowGraphDfsTree* fgComputeDfs();
57835784

@@ -5787,14 +5788,9 @@ class Compiler
57875788

57885789
bool fgCastNeeded(GenTree* tree, var_types toType);
57895790

5790-
// The following check for loops that don't execute calls
5791-
bool fgLoopCallMarked;
5792-
57935791
void fgLoopCallTest(BasicBlock* srcBB, BasicBlock* dstBB);
57945792
void fgLoopCallMark();
57955793

5796-
void fgMarkLoopHead(BasicBlock* block);
5797-
57985794
unsigned fgGetCodeEstimate(BasicBlock* block);
57995795

58005796
#if DUMP_FLOWGRAPHS
@@ -8013,8 +8009,6 @@ class Compiler
80138009
protected:
80148010
ssize_t optGetArrayRefScaleAndIndex(GenTree* mul, GenTree** pIndex DEBUGARG(bool bRngChk));
80158011

8016-
bool optReachWithoutCall(BasicBlock* srcBB, BasicBlock* dstBB);
8017-
80188012
/*
80198013
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
80208014
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

src/coreclr/jit/fgbasic.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ void Compiler::fgInit()
3838
fgReachabilitySetsValid = false;
3939
#endif // DEBUG
4040

41-
/* We don't know yet which loops will always execute calls */
42-
fgLoopCallMarked = false;
43-
4441
/* Initialize the basic block list */
4542

4643
fgFirstBB = nullptr;
@@ -4770,8 +4767,8 @@ BasicBlock* Compiler::fgSplitBlockAtEnd(BasicBlock* curr)
47704767
newBlock->bbFlags = curr->bbFlags;
47714768

47724769
// Remove flags that the new block can't have.
4773-
newBlock->bbFlags &= ~(BBF_LOOP_HEAD | BBF_LOOP_CALL0 | BBF_LOOP_CALL1 | BBF_FUNCLET_BEG | BBF_LOOP_PREHEADER |
4774-
BBF_KEEP_BBJ_ALWAYS | BBF_PATCHPOINT | BBF_BACKWARD_JUMP_TARGET | BBF_LOOP_ALIGN);
4770+
newBlock->bbFlags &= ~(BBF_LOOP_HEAD | BBF_FUNCLET_BEG | BBF_LOOP_PREHEADER | BBF_KEEP_BBJ_ALWAYS | BBF_PATCHPOINT |
4771+
BBF_BACKWARD_JUMP_TARGET | BBF_LOOP_ALIGN);
47754772

47764773
// Remove the GC safe bit on the new block. It seems clear that if we split 'curr' at the end,
47774774
// such that all the code is left in 'curr', and 'newBlock' just gets the control flow, then

0 commit comments

Comments
 (0)