diff --git a/src/coreclr/jit/compiler.hpp b/src/coreclr/jit/compiler.hpp index f114b4785fff65..ff6441553837a1 100644 --- a/src/coreclr/jit/compiler.hpp +++ b/src/coreclr/jit/compiler.hpp @@ -4976,7 +4976,6 @@ unsigned Compiler::fgRunDfs(VisitPreorder visitPreorder, VisitPostorder visitPos // patchpoint, but during morph we may transform to something that // requires the original entry (fgEntryBB). assert(opts.IsOSR()); - assert((fgEntryBB->bbRefs == 1) && (fgEntryBB->bbPreds == nullptr)); dfsFrom(fgEntryBB); } diff --git a/src/coreclr/jit/jiteh.cpp b/src/coreclr/jit/jiteh.cpp index 2aad48278ded35..86714281fc7890 100644 --- a/src/coreclr/jit/jiteh.cpp +++ b/src/coreclr/jit/jiteh.cpp @@ -2168,6 +2168,12 @@ bool Compiler::fgNormalizeEHCase2() newTryStart->bbRefs++; } + // Same for OSR's protected entry BB. + if (insertBeforeBlk == fgEntryBB) + { + fgEntryBB = newTryStart; + } + JITDUMP("'try' begin for EH#%u and EH#%u are same block; inserted new " FMT_BB " before " FMT_BB " " "as new 'try' begin for EH#%u.\n",