Skip to content

Add visit budget checks to IsMonotonicallyIncreasing and ComputeDoesOverflow#125156

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-budget-checks
Draft

Add visit budget checks to IsMonotonicallyIncreasing and ComputeDoesOverflow#125156
Copilot wants to merge 2 commits intomainfrom
copilot/add-budget-checks

Conversation

Copy link
Contributor

Copilot AI commented Mar 3, 2026

IsMonotonicallyIncreasing and ComputeDoesOverflow lacked the m_nVisitBudget guard that ComputeRange already uses, allowing unbounded recursion cost in pathological cases.

Description

Added early-exit budget checks to both functions, consistent with the existing pattern in ComputeRange:

if (IsOverBudget())
{
    return false;
}
m_nVisitBudget--;
  • IsMonotonicallyIncreasing: false is 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, but ComputeRange independently returns Unknown when 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.

Co-authored-by: EgorBo <523221+EgorBo@users.noreply.github.com>
Copilot AI changed the title [WIP] Add budget checks to IsMonotonicallyIncreasing and ComputeDoesOverflow Add visit budget checks to IsMonotonicallyIncreasing and ComputeDoesOverflow Mar 4, 2026
@github-actions github-actions bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Mar 4, 2026
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants