JIT: fix range assertions for bypassed phi blocks - #133268
Conversation
Fixes dotnet#133267. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 56f763ef-1e54-421c-9e79-fe14ed2b906a
|
Azure Pipelines: Successfully started running 5 pipeline(s). 11 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
🔵 Needs a closer look
It changes JIT range/assertion-merging behavior (compiler correctness surface area), and I did not validate it with local builds/tests in this review.
Pull request overview
This PR updates JIT range-check analysis to avoid relying on potentially stale assertion sets after flow edits (e.g., jump threading bypassing phi-related blocks), and adds a targeted regression test for the reported miscompile scenario.
Changes:
- Adjust range computation for locals so assertion merging happens at the use site (via
MergeAssertion) rather than insideComputeRangeForLocalDef. - Update
ComputeRangeForLocalDefsignature to no longer take the use block. - Add a new JitBlue regression test (
Runtime_133267) and register it inRegression_ro_2.csproj.
File summaries
| File | Description |
|---|---|
| src/coreclr/jit/rangecheck.h | Updates ComputeRangeForLocalDef declaration to drop the BasicBlock* parameter. |
| src/coreclr/jit/rangecheck.cpp | Moves assertion merging responsibility to the local-use path (MergeAssertion) to avoid stale phi-block assertion inputs. |
| src/tests/JIT/Regression/JitBlue/Runtime_133267/Runtime_133267.cs | Adds a regression test that fails if the JIT incorrectly throws ArgumentException under optimization. |
| src/tests/JIT/Regression/Regression_ro_2.csproj | Registers the new regression test for compilation/execution in the ro_2 suite. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 0
- Review effort level: Lite
There was a problem hiding this comment.
🟡 Changes recommended
The new MergeAssertion call for locals can introduce redundant assertion merging at existing call sites, potentially impacting JIT compilation performance.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 1
- Review effort level: Lite
|
PTAL @jakobbotsch @dotnet/jit-contrib A small correctness issue found by AI. Not too many diffs so it's fine to remove that "improve range by assertions" logic. |
jakobbotsch
left a comment
There was a problem hiding this comment.
I guess it doesn't apply here since this just removes the opt, but it would be nice to keep track of these places if we find more so that we know what to do if we ever get around to fixing the SSA update story. Perhaps some // TODO-SSAUPDATING: Remove this
|
/ba-g unrelated swiftc error in monointerp |
Fixes #133267. Avoid stale phi-block assertions after jump threading.