Skip to content

Commit

Permalink
JIT: Fix OSR DFS assert, and update entry BB for try regions (#95871)
Browse files Browse the repository at this point in the history
There is nothing that stops an edge into the original entry BB from
existing, so this assert is overzealous.

The asserting case, however, was because of `fgNormalizeEH` not taking
care to update `fgEntryBB`; also fix that.
  • Loading branch information
jakobbotsch authored Dec 12, 2023
1 parent 2155bb4 commit 69bbdb8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/coreclr/jit/compiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
6 changes: 6 additions & 0 deletions src/coreclr/jit/jiteh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 69bbdb8

Please sign in to comment.