From 5fda47434cecc590095e9aef3c4e560b7b7ebb47 Mon Sep 17 00:00:00 2001 From: Aman Khalid Date: Mon, 18 Mar 2024 18:21:23 +0000 Subject: [PATCH] JIT: Remove BBF_NONE_QUIRK (#99907) --- src/coreclr/jit/block.cpp | 4 --- src/coreclr/jit/block.h | 8 ++---- src/coreclr/jit/fgbasic.cpp | 24 ++--------------- src/coreclr/jit/fginline.cpp | 7 ----- src/coreclr/jit/fgopt.cpp | 29 --------------------- src/coreclr/jit/fgprofile.cpp | 4 +-- src/coreclr/jit/flowgraph.cpp | 2 +- src/coreclr/jit/helperexpansion.cpp | 5 ---- src/coreclr/jit/importer.cpp | 20 +------------- src/coreclr/jit/indirectcalltransformer.cpp | 6 +---- src/coreclr/jit/jiteh.cpp | 12 +++------ src/coreclr/jit/loopcloning.cpp | 7 ----- src/coreclr/jit/lower.cpp | 20 +++----------- src/coreclr/jit/morph.cpp | 10 ++----- src/coreclr/jit/optimizebools.cpp | 1 - src/coreclr/jit/optimizer.cpp | 12 --------- src/coreclr/jit/patchpoint.cpp | 2 +- 17 files changed, 20 insertions(+), 153 deletions(-) diff --git a/src/coreclr/jit/block.cpp b/src/coreclr/jit/block.cpp index 1e7750997a103..7bc07a5477525 100644 --- a/src/coreclr/jit/block.cpp +++ b/src/coreclr/jit/block.cpp @@ -583,7 +583,6 @@ void BasicBlock::dspFlags() const {BBF_HAS_ALIGN, "has-align"}, {BBF_HAS_MDARRAYREF, "mdarr"}, {BBF_NEEDS_GCPOLL, "gcpoll"}, - {BBF_NONE_QUIRK, "q"}, }; bool first = true; @@ -941,9 +940,6 @@ void BasicBlock::TransferTarget(BasicBlock* from) SetCond(from->bbTrueEdge, from->bbFalseEdge); break; case BBJ_ALWAYS: - SetKindAndTargetEdge(BBJ_ALWAYS, from->bbTargetEdge); - CopyFlags(from, BBF_NONE_QUIRK); - break; case BBJ_CALLFINALLY: case BBJ_CALLFINALLYRET: case BBJ_EHCATCHRET: diff --git a/src/coreclr/jit/block.h b/src/coreclr/jit/block.h index ae881d99f7361..52081e9bb779a 100644 --- a/src/coreclr/jit/block.h +++ b/src/coreclr/jit/block.h @@ -456,11 +456,7 @@ enum BasicBlockFlags : unsigned __int64 BBF_RECURSIVE_TAILCALL = MAKE_BBFLAG(37), // Block has recursive tailcall that may turn into a loop BBF_NO_CSE_IN = MAKE_BBFLAG(38), // Block should kill off any incoming CSE BBF_CAN_ADD_PRED = MAKE_BBFLAG(39), // Ok to add pred edge to this block, even when "safe" edge creation disabled - BBF_NONE_QUIRK = MAKE_BBFLAG(40), // Block was created as a BBJ_ALWAYS to the next block, - // and should be treated as if it falls through. - // This is just to reduce diffs from removing BBJ_NONE. - // (TODO: Remove this quirk after refactoring Compiler::fgFindInsertPoint) - BBF_HAS_VALUE_PROFILE = MAKE_BBFLAG(41), // Block has a node that needs a value probing + BBF_HAS_VALUE_PROFILE = MAKE_BBFLAG(40), // Block has a node that needs a value probing // The following are sets of flags. @@ -486,7 +482,7 @@ enum BasicBlockFlags : unsigned __int64 // TODO: Should BBF_RUN_RARELY be added to BBF_SPLIT_GAINED ? BBF_SPLIT_GAINED = BBF_DONT_REMOVE | BBF_HAS_JMP | BBF_BACKWARD_JUMP | BBF_HAS_IDX_LEN | BBF_HAS_MD_IDX_LEN | BBF_PROF_WEIGHT | \ - BBF_HAS_NEWOBJ | BBF_KEEP_BBJ_ALWAYS | BBF_CLONED_FINALLY_END | BBF_HAS_NULLCHECK | BBF_HAS_HISTOGRAM_PROFILE | BBF_HAS_VALUE_PROFILE | BBF_HAS_MDARRAYREF | BBF_NEEDS_GCPOLL | BBF_NONE_QUIRK, + BBF_HAS_NEWOBJ | BBF_KEEP_BBJ_ALWAYS | BBF_CLONED_FINALLY_END | BBF_HAS_NULLCHECK | BBF_HAS_HISTOGRAM_PROFILE | BBF_HAS_VALUE_PROFILE | BBF_HAS_MDARRAYREF | BBF_NEEDS_GCPOLL, // Flags that must be propagated to a new block if code is copied from a block to a new block. These are flags that // limit processing of a block if the code in question doesn't exist. This is conservative; we might not diff --git a/src/coreclr/jit/fgbasic.cpp b/src/coreclr/jit/fgbasic.cpp index c98c7a1281994..bfbf5dc95ff8c 100644 --- a/src/coreclr/jit/fgbasic.cpp +++ b/src/coreclr/jit/fgbasic.cpp @@ -239,7 +239,7 @@ bool Compiler::fgEnsureFirstBBisScratch() noway_assert(fgLastBB != nullptr); // Set the expected flags - block->SetFlags(BBF_INTERNAL | BBF_IMPORTED | BBF_NONE_QUIRK); + block->SetFlags(BBF_INTERNAL | BBF_IMPORTED); // This new first BB has an implicit ref, and no others. // @@ -3503,7 +3503,6 @@ unsigned Compiler::fgMakeBasicBlocks(const BYTE* codeAddr, IL_OFFSET codeSize, F // Jump to the next block jmpKind = BBJ_ALWAYS; jmpAddr = nxtBBoffs; - bbFlags |= BBF_NONE_QUIRK; } assert(jmpKind != BBJ_COUNT); @@ -4806,7 +4805,6 @@ BasicBlock* Compiler::fgSplitBlockAtEnd(BasicBlock* curr) newBlock->TransferTarget(curr); curr->SetKindAndTargetEdge(BBJ_ALWAYS, newEdge); - curr->SetFlags(BBF_NONE_QUIRK); assert(curr->JumpsToNext()); return newBlock; @@ -4898,7 +4896,6 @@ BasicBlock* Compiler::fgSplitBlockBeforeTree( // prevBb should flow into block assert(prevBb->KindIs(BBJ_ALWAYS) && prevBb->JumpsToNext() && prevBb->NextIs(block)); - prevBb->SetFlags(BBF_NONE_QUIRK); return block; } @@ -5031,9 +5028,7 @@ BasicBlock* Compiler::fgSplitEdge(BasicBlock* curr, BasicBlock* succ) // an immediately following block of a BBJ_SWITCH (which has // no fall-through path). For this case, simply insert a new // fall-through block after 'curr'. - // TODO-NoFallThrough: Once false target can diverge from bbNext, this will be unnecessary for BBJ_COND newBlock = fgNewBBafter(BBJ_ALWAYS, curr, true /* extendRegion */); - newBlock->SetFlags(BBF_NONE_QUIRK); } else { @@ -5484,10 +5479,6 @@ BasicBlock* Compiler::fgConnectFallThrough(BasicBlock* bSrc, BasicBlock* bDst) JITDUMP("Added an unconditional jump to " FMT_BB " after block " FMT_BB "\n", jmpBlk->GetTarget()->bbNum, bSrc->bbNum); } - else if (bSrc->KindIs(BBJ_ALWAYS) && bSrc->HasInitializedTarget() && bSrc->JumpsToNext()) - { - bSrc->SetFlags(BBF_NONE_QUIRK); - } return jmpBlk; } @@ -5944,7 +5935,7 @@ BasicBlock* Compiler::fgRelocateEHRange(unsigned regionIndex, FG_RELOCATE_TYPE r // Because this relies on ebdEnclosingTryIndex and ebdEnclosingHndIndex #endif // DEBUG -#else // !FEATURE_EH_FUNCLETS +#else // !FEATURE_EH_FUNCLETS for (XTnum = 0, HBtab = compHndBBtab; XTnum < compHndBBtabCount; XTnum++, HBtab++) { @@ -5994,17 +5985,6 @@ BasicBlock* Compiler::fgRelocateEHRange(unsigned regionIndex, FG_RELOCATE_TYPE r // We have decided to insert the block(s) after fgLastBlock fgMoveBlocksAfter(bStart, bLast, insertAfterBlk); - - if (bPrev->KindIs(BBJ_ALWAYS) && bPrev->JumpsToNext()) - { - bPrev->SetFlags(BBF_NONE_QUIRK); - } - - if (bLast->KindIs(BBJ_ALWAYS) && bLast->JumpsToNext()) - { - bLast->SetFlags(BBF_NONE_QUIRK); - } - #endif // !FEATURE_EH_FUNCLETS goto DONE; diff --git a/src/coreclr/jit/fginline.cpp b/src/coreclr/jit/fginline.cpp index b72b99228fbc7..4c44bbc6bf33a 100644 --- a/src/coreclr/jit/fginline.cpp +++ b/src/coreclr/jit/fginline.cpp @@ -677,7 +677,6 @@ class SubstitutePlaceholdersAndDevirtualizeWalker : public GenTreeVisitorfgRemoveRefPred(block->GetTrueEdge()); block->SetKindAndTargetEdge(BBJ_ALWAYS, block->GetFalseEdge()); - block->SetFlags(BBF_NONE_QUIRK); } else { @@ -1536,11 +1535,6 @@ void Compiler::fgInsertInlineeBlocks(InlineInfo* pInlineInfo) FlowEdge* const newEdge = fgAddRefPred(bottomBlock, block); block->SetKindAndTargetEdge(BBJ_ALWAYS, newEdge); - - if (block == InlineeCompiler->fgLastBB) - { - block->SetFlags(BBF_NONE_QUIRK); - } } } @@ -1554,7 +1548,6 @@ void Compiler::fgInsertInlineeBlocks(InlineInfo* pInlineInfo) fgRedirectTargetEdge(topBlock, InlineeCompiler->fgFirstBB); topBlock->SetNext(InlineeCompiler->fgFirstBB); - topBlock->SetFlags(BBF_NONE_QUIRK); InlineeCompiler->fgLastBB->SetNext(bottomBlock); // diff --git a/src/coreclr/jit/fgopt.cpp b/src/coreclr/jit/fgopt.cpp index 8fcfdfc62c72b..4c6bf73b94f0b 100644 --- a/src/coreclr/jit/fgopt.cpp +++ b/src/coreclr/jit/fgopt.cpp @@ -620,7 +620,6 @@ PhaseStatus Compiler::fgPostImportationCleanup() else { FlowEdge* const newEdge = fgAddRefPred(newTryEntry->Next(), newTryEntry); - newTryEntry->SetFlags(BBF_NONE_QUIRK); newTryEntry->SetKindAndTargetEdge(BBJ_ALWAYS, newEdge); } @@ -1309,17 +1308,6 @@ void Compiler::fgCompactBlocks(BasicBlock* block, BasicBlock* bNext) assert(block->KindIs(bNext->GetKind())); - if (block->KindIs(BBJ_ALWAYS)) - { - // Propagate BBF_NONE_QUIRK flag - block->CopyFlags(bNext, BBF_NONE_QUIRK); - } - else - { - // It's no longer a BBJ_ALWAYS; remove the BBF_NONE_QUIRK flag. - block->RemoveFlags(BBF_NONE_QUIRK); - } - #if DEBUG if (verbose && 0) { @@ -2613,9 +2601,6 @@ void Compiler::fgRemoveConditionalJump(BasicBlock* block) block->SetKindAndTargetEdge(BBJ_ALWAYS, block->GetTrueEdge()); assert(block->TargetIs(target)); - // TODO-NoFallThrough: Set BBF_NONE_QUIRK only when false target is the next block - block->SetFlags(BBF_NONE_QUIRK); - /* Update bbRefs and bbNum - Conditional predecessors to the same * block are counted twice so we have to remove one of them */ @@ -4314,16 +4299,6 @@ bool Compiler::fgReorderBlocks(bool useProfile) const bool bStartPrevJumpsToNext = bStartPrev->KindIs(BBJ_ALWAYS) && bStartPrev->JumpsToNext(); fgUnlinkRange(bStart, bEnd); - // If bStartPrev is a BBJ_ALWAYS to some block after bStart, unlinking bStart can move - // bStartPrev's jump destination up, making bStartPrev jump to the next block for now. - // This can lead us to make suboptimal decisions in Compiler::fgFindInsertPoint, - // so make sure the BBF_NONE_QUIRK flag is unset for bStartPrev beforehand. - // TODO: Remove quirk. - if (bStartPrev->KindIs(BBJ_ALWAYS) && (bStartPrevJumpsToNext != bStartPrev->JumpsToNext())) - { - bStartPrev->RemoveFlags(BBF_NONE_QUIRK); - } - if (insertAfterBlk == nullptr) { // Find new location for the unlinked block(s) @@ -4840,10 +4815,6 @@ bool Compiler::fgUpdateFlowGraph(bool doTailDuplication /* = false */, bool isPh if (bDest == bNext) { // Skip jump optimizations, and try to compact block and bNext later - if (!block->isBBCallFinallyPairTail()) - { - block->SetFlags(BBF_NONE_QUIRK); - } bDest = nullptr; } } diff --git a/src/coreclr/jit/fgprofile.cpp b/src/coreclr/jit/fgprofile.cpp index 4693107168ba6..ff86fcff106cc 100644 --- a/src/coreclr/jit/fgprofile.cpp +++ b/src/coreclr/jit/fgprofile.cpp @@ -508,7 +508,7 @@ void BlockCountInstrumentor::RelocateProbes() if (criticalPreds.Height() > 0) { BasicBlock* const intermediary = m_comp->fgNewBBbefore(BBJ_ALWAYS, block, /* extendRegion */ true); - intermediary->SetFlags(BBF_IMPORTED | BBF_MARKED | BBF_NONE_QUIRK); + intermediary->SetFlags(BBF_IMPORTED | BBF_MARKED); intermediary->inheritWeight(block); FlowEdge* const newEdge = m_comp->fgAddRefPred(block, intermediary); intermediary->SetTargetEdge(newEdge); @@ -1679,7 +1679,7 @@ void EfficientEdgeCountInstrumentor::RelocateProbes() if (criticalPreds.Height() > 0) { BasicBlock* intermediary = m_comp->fgNewBBbefore(BBJ_ALWAYS, block, /* extendRegion */ true); - intermediary->SetFlags(BBF_IMPORTED | BBF_NONE_QUIRK); + intermediary->SetFlags(BBF_IMPORTED); intermediary->inheritWeight(block); FlowEdge* const newEdge = m_comp->fgAddRefPred(block, intermediary); intermediary->SetTargetEdge(newEdge); diff --git a/src/coreclr/jit/flowgraph.cpp b/src/coreclr/jit/flowgraph.cpp index cbdabfd930c7e..e4a253c365da8 100644 --- a/src/coreclr/jit/flowgraph.cpp +++ b/src/coreclr/jit/flowgraph.cpp @@ -2775,7 +2775,7 @@ void Compiler::fgInsertFuncletPrologBlock(BasicBlock* block) /* Allocate a new basic block */ BasicBlock* newHead = BasicBlock::New(this); - newHead->SetFlags(BBF_INTERNAL | BBF_NONE_QUIRK); + newHead->SetFlags(BBF_INTERNAL); newHead->inheritWeight(block); newHead->bbRefs = 0; diff --git a/src/coreclr/jit/helperexpansion.cpp b/src/coreclr/jit/helperexpansion.cpp index eb203cbd3f68c..94e9d01c59e05 100644 --- a/src/coreclr/jit/helperexpansion.cpp +++ b/src/coreclr/jit/helperexpansion.cpp @@ -382,7 +382,6 @@ bool Compiler::fgExpandRuntimeLookupsForCall(BasicBlock** pBlock, Statement* stm FlowEdge* const newEdge = fgAddRefPred(block, fallbackBb); fallbackBb->SetTargetEdge(newEdge); assert(fallbackBb->JumpsToNext()); - fallbackBb->SetFlags(BBF_NONE_QUIRK); } if (needsSizeCheck) @@ -1465,7 +1464,6 @@ bool Compiler::fgExpandStaticInitForCall(BasicBlock** pBlock, Statement* stmt, G // Redirect prevBb from block to isInitedBb fgRedirectTargetEdge(prevBb, isInitedBb); - prevBb->SetFlags(BBF_NONE_QUIRK); assert(prevBb->JumpsToNext()); { @@ -1473,7 +1471,6 @@ bool Compiler::fgExpandStaticInitForCall(BasicBlock** pBlock, Statement* stmt, G FlowEdge* const newEdge = fgAddRefPred(block, helperCallBb); helperCallBb->SetTargetEdge(newEdge); assert(helperCallBb->JumpsToNext()); - helperCallBb->SetFlags(BBF_NONE_QUIRK); } { @@ -1790,7 +1787,6 @@ bool Compiler::fgVNBasedIntrinsicExpansionForCall_ReadUtf8(BasicBlock** pBlock, // // Redirect prevBb to lengthCheckBb fgRedirectTargetEdge(prevBb, lengthCheckBb); - prevBb->SetFlags(BBF_NONE_QUIRK); assert(prevBb->JumpsToNext()); { @@ -1810,7 +1806,6 @@ bool Compiler::fgVNBasedIntrinsicExpansionForCall_ReadUtf8(BasicBlock** pBlock, FlowEdge* const newEdge = fgAddRefPred(block, fastpathBb); fastpathBb->SetTargetEdge(newEdge); assert(fastpathBb->JumpsToNext()); - fastpathBb->SetFlags(BBF_NONE_QUIRK); } // diff --git a/src/coreclr/jit/importer.cpp b/src/coreclr/jit/importer.cpp index 605c318ec98b8..1117494c5018e 100644 --- a/src/coreclr/jit/importer.cpp +++ b/src/coreclr/jit/importer.cpp @@ -2052,7 +2052,7 @@ BasicBlock* Compiler::impPushCatchArgOnStack(BasicBlock* hndBlk, CORINFO_CLASS_H // Create extra basic block for the spill // BasicBlock* newBlk = fgNewBBbefore(BBJ_ALWAYS, hndBlk, /* extendRegion */ true); - newBlk->SetFlags(BBF_IMPORTED | BBF_DONT_REMOVE | BBF_NONE_QUIRK); + newBlk->SetFlags(BBF_IMPORTED | BBF_DONT_REMOVE); newBlk->inheritWeight(hndBlk); newBlk->bbCodeOffs = hndBlk->bbCodeOffs; @@ -7233,10 +7233,6 @@ void Compiler::impImportBlockCode(BasicBlock* block) fgRemoveRefPred(block->GetFalseEdge()); block->SetKindAndTargetEdge(BBJ_ALWAYS, block->GetTrueEdge()); - // TODO-NoFallThrough: Once false target can diverge from bbNext, it may not make sense to - // set BBF_NONE_QUIRK - block->SetFlags(BBF_NONE_QUIRK); - jumpToNextOptimization = true; } else if (block->KindIs(BBJ_ALWAYS) && block->JumpsToNext()) @@ -7310,15 +7306,10 @@ void Compiler::impImportBlockCode(BasicBlock* block) } else { - // TODO-NoFallThrough: Update once false target can diverge from bbNext assert(block->NextIs(block->GetFalseTarget())); JITDUMP("\nThe block jumps to the next " FMT_BB "\n", block->Next()->bbNum); fgRemoveRefPred(block->GetTrueEdge()); block->SetKindAndTargetEdge(BBJ_ALWAYS, block->GetFalseEdge()); - - // TODO-NoFallThrough: Once false target can diverge from bbNext, it may not make sense - // to set BBF_NONE_QUIRK - block->SetFlags(BBF_NONE_QUIRK); } } @@ -7495,10 +7486,6 @@ void Compiler::impImportBlockCode(BasicBlock* block) fgRemoveRefPred(block->GetFalseEdge()); block->SetKindAndTargetEdge(BBJ_ALWAYS, block->GetTrueEdge()); - // TODO-NoFallThrough: Once false target can diverge from bbNext, it may not make sense to - // set BBF_NONE_QUIRK - block->SetFlags(BBF_NONE_QUIRK); - jumpToNextOptimization = true; } else if (block->KindIs(BBJ_ALWAYS) && block->JumpsToNext()) @@ -7591,11 +7578,6 @@ void Compiler::impImportBlockCode(BasicBlock* block) } assert(foundVal); - if (block->JumpsToNext()) - { - block->SetFlags(BBF_NONE_QUIRK); - } - #ifdef DEBUG if (verbose) { diff --git a/src/coreclr/jit/indirectcalltransformer.cpp b/src/coreclr/jit/indirectcalltransformer.cpp index 9220df5e3dc85..87120014abba5 100644 --- a/src/coreclr/jit/indirectcalltransformer.cpp +++ b/src/coreclr/jit/indirectcalltransformer.cpp @@ -377,8 +377,7 @@ class IndirectCallTransformer { assert(checkIdx == 0); - checkBlock = CreateAndInsertBasicBlock(BBJ_ALWAYS, currBlock); - checkBlock->SetFlags(BBF_NONE_QUIRK); + checkBlock = CreateAndInsertBasicBlock(BBJ_ALWAYS, currBlock); GenTree* fatPointerMask = new (compiler, GT_CNS_INT) GenTreeIntCon(TYP_I_IMPL, FAT_POINTER_MASK); GenTree* fptrAddressCopy = compiler->gtCloneExpr(fptrAddress); GenTree* fatPointerAnd = compiler->gtNewOperNode(GT_AND, TYP_I_IMPL, fptrAddressCopy, fatPointerMask); @@ -407,7 +406,6 @@ class IndirectCallTransformer virtual void CreateElse() { elseBlock = CreateAndInsertBasicBlock(BBJ_ALWAYS, thenBlock); - elseBlock->SetFlags(BBF_NONE_QUIRK); GenTree* fixedFptrAddress = GetFixedFptrAddress(); GenTree* actualCallAddress = compiler->gtNewIndir(pointerType, fixedFptrAddress); @@ -1061,7 +1059,6 @@ class IndirectCallTransformer assert(checkBlock->KindIs(BBJ_ALWAYS)); FlowEdge* const checkThenEdge = compiler->fgAddRefPred(thenBlock, checkBlock); checkBlock->SetTargetEdge(checkThenEdge); - checkBlock->SetFlags(BBF_NONE_QUIRK); assert(checkBlock->JumpsToNext()); // SetTargetEdge() gave checkThenEdge a (correct) likelihood of 1.0. @@ -1084,7 +1081,6 @@ class IndirectCallTransformer { elseBlock = CreateAndInsertBasicBlock(BBJ_ALWAYS, thenBlock); elseBlock->CopyFlags(currBlock, BBF_SPLIT_GAINED); - elseBlock->SetFlags(BBF_NONE_QUIRK); // We computed the "then" likelihood in CreateThen, so we // just use that to figure out the "else" likelihood. diff --git a/src/coreclr/jit/jiteh.cpp b/src/coreclr/jit/jiteh.cpp index f4b651559ee0f..75749e50fbd3b 100644 --- a/src/coreclr/jit/jiteh.cpp +++ b/src/coreclr/jit/jiteh.cpp @@ -2025,7 +2025,7 @@ bool Compiler::fgNormalizeEHCase1() newHndStart->bbCodeOffs = handlerStart->bbCodeOffs; newHndStart->bbCodeOffsEnd = newHndStart->bbCodeOffs; // code size = 0. TODO: use BAD_IL_OFFSET instead? newHndStart->inheritWeight(handlerStart); - newHndStart->SetFlags(BBF_DONT_REMOVE | BBF_INTERNAL | BBF_NONE_QUIRK); + newHndStart->SetFlags(BBF_DONT_REMOVE | BBF_INTERNAL); modified = true; #ifdef DEBUG @@ -2194,12 +2194,8 @@ bool Compiler::fgNormalizeEHCase2() // Note that we don't need to clear any flags on the old try start, since it is still a 'try' // start. - newTryStart->SetFlags(BBF_DONT_REMOVE | BBF_INTERNAL | BBF_NONE_QUIRK); - - if (insertBeforeBlk->HasFlag(BBF_BACKWARD_JUMP_TARGET)) - { - newTryStart->SetFlags(BBF_BACKWARD_JUMP_TARGET); - } + newTryStart->SetFlags(BBF_DONT_REMOVE | BBF_INTERNAL); + newTryStart->CopyFlags(insertBeforeBlk, BBF_BACKWARD_JUMP_TARGET); // Now we need to split any flow edges targeting the old try begin block between the old // and new block. Note that if we are handling a multiply-nested 'try', we may have already @@ -2682,7 +2678,7 @@ bool Compiler::fgNormalizeEHCase3() newLast->bbCodeOffs = insertAfterBlk->bbCodeOffsEnd; newLast->bbCodeOffsEnd = newLast->bbCodeOffs; // code size = 0. TODO: use BAD_IL_OFFSET instead? newLast->inheritWeight(insertAfterBlk); - newLast->SetFlags(BBF_INTERNAL | BBF_NONE_QUIRK); + newLast->SetFlags(BBF_INTERNAL); FlowEdge* const newEdge = fgAddRefPred(newLast, insertAfterBlk); insertAfterBlk->SetKindAndTargetEdge(BBJ_ALWAYS, newEdge); diff --git a/src/coreclr/jit/loopcloning.cpp b/src/coreclr/jit/loopcloning.cpp index 5f51c77eb2384..7283cc0d1d88c 100644 --- a/src/coreclr/jit/loopcloning.cpp +++ b/src/coreclr/jit/loopcloning.cpp @@ -1976,11 +1976,6 @@ void Compiler::optCloneLoop(FlowGraphNaturalLoop* loop, LoopCloneContext* contex JITDUMP("Adding " FMT_BB " after " FMT_BB "\n", fastPreheader->bbNum, preheader->bbNum); fastPreheader->bbWeight = fastPreheader->isRunRarely() ? BB_ZERO_WEIGHT : ambientWeight; - if (fastPreheader->NextIs(loop->GetHeader())) - { - fastPreheader->SetFlags(BBF_NONE_QUIRK); - } - assert(preheader->KindIs(BBJ_ALWAYS)); assert(preheader->TargetIs(loop->GetHeader())); @@ -2073,8 +2068,6 @@ void Compiler::optCloneLoop(FlowGraphNaturalLoop* loop, LoopCloneContext* contex preheader->SetTargetEdge(newEdge); } - preheader->SetFlags(BBF_NONE_QUIRK); - // And make sure we insert a pred link for the final fallthrough into the fast preheader. assert(condLast->NextIs(fastPreheader)); FlowEdge* const falseEdge = fgAddRefPred(fastPreheader, condLast); diff --git a/src/coreclr/jit/lower.cpp b/src/coreclr/jit/lower.cpp index 591c2b9165879..935479beff01b 100644 --- a/src/coreclr/jit/lower.cpp +++ b/src/coreclr/jit/lower.cpp @@ -861,11 +861,6 @@ GenTree* Lowering::LowerSwitch(GenTree* node) noway_assert(comp->opts.OptimizationDisabled()); originalSwitchBB->SetKindAndTargetEdge(BBJ_ALWAYS, jumpTab[0]); - if (originalSwitchBB->JumpsToNext()) - { - originalSwitchBB->SetFlags(BBF_NONE_QUIRK); - } - // Remove extra predecessor links if there was more than one case. for (unsigned i = 1; i < jumpCnt; ++i) { @@ -1026,11 +1021,6 @@ GenTree* Lowering::LowerSwitch(GenTree* node) } afterDefaultCondBlock->SetKindAndTargetEdge(BBJ_ALWAYS, uniqueSucc); - - if (afterDefaultCondBlock->JumpsToNext()) - { - afterDefaultCondBlock->SetFlags(BBF_NONE_QUIRK); - } } // If the number of possible destinations is small enough, we proceed to expand the switch // into a series of conditional branches, otherwise we follow the jump table based switch @@ -1101,8 +1091,7 @@ GenTree* Lowering::LowerSwitch(GenTree* node) // if (fUsedAfterDefaultCondBlock) { - BasicBlock* newBlock = comp->fgNewBBafter(BBJ_ALWAYS, currentBlock, true); - newBlock->SetFlags(BBF_NONE_QUIRK); + BasicBlock* newBlock = comp->fgNewBBafter(BBJ_ALWAYS, currentBlock, true); FlowEdge* const falseEdge = comp->fgAddRefPred(newBlock, currentBlock); // The fall-through predecessor. // We set the true edge likelihood earlier, use that to figure out the false edge likelihood @@ -1131,10 +1120,9 @@ GenTree* Lowering::LowerSwitch(GenTree* node) if (oldEdge->getDupCount() > 0) { BasicBlock* const newBlock = comp->fgNewBBafter(BBJ_ALWAYS, currentBlock, true); - newBlock->SetFlags(BBF_NONE_QUIRK); - FlowEdge* const newEdge = comp->fgAddRefPred(newBlock, currentBlock); - currentBlock = newBlock; - currentBBRange = &LIR::AsRange(currentBlock); + FlowEdge* const newEdge = comp->fgAddRefPred(newBlock, currentBlock); + currentBlock = newBlock; + currentBBRange = &LIR::AsRange(currentBlock); afterDefaultCondBlock->SetKindAndTargetEdge(BBJ_ALWAYS, newEdge); } diff --git a/src/coreclr/jit/morph.cpp b/src/coreclr/jit/morph.cpp index 90d599e498406..1c9fc51d48567 100644 --- a/src/coreclr/jit/morph.cpp +++ b/src/coreclr/jit/morph.cpp @@ -13229,7 +13229,6 @@ Compiler::FoldResult Compiler::fgFoldConditional(BasicBlock* block) edgeTaken = block->GetFalseEdge(); block->SetKindAndTargetEdge(BBJ_ALWAYS, block->GetFalseEdge()); - block->SetFlags(BBF_NONE_QUIRK); } if (fgHaveValidEdgeWeights) @@ -13401,11 +13400,6 @@ Compiler::FoldResult Compiler::fgFoldConditional(BasicBlock* block) } assert(foundVal); - if (block->JumpsToNext()) - { - block->SetFlags(BBF_NONE_QUIRK); - } - #ifdef DEBUG if (verbose) { @@ -14659,8 +14653,8 @@ bool Compiler::fgExpandQmarkStmt(BasicBlock* block, Statement* stmt) assert(condBlock->JumpsToNext()); assert(elseBlock->JumpsToNext()); - condBlock->SetFlags(propagateFlagsToAll | BBF_NONE_QUIRK); - elseBlock->SetFlags(propagateFlagsToAll | BBF_NONE_QUIRK); + condBlock->SetFlags(propagateFlagsToAll); + elseBlock->SetFlags(propagateFlagsToAll); BasicBlock* thenBlock = nullptr; if (hasTrueExpr && hasFalseExpr) diff --git a/src/coreclr/jit/optimizebools.cpp b/src/coreclr/jit/optimizebools.cpp index 4363e946af51d..d456cb3793f5e 100644 --- a/src/coreclr/jit/optimizebools.cpp +++ b/src/coreclr/jit/optimizebools.cpp @@ -1031,7 +1031,6 @@ bool OptBoolsDsc::optOptimizeCompareChainCondBlock() // Update the flow. m_comp->fgRemoveRefPred(m_b1->GetTrueEdge()); m_b1->SetKindAndTargetEdge(BBJ_ALWAYS, m_b1->GetFalseEdge()); - m_b1->SetFlags(BBF_NONE_QUIRK); // Fixup flags. m_b2->CopyFlags(m_b1, BBF_COPY_PROPAGATE); diff --git a/src/coreclr/jit/optimizer.cpp b/src/coreclr/jit/optimizer.cpp index 993ebe6cbb374..8306cf40a8aab 100644 --- a/src/coreclr/jit/optimizer.cpp +++ b/src/coreclr/jit/optimizer.cpp @@ -603,10 +603,6 @@ void Compiler::optSetMappedBlockTargets(BasicBlock* blk, BasicBlock* newBlk, Blo switch (blk->GetKind()) { case BBJ_ALWAYS: - // Copy BBF_NONE_QUIRK flag for BBJ_ALWAYS blocks only - newBlk->CopyFlags(blk, BBF_NONE_QUIRK); - - FALLTHROUGH; case BBJ_CALLFINALLY: case BBJ_CALLFINALLYRET: case BBJ_LEAVE: @@ -2256,7 +2252,6 @@ bool Compiler::optInvertWhileLoop(BasicBlock* block) bNewCond->SetFalseEdge(newCondTopEdge); fgRedirectTargetEdge(block, bNewCond); - block->SetFlags(BBF_NONE_QUIRK); assert(block->JumpsToNext()); // Move all predecessor edges that look like loop entry edges to point to the new cloned condition @@ -3023,12 +3018,6 @@ bool Compiler::optCreatePreheader(FlowGraphNaturalLoop* loop) BasicBlock* preheader = fgNewBBbefore(BBJ_ALWAYS, insertBefore, false); preheader->SetFlags(BBF_INTERNAL); fgSetEHRegionForNewPreheaderOrExit(preheader); - - if (preheader->NextIs(header)) - { - preheader->SetFlags(BBF_NONE_QUIRK); - } - preheader->bbCodeOffs = insertBefore->bbCodeOffs; JITDUMP("Created new preheader " FMT_BB " for " FMT_LP "\n", preheader->bbNum, loop->GetIndex()); @@ -3153,7 +3142,6 @@ bool Compiler::optCanonicalizeExit(FlowGraphNaturalLoop* loop, BasicBlock* exit) #endif // FEATURE_EH_CALLFINALLY_THUNKS { newExit = fgNewBBbefore(BBJ_ALWAYS, exit, false); - newExit->SetFlags(BBF_NONE_QUIRK); fgSetEHRegionForNewPreheaderOrExit(newExit); } diff --git a/src/coreclr/jit/patchpoint.cpp b/src/coreclr/jit/patchpoint.cpp index 158154583f779..5a27367906774 100644 --- a/src/coreclr/jit/patchpoint.cpp +++ b/src/coreclr/jit/patchpoint.cpp @@ -146,7 +146,7 @@ class PatchpointTransformer // Update flow and flags block->SetFlags(BBF_INTERNAL); - helperBlock->SetFlags(BBF_BACKWARD_JUMP | BBF_NONE_QUIRK); + helperBlock->SetFlags(BBF_BACKWARD_JUMP); assert(block->TargetIs(remainderBlock)); FlowEdge* const falseEdge = compiler->fgAddRefPred(helperBlock, block);