Skip to content

Commit

Permalink
JIT: Fix BBJ_COND-related assert in OptIfConversionDsc::IfConvertDump (
Browse files Browse the repository at this point in the history
…#95934)

In #95773, I incorrectly assumed m_startBlock would always be a BBJ_COND in OptIfConversionDsc::IfConvertDump, but it can be converted to a BBJ_ALWAYS before being dumped, thus hitting an assert when m_startBlock->GetTrueTarget() is called. This is fixed by calling the correct target accessor method depending on the type of m_startBlock.

(Note that IfConvertDump is only called if dumps are enabled, hence why this assert wasn't initially hit in CI.)
  • Loading branch information
amanasifkhalid authored Dec 12, 2023
1 parent ebb540e commit e683e99
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/coreclr/jit/ifconversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,15 +381,15 @@ void OptIfConversionDsc::IfConvertDump()
{
assert(m_startBlock != nullptr);
m_comp->fgDumpBlock(m_startBlock);
for (BasicBlock* dumpBlock = m_startBlock->Next(); dumpBlock != m_finalBlock;
dumpBlock = dumpBlock->GetUniqueSucc())
BasicBlock* dumpBlock = m_startBlock->KindIs(BBJ_COND) ? m_startBlock->GetFalseTarget() : m_startBlock->Next();
for (; dumpBlock != m_finalBlock; dumpBlock = dumpBlock->GetUniqueSucc())
{
m_comp->fgDumpBlock(dumpBlock);
}
if (m_doElseConversion)
{
for (BasicBlock* dumpBlock = m_startBlock->GetTrueTarget(); dumpBlock != m_finalBlock;
dumpBlock = dumpBlock->GetUniqueSucc())
dumpBlock = m_startBlock->KindIs(BBJ_COND) ? m_startBlock->GetTrueTarget() : m_startBlock->GetTarget();
for (; dumpBlock != m_finalBlock; dumpBlock = dumpBlock->GetUniqueSucc())
{
m_comp->fgDumpBlock(dumpBlock);
}
Expand Down

0 comments on commit e683e99

Please sign in to comment.