Skip to content

Commit 70a78f9

Browse files
authored
JIT: fix BasicBlock::isEmpty() (#51340)
The detection of blocks with only PHI assignments was broken by #50806. Fix by using existing helper to find the first non-PHI assignment. Closes #51326.
1 parent 31c28fc commit 70a78f9

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/coreclr/jit/block.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -913,16 +913,27 @@ unsigned JitPtrKeyFuncs<BasicBlock>::GetHashCode(const BasicBlock* ptr)
913913
return ptr->bbNum;
914914
}
915915

916+
//------------------------------------------------------------------------
917+
// isEmpty: check if block is empty or contains only ignorable statements
918+
//
919+
// Return Value:
920+
// True if block is empty, or contains only PHI assignments,
921+
// or contains zero or more PHI assignments followed by NOPs.
922+
//
916923
bool BasicBlock::isEmpty()
917924
{
918925
if (!IsLIR())
919926
{
920-
for (Statement* stmt : Statements())
927+
Statement* stmt = FirstNonPhiDef();
928+
929+
while (stmt != nullptr)
921930
{
922-
if (!stmt->GetRootNode()->OperIs(GT_PHI, GT_NOP))
931+
if (!stmt->GetRootNode()->OperIs(GT_NOP))
923932
{
924933
return false;
925934
}
935+
936+
stmt = stmt->GetNextStmt();
926937
}
927938
}
928939
else

0 commit comments

Comments
 (0)