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: fix BasicBlock::isEmpty() #51340

Merged
merged 1 commit into from
Apr 16, 2021
Merged
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
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