diff options
author | Bruce Forstall <brucefo@microsoft.com> | 2021-04-15 19:45:51 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-15 19:45:51 +0300 |
commit | a2e36a7693967d04ca0548e2b825d7ec363bd1f3 (patch) | |
tree | 94934398db5ab0f1a3435c4afa9dc68862ed5db7 /src/coreclr/jit/flowgraph.cpp | |
parent | 8f491fc4efdf229a78f687b896b8a46eb2a2ce03 (diff) |
Simplify JIT label handling (#51208)
* Simplify JIT label handling
Remove the BBF_JMP_TARGET flag that was set early and attempted
to be maintained all through compilation. Instead, use
BBF_USE_LABEL to indicate to the emitter where we need labels.
Also, stop setting and maintaining BBF_USE_LABEL early.
Add a pass over the blocks when preparing for codegen that sets
most of the necessary BBF_USE_LABEL flags. This flag will never
be set before codegen. A few places set the flag after codegen starts,
namely `genCreateTempLabel` and BBJ_COND handling for alignment.
Note that this flag must be set before the block is processed for
codegen (and an insGroup is created).
Together, these changes make it easier to work with the flow graph
without worrying about maintaining these bits of information through
various optimizations.
Add a few more details about alignment processing to the dump.
There are a few code asm diffs due to alignment processing not previously
creating a label to help compute how large a loop is.
There are a lot of textual asm diffs due to there being (mostly)
fewer labels, plus some additional insGroup output. This can happen if
a block was labeled with `BBF_JMP_TARGET` or `BBF_USE_LABEL` before,
but didn't need to be, perhaps after some optimizations. Now, the flag is
never added in the first place.
There are a large number of GC info diffs. Labels are where GC info state
changes are recorded between codegen and the emitter. If we eliminate an
unnecessary emitter label, then we also eliminate a capture of the current
codegen GC state. Since the emitter is lazy at marking GC deaths, this
means that we see a lot of lengthened GC lifetimes -- until the next
label, or some other cause of GC kill. Often, you see a register kill
followed by register birth just disappear, and the register is maintained
alive across the interim.
* Remove loop align flag if we decide a loop is no longer a loop
Diffstat (limited to 'src/coreclr/jit/flowgraph.cpp')
-rw-r--r-- | src/coreclr/jit/flowgraph.cpp | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/src/coreclr/jit/flowgraph.cpp b/src/coreclr/jit/flowgraph.cpp index 3210718d041..046f939772b 100644 --- a/src/coreclr/jit/flowgraph.cpp +++ b/src/coreclr/jit/flowgraph.cpp @@ -430,7 +430,6 @@ BasicBlock* Compiler::fgCreateGCPoll(GCPollType pollType, BasicBlock* block) top->bbJumpDest = bottom; top->bbJumpKind = BBJ_COND; - bottom->bbFlags |= BBF_JMP_TARGET; // Bottom has Top and Poll as its predecessors. Poll has just Top as a predecessor. fgAddRefPred(bottom, poll); @@ -1748,9 +1747,9 @@ void Compiler::fgAddSyncMethodEnterExit() // EH regions in fgFindBasicBlocks(). Note that the try has no enclosing // handler, and the fault has no enclosing try. - tryBegBB->bbFlags |= BBF_HAS_LABEL | BBF_DONT_REMOVE | BBF_TRY_BEG | BBF_IMPORTED; + tryBegBB->bbFlags |= BBF_DONT_REMOVE | BBF_TRY_BEG | BBF_IMPORTED; - faultBB->bbFlags |= BBF_HAS_LABEL | BBF_DONT_REMOVE | BBF_IMPORTED; + faultBB->bbFlags |= BBF_DONT_REMOVE | BBF_IMPORTED; faultBB->bbCatchTyp = BBCT_FAULT; tryBegBB->setTryIndex(XTnew); @@ -2294,8 +2293,6 @@ private: newReturnBB->bbRefs = 1; // bbRefs gets update later, for now it should be 1 comp->fgReturnCount++; - newReturnBB->bbFlags |= (BBF_INTERNAL | BBF_JMP_TARGET); - noway_assert(newReturnBB->bbNext == nullptr); JITDUMP("\n newReturnBB [" FMT_BB "] created\n", newReturnBB->bbNum); @@ -3177,10 +3174,7 @@ void Compiler::fgInsertFuncletPrologBlock(BasicBlock* block) /* Allocate a new basic block */ BasicBlock* newHead = bbNewBasicBlock(BBJ_NONE); - - // In fgComputePreds() we set the BBF_JMP_TARGET and BBF_HAS_LABEL for all of the handler entry points - // - newHead->bbFlags |= (BBF_INTERNAL | BBF_JMP_TARGET | BBF_HAS_LABEL); + newHead->bbFlags |= BBF_INTERNAL; newHead->inheritWeight(block); newHead->bbRefs = 0; @@ -3221,8 +3215,7 @@ void Compiler::fgInsertFuncletPrologBlock(BasicBlock* block) assert(nullptr == fgGetPredForBlock(block, newHead)); fgAddRefPred(block, newHead); - assert((newHead->bbFlags & (BBF_INTERNAL | BBF_JMP_TARGET | BBF_HAS_LABEL)) == - (BBF_INTERNAL | BBF_JMP_TARGET | BBF_HAS_LABEL)); + assert((newHead->bbFlags & BBF_INTERNAL) == BBF_INTERNAL); } /***************************************************************************** @@ -3578,14 +3571,9 @@ void Compiler::fgDetermineFirstColdBlock() } } - if (firstColdBlock != nullptr) + for (block = firstColdBlock; block != nullptr; block = block->bbNext) { - firstColdBlock->bbFlags |= BBF_JMP_TARGET; - - for (block = firstColdBlock; block; block = block->bbNext) - { - block->bbFlags |= BBF_COLD; - } + block->bbFlags |= BBF_COLD; } EXIT:; @@ -3695,8 +3683,6 @@ BasicBlock* Compiler::fgAddCodeRef(BasicBlock* srcBlk, unsigned refData, Special newBlk = add->acdDstBlk = fgNewBBinRegion(jumpKinds[kind], srcBlk, /* runRarely */ true, /* insertAtEnd */ true); - add->acdDstBlk->bbFlags |= BBF_JMP_TARGET | BBF_HAS_LABEL; - #ifdef DEBUG if (verbose) { |