diff --git a/src/coreclr/jit/helperexpansion.cpp b/src/coreclr/jit/helperexpansion.cpp index 4ab8af48bb1fd7..077c9e05e2ee9a 100644 --- a/src/coreclr/jit/helperexpansion.cpp +++ b/src/coreclr/jit/helperexpansion.cpp @@ -1506,6 +1506,17 @@ bool Compiler::fgExpandStaticInitForCall(BasicBlock** pBlock, Statement* stmt, G // Clear gtInitClsHnd as a mark that we've already visited this call call->gtInitClsHnd = NO_CLASS_HANDLE; + + // Update the IL offsets of the blocks to match the split. + + // prevBb->bbCodeOffs remains the same + block->bbCodeOffsEnd = prevBb->bbCodeOffsEnd; + + IL_OFFSET splitPointILOffset = fgFindBlockILOffset(block); + + prevBb->bbCodeOffsEnd = max(prevBb->bbCodeOffs, splitPointILOffset); + block->bbCodeOffs = min(splitPointILOffset, block->bbCodeOffsEnd); + return true; }