diff --git a/src/coreclr/jit/ssabuilder.cpp b/src/coreclr/jit/ssabuilder.cpp index 8f4561ecfc8660..3697ebc0bdf8fc 100644 --- a/src/coreclr/jit/ssabuilder.cpp +++ b/src/coreclr/jit/ssabuilder.cpp @@ -1737,13 +1737,11 @@ bool IncrementalSsaBuilder::FinalizeDefs() for (int i = 0; i < m_defs.Height(); i++) { UseDefLocation& def = m_defs.BottomRef(i); - if (!m_comp->m_dfsTree->Contains(def.Block)) + if (m_comp->m_dfsTree->Contains(def.Block)) { - continue; + BitVecOps::AddElemD(&m_poTraits, m_defBlocks, def.Block->bbPostorderNum); } - BitVecOps::AddElemD(&m_poTraits, m_defBlocks, def.Block->bbPostorderNum); - unsigned ssaNum = dsc->lvPerSsaData.AllocSsaNum(m_comp->getAllocator(CMK_SSA), def.Block, def.Tree); def.Tree->SetSsaNum(ssaNum); LclSsaVarDsc* ssaDsc = dsc->GetPerSsaData(ssaNum); @@ -1788,11 +1786,14 @@ bool IncrementalSsaBuilder::InsertUse(const UseDefLocation& use) { if (!m_comp->m_dfsTree->Contains(use.Block)) { - JITDUMP(" Use is in unreachable block " FMT_BB "\n", use.Block->bbNum); - return false; + reachingDef = m_defs.Bottom(0); + JITDUMP(" Use is in unreachable block " FMT_BB ", using first def [%06u] in " FMT_BB "\n", + use.Block->bbNum, Compiler::dspTreeID(reachingDef.Tree), reachingDef.Block->bbNum); + } + else + { + reachingDef = FindOrCreateReachingDef(use); } - - reachingDef = FindOrCreateReachingDef(use); } JITDUMP(" Reaching def is [%06u] d:%d\n", Compiler::dspTreeID(reachingDef.Tree), reachingDef.Tree->GetSsaNum());