Skip to content

Commit

Permalink
Print switch succs in bbNum order
Browse files Browse the repository at this point in the history
  • Loading branch information
amanasifkhalid committed Nov 21, 2024
1 parent 2305c56 commit 4dda34b
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/coreclr/jit/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,20 +617,23 @@ void BasicBlock::dspSuccs(Compiler* compiler)
// compute it ourselves here.
if (bbKind == BBJ_SWITCH)
{
// Create a set with all the successors.
BitVecTraits bitVecTraits(compiler->compBasicBlockID, compiler);
BitVec uniqueSuccBlocks(BitVecOps::MakeEmpty(&bitVecTraits));
unsigned* const targetNums = new unsigned[NumSucc()];
unsigned targetCount = 0;
for (BasicBlock* const bTarget : SwitchTargets())
{
BitVecOps::AddElemD(&bitVecTraits, uniqueSuccBlocks, bTarget->bbID);
targetNums[targetCount++] = bTarget->bbNum;
}
BitVecOps::Iter iter(&bitVecTraits, uniqueSuccBlocks);
unsigned bbNum = 0;
while (iter.NextElem(&bbNum))

// Note that we will output switch successors in increasing numerical bbNum order, which is
// not related to their order in the bbSwtTargets->bbsDstTab table.
assert(targetCount == NumSucc());
jitstd::sort(targetNums, targetNums + targetCount, [](unsigned left, unsigned right) {
return left < right;
});

for (unsigned i = 0; i < targetCount; i++)
{
// Note that we will output switch successors in increasing numerical bbNum order, which is
// not related to their order in the bbSwtTargets->bbsDstTab table.
printf("%s" FMT_BB, first ? "" : ",", bbNum);
printf("%s" FMT_BB, first ? "" : ",", targetNums[i]);
first = false;
}
}
Expand Down

0 comments on commit 4dda34b

Please sign in to comment.