Add visit budget checks to IsMonotonicallyIncreasing and ComputeDoesOverflow#125156
Add visit budget checks to IsMonotonicallyIncreasing and ComputeDoesOverflow#125156
Conversation
Co-authored-by: EgorBo <523221+EgorBo@users.noreply.github.com>
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
There was a problem hiding this comment.
Pull request overview
Adds visit-budget guards to additional RangeCheck helpers to prevent pathological recursion cost during JIT range analysis, aligning them with the existing budget mechanism used by ComputeRange.
Changes:
- Add
IsOverBudget()early-exit +m_nVisitBudget--toRangeCheck::IsMonotonicallyIncreasing. - Add
IsOverBudget()early-exit +m_nVisitBudget--toRangeCheck::ComputeDoesOverflow.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
PTAL @AndyAyersMS @dotnet/jit-contrib I've checked it on your MC file - it did fix the issue, although, the initial issue didn't reproduce as a hang in VMR for me. |
|
Actually, no, I was able to repro locally, here is the minimal repro: https://gist.github.com/EgorBo/2962e5e5a94961f6c461df0e077361e1 It's difficult to test on CI as it doesn't fail, just never reaches Tier1 (since promotion is asynchronous) and consumes memory. Doesn't repro with TC=0, probably can be added as a benchmark. |
IsMonotonicallyIncreasingandComputeDoesOverflowlacked them_nVisitBudgetguard thatComputeRangealready uses, allowing unbounded recursion cost in pathological cases.Description
Added early-exit budget checks to both functions, consistent with the existing pattern in
ComputeRange:IsMonotonicallyIncreasing:falseis the conservative result ("not proven monotonic"), so this is safe to return when over budget.ComputeDoesOverflow:false("doesn't overflow") is slightly optimistic in isolation, butComputeRangeindependently returnsUnknownwhen over budget, which already blocks bounds-check elimination — so no unsound optimization can occur.Both checks are placed before
GetSearchPath()->Set(...)to avoid leaving stale entries in the search path on early exit.✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.