Skip to content

Commit

Permalink
JIT: Remove compaction renumbering quirk (#96478)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobbotsch authored Jan 5, 2024
1 parent 7113338 commit 9e31c21
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 55 deletions.
4 changes: 1 addition & 3 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4849,8 +4849,7 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
optLoopCount = 0;

// Old dominators and reachability sets are no longer valid.
fgDomsComputed = false;
fgCompactRenumberQuirk = true;
fgDomsComputed = false;
}

#ifdef DEBUG
Expand Down Expand Up @@ -5039,7 +5038,6 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
}

optLoopsRequirePreHeaders = false;
fgCompactRenumberQuirk = false;

#ifdef DEBUG
DoPhase(this, PHASE_STRESS_SPLIT_TREE, &Compiler::StressSplitTree);
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -5124,7 +5124,6 @@ class Compiler
bool fgReturnBlocksComputed; // Have we computed the return blocks list?
bool fgOptimizedFinally; // Did we optimize any try-finallys?
bool fgCanonicalizedFirstBB; // TODO-Quirk: did we end up canonicalizing first BB?
bool fgCompactRenumberQuirk; // TODO-Quirk: Should fgCompactBlocks renumber BBs above fgDomBBcount?

bool fgHasSwitch; // any BBJ_SWITCH jumps?

Expand Down
1 change: 0 additions & 1 deletion src/coreclr/jit/fgbasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ void Compiler::fgInit()
/* We haven't yet computed the dominator sets */
fgDomsComputed = false;
fgReturnBlocksComputed = false;
fgCompactRenumberQuirk = false;

#ifdef DEBUG
fgReachabilitySetsValid = false;
Expand Down
49 changes: 1 addition & 48 deletions src/coreclr/jit/fgopt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2356,54 +2356,7 @@ void Compiler::fgCompactBlocks(BasicBlock* block, BasicBlock* bNext)
block->RemoveFlags(BBF_NONE_QUIRK);
}

// If we're collapsing a block created after the dominators are
// computed, copy block number the block and reuse dominator
// information from bNext to block.
//
// Note we have to do this renumbering after the full set of pred list
// updates above, since those updates rely on stable bbNums; if we renumber
// before the updates, we can create pred lists with duplicate m_block->bbNum
// values (though different m_blocks).
//
if ((fgDomsComputed || fgCompactRenumberQuirk) && (block->bbNum > fgDomBBcount))
{
if (fgDomsComputed)
{
assert(fgReachabilitySetsValid);
BlockSetOps::Assign(this, block->bbReach, bNext->bbReach);
BlockSetOps::ClearD(this, bNext->bbReach);

block->bbIDom = bNext->bbIDom;
bNext->bbIDom = nullptr;

// In this case, there's no need to update the preorder and postorder numbering
// since we're changing the bbNum, this makes the basic block all set.
//
JITDUMP("Renumbering " FMT_BB " to be " FMT_BB " to preserve dominator information\n", block->bbNum,
bNext->bbNum);
}
else
{
// TODO-Quirk: Remove
JITDUMP("Renumbering " FMT_BB " to be " FMT_BB " for a quirk\n", block->bbNum, bNext->bbNum);
}

block->bbNum = bNext->bbNum;

// Because we may have reordered pred lists when we swapped in
// block for bNext above, we now need to re-reorder pred lists
// to reflect the bbNum update.
//
// This process of reordering and re-reordering could likely be avoided
// via a different update strategy. But because it's probably rare,
// and we avoid most of the work if pred lists are already in order,
// we'll just ensure everything is properly ordered.
//
for (BasicBlock* const checkBlock : Blocks())
{
checkBlock->ensurePredListOrder(this);
}
}
assert(!fgDomsComputed);

if (optLoopTableValid)
{
Expand Down
3 changes: 1 addition & 2 deletions src/coreclr/jit/optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4590,8 +4590,7 @@ PhaseStatus Compiler::optUnrollLoops()
optLoopCount = 0;

// Old dominators and reachability sets are no longer valid.
fgDomsComputed = false;
fgCompactRenumberQuirk = true;
fgDomsComputed = false;

return anyIRchange ? PhaseStatus::MODIFIED_EVERYTHING : PhaseStatus::MODIFIED_NOTHING;
}
Expand Down

0 comments on commit 9e31c21

Please sign in to comment.