Skip to content

Commit

Permalink
JIT: Clamp basic block IL ranges when splitting blocks (#89179)
Browse files Browse the repository at this point in the history
In release, code motion/compaction may lead to statements ending up in
blocks that don't contain their IL offset. This can cause splitting of
blocks to create meaningless IL ranges such as [057..020). Since we
maintain these IL ranges on a best-effort basis, just clamp them when we
do the splitting.

Fix #88348
  • Loading branch information
jakobbotsch authored Jul 19, 2023
1 parent 0678ea2 commit 7469976
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/coreclr/jit/fgbasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4664,8 +4664,8 @@ BasicBlock* Compiler::fgSplitBlockAfterStatement(BasicBlock* curr, Statement* st

IL_OFFSET splitPointILOffset = fgFindBlockILOffset(newBlock);

curr->bbCodeOffsEnd = splitPointILOffset;
newBlock->bbCodeOffs = splitPointILOffset;
curr->bbCodeOffsEnd = max(curr->bbCodeOffs, splitPointILOffset);
newBlock->bbCodeOffs = min(splitPointILOffset, newBlock->bbCodeOffsEnd);
}
else
{
Expand Down Expand Up @@ -4781,11 +4781,11 @@ BasicBlock* Compiler::fgSplitBlockAfterNode(BasicBlock* curr, GenTree* node)
}
}

curr->bbCodeOffsEnd = splitPointILOffset;
curr->bbCodeOffsEnd = max(curr->bbCodeOffs, splitPointILOffset);

// Also use this as the beginning offset of the next block. Presumably we could/should
// look to see if the first node is a GT_IL_OFFSET node, and use that instead.
newBlock->bbCodeOffs = splitPointILOffset;
newBlock->bbCodeOffs = min(splitPointILOffset, newBlock->bbCodeOffsEnd);
}
else
{
Expand Down

0 comments on commit 7469976

Please sign in to comment.