Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JIT: Add FlowEdge destination block member #98243

Merged
merged 1 commit into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/coreclr/jit/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ FlowEdge* Compiler::BlockPredsWithEH(BasicBlock* blk)
{
if (bbInExnFlowRegions(tryIndex, bb) && !bb->isBBCallFinallyPairTail())
{
res = new (this, CMK_FlowEdge) FlowEdge(bb, res);
res = new (this, CMK_FlowEdge) FlowEdge(bb, blk, res);

#if MEASURE_BLOCK_SIZE
genFlowNodeCnt += 1;
Expand All @@ -164,7 +164,7 @@ FlowEdge* Compiler::BlockPredsWithEH(BasicBlock* blk)
for (BasicBlock* filterBlk = enclosingDsc->ebdFilter; filterBlk != enclosingDsc->ebdHndBeg;
filterBlk = filterBlk->Next())
{
res = new (this, CMK_FlowEdge) FlowEdge(filterBlk, res);
res = new (this, CMK_FlowEdge) FlowEdge(filterBlk, blk, res);

assert(filterBlk->VisitEHEnclosedHandlerSecondPassSuccs(this, [blk](BasicBlock* succ) {
return succ == blk ? BasicBlockVisit::Abort : BasicBlockVisit::Continue;
Expand Down Expand Up @@ -239,7 +239,7 @@ FlowEdge* Compiler::BlockDominancePreds(BasicBlock* blk)
for (BasicBlock* filterBlk = enclosingDsc->ebdFilter; filterBlk != enclosingDsc->ebdHndBeg;
filterBlk = filterBlk->Next())
{
res = new (this, CMK_FlowEdge) FlowEdge(filterBlk, res);
res = new (this, CMK_FlowEdge) FlowEdge(filterBlk, blk, res);

assert(filterBlk->VisitEHEnclosedHandlerSecondPassSuccs(this, [blk](BasicBlock* succ) {
return succ == blk ? BasicBlockVisit::Abort : BasicBlockVisit::Continue;
Expand Down
22 changes: 20 additions & 2 deletions src/coreclr/jit/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -2059,6 +2059,9 @@ struct FlowEdge
// The source of the control flow
BasicBlock* m_sourceBlock;

// The destination of the control flow
BasicBlock* m_destBlock;

// Edge weights
weight_t m_edgeWeightMin;
weight_t m_edgeWeightMax;
Expand All @@ -2074,9 +2077,10 @@ struct FlowEdge
bool m_likelihoodSet;

public:
FlowEdge(BasicBlock* block, FlowEdge* rest)
FlowEdge(BasicBlock* sourceBlock, BasicBlock* destBlock, FlowEdge* rest)
: m_nextPredEdge(rest)
, m_sourceBlock(block)
, m_sourceBlock(sourceBlock)
, m_destBlock(destBlock)
, m_edgeWeightMin(0)
, m_edgeWeightMax(0)
, m_likelihood(0)
Expand All @@ -2102,14 +2106,28 @@ struct FlowEdge

BasicBlock* getSourceBlock() const
{
assert(m_sourceBlock != nullptr);
return m_sourceBlock;
}

void setSourceBlock(BasicBlock* newBlock)
{
assert(newBlock != nullptr);
m_sourceBlock = newBlock;
}

BasicBlock* getDestinationBlock() const
{
assert(m_destBlock != nullptr);
return m_destBlock;
}

void setDestinationBlock(BasicBlock* newBlock)
{
assert(newBlock != nullptr);
m_destBlock = newBlock;
}

weight_t edgeWeightMin() const
{
return m_edgeWeightMin;
Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/jit/fgdiagnostic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2683,6 +2683,10 @@ unsigned BBPredsChecker::CheckBBPreds(BasicBlock* block, unsigned curTraversalSt
}

assert(CheckJump(blockPred, block));

// Make sure the pred edge's destination block is correct
//
assert(pred->getDestinationBlock() == block);
}

// Make sure preds are in increasing BBnum order
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/fgflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ FlowEdge* Compiler::fgAddRefPred(BasicBlock* block, BasicBlock* blockPred, FlowE

// Create new edge in the list in the correct ordered location.
//
flow = new (this, CMK_FlowEdge) FlowEdge(blockPred, *listp);
flow = new (this, CMK_FlowEdge) FlowEdge(blockPred, block, *listp);
flow->incrementDupCount();
*listp = flow;

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ void Compiler::optScaleLoopBlocks(BasicBlock* begBlk, BasicBlock* endBlk)
// Is this a back edge?
if (predBlock->bbNum >= begBlk->bbNum)
{
backedgeList = new (this, CMK_FlowEdge) FlowEdge(predBlock, backedgeList);
backedgeList = new (this, CMK_FlowEdge) FlowEdge(predBlock, begBlk, backedgeList);

#if MEASURE_BLOCK_SIZE
genFlowNodeCnt += 1;
Expand Down
Loading