Skip to content
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
186 changes: 7 additions & 179 deletions src/coreclr/jit/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,13 +580,10 @@ unsigned BasicBlock::dspPreds() const
//------------------------------------------------------------------------
// dspSuccs: Display the basic block successors.
//
// Arguments:
// compiler - compiler instance; passed to NumSucc(Compiler*) -- see that function for implications.
//
void BasicBlock::dspSuccs(Compiler* compiler)
void BasicBlock::dspSuccs() const
{
bool first = true;
for (const BasicBlock* const succ : Succs(compiler))
for (const BasicBlock* const succ : Succs())
{
printf("%s" FMT_BB, first ? "" : ",", succ->bbNum);
first = false;
Expand Down Expand Up @@ -734,10 +731,7 @@ void BasicBlock::dspKind() const
}
}

void BasicBlock::dspBlockHeader(Compiler* compiler,
bool showKind /*= true*/,
bool showFlags /*= false*/,
bool showPreds /*= true*/)
void BasicBlock::dspBlockHeader(bool showKind /*= true*/, bool showFlags /*= false*/, bool showPreds /*= true*/) const
{
printf("%s ", dspToString());
dspBlockILRange();
Expand All @@ -750,7 +744,7 @@ void BasicBlock::dspBlockHeader(Compiler* compiler,
printf(", preds={");
dspPreds();
printf("} succs={");
dspSuccs(compiler);
dspSuccs();
printf("}");
}
if (showFlags)
Expand Down Expand Up @@ -1066,41 +1060,6 @@ Statement* BasicBlock::FirstNonPhiDefOrCatchArgStore() const
return stmt;
}

//------------------------------------------------------------------------
// bbFallsThrough: Check if inserting a BasicBlock after this one will alter
// the flowgraph.
//
// Returns:
// True if so.
//
bool BasicBlock::bbFallsThrough() const
{
switch (bbKind)
{
case BBJ_THROW:
case BBJ_EHFINALLYRET:
case BBJ_EHFAULTRET:
case BBJ_EHFILTERRET:
case BBJ_EHCATCHRET:
case BBJ_RETURN:
case BBJ_ALWAYS:
case BBJ_CALLFINALLYRET:
case BBJ_LEAVE:
case BBJ_SWITCH:
return false;

case BBJ_COND:
return true;

case BBJ_CALLFINALLY:
return !HasFlag(BBF_RETLESS_CALL);

default:
assert(!"Unknown bbKind in bbFallsThrough()");
return true;
}
}

//------------------------------------------------------------------------
// NumSucc: Returns the count of block successors. See the declaration comment for details.
//
Expand Down Expand Up @@ -1155,15 +1114,15 @@ unsigned BasicBlock::NumSucc() const
return bbEhfTargets->GetSuccCount();

case BBJ_SWITCH:
return bbSwtTargets->GetCaseCount();
return bbSwtTargets->GetSuccCount();

default:
unreached();
}
}

//------------------------------------------------------------------------
// GetSucc: Returns the requested successor edge. See the declaration comment for details.
// GetSuccEdge: Returns the requested successor edge. See the declaration comment for details.
//
// Arguments:
// i - index of successor to return. 0 <= i <= NumSucc().
Expand Down Expand Up @@ -1200,7 +1159,7 @@ FlowEdge* BasicBlock::GetSuccEdge(unsigned i) const
return bbEhfTargets->GetSucc(i);

case BBJ_SWITCH:
return bbSwtTargets->GetCase(i);
return bbSwtTargets->GetSucc(i);

default:
unreached();
Expand All @@ -1221,137 +1180,6 @@ BasicBlock* BasicBlock::GetSucc(unsigned i) const
return GetSuccEdge(i)->getDestinationBlock();
}

//------------------------------------------------------------------------
// NumSucc: Returns the count of block successors. See the declaration comment for details.
//
// Arguments:
// comp - Compiler instance
//
// Return Value:
// Count of block successors.
//
unsigned BasicBlock::NumSucc(Compiler* comp)
{
assert(comp != nullptr);

switch (bbKind)
{
case BBJ_THROW:
case BBJ_RETURN:
case BBJ_EHFAULTRET:
return 0;

case BBJ_EHFINALLYRET:
// We may call this method before we realize we have invalid IL. Tolerate.
//
if (!hasHndIndex())
{
return 0;
}

// We may call this before we've computed the BBJ_EHFINALLYRET successors in the importer. Tolerate.
//
if (bbEhfTargets == nullptr)
{
return 0;
}

return bbEhfTargets->GetSuccCount();

case BBJ_CALLFINALLY:
case BBJ_CALLFINALLYRET:
case BBJ_ALWAYS:
case BBJ_EHCATCHRET:
case BBJ_EHFILTERRET:
case BBJ_LEAVE:
return 1;

case BBJ_COND:
if (bbTrueEdge == bbFalseEdge)
{
return 1;
}
else
{
return 2;
}

case BBJ_SWITCH:
return bbSwtTargets->GetSuccCount();

default:
unreached();
}
}

//------------------------------------------------------------------------
// GetSucc: Returns the requested successor edge. See the declaration comment for details.
//
// Arguments:
// i - index of successor to return. 0 <= i <= NumSucc(comp).
// comp - Compiler instance
//
// Return Value:
// Requested successor edge
//
FlowEdge* BasicBlock::GetSuccEdge(unsigned i, Compiler* comp)
{
assert(comp != nullptr);

assert(i < NumSucc(comp)); // Index bounds check.
switch (bbKind)
{
case BBJ_EHFILTERRET:
// Handler is the (sole) normal successor of the filter.
assert(comp->fgFirstBlockOfHandler(this) == GetTarget());
return GetTargetEdge();

case BBJ_EHFINALLYRET:
assert(bbEhfTargets != nullptr);
return bbEhfTargets->GetSucc(i);

case BBJ_CALLFINALLY:
case BBJ_CALLFINALLYRET:
case BBJ_ALWAYS:
case BBJ_EHCATCHRET:
case BBJ_LEAVE:
return GetTargetEdge();

case BBJ_COND:
if (i == 0)
{
return GetFalseEdge();
}
else
{
assert(i == 1);
assert(bbTrueEdge != bbFalseEdge);
return GetTrueEdge();
}

case BBJ_SWITCH:
return bbSwtTargets->GetSucc(i);

default:
unreached();
}
}

//------------------------------------------------------------------------
// GetSucc: Returns the requested block successor. See the declaration comment for details.
//
// Arguments:
// i - index of successor to return. 0 <= i <= NumSucc(comp).
// comp - Compiler instance
//
// Return Value:
// Requested successor block
//
BasicBlock* BasicBlock::GetSucc(unsigned i, Compiler* comp)
{
return GetSuccEdge(i, comp)->getDestinationBlock();
}

void BasicBlock::InitVarSets(Compiler* comp)
{
VarSetOps::AssignNoCopy(comp, bbVarUse, VarSetOps::MakeEmpty(comp));
Expand Down
Loading
Loading