Skip to content

Commit

Permalink
JIT: fix BasicBlock::isEmpty()
Browse files Browse the repository at this point in the history
The detection of blocks with only PHI assignments was broken by dotnet#50806.
Fix by using existing helper to find the first non-PHI assignment.

Closes dotnet#51326.
  • Loading branch information
AndyAyersMS committed Apr 15, 2021
1 parent 2e12730 commit 91cf8b3
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/coreclr/jit/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -913,16 +913,27 @@ unsigned JitPtrKeyFuncs<BasicBlock>::GetHashCode(const BasicBlock* ptr)
return ptr->bbNum;
}

//------------------------------------------------------------------------
// isEmpty: check if block is empty or contains only ignorable statements
//
// Return Value:
// True if block is empty, or contains only PHI assignments,
// or contains zero or more PHI assignments followed by NOPs.
//
bool BasicBlock::isEmpty()
{
if (!IsLIR())
{
for (Statement* stmt : Statements())
Statement* stmt = FirstNonPhiDef();

while (stmt != nullptr)
{
if (!stmt->GetRootNode()->OperIs(GT_PHI, GT_NOP))
if (!stmt->GetRootNode()->OperIs(GT_NOP))
{
return false;
}

stmt = stmt->GetNextStmt();
}
}
else
Expand Down

0 comments on commit 91cf8b3

Please sign in to comment.