Skip to content

fix(compiler): handle null MI in enterIntvAfter#318

Open
abmcar wants to merge 1 commit intoDTVMStack:mainfrom
abmcar:fix/cg-split-null-inst-repro
Open

fix(compiler): handle null MI in enterIntvAfter#318
abmcar wants to merge 1 commit intoDTVMStack:mainfrom
abmcar:fix/cg-split-null-inst-repro

Conversation

@abmcar
Copy link
Contributor

@abmcar abmcar commented Feb 3, 2026

1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):

  • N
  • Y

2. What is the scope of this PR (e.g. component or file name):

3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):

  • Affects user behaviors
  • Contains CI/CD configuration changes
  • Contains documentation changes
  • Contains experimental features
  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Other

4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):

  • N
  • Y

5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:

  • Unit test
  • Integration test
  • Benchmark (add benchmark stats below)
  • Manual test (add detailed scripts or steps below)
  • Other

6. Release note

None

Copilot AI review requested due to automatic review settings February 3, 2026 05:41
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the compiler’s CGIR split editor by gracefully handling cases where enterIntvAfter is called with a slot index that does not map directly to an instruction, avoiding crashes and correctly placing new interval definitions.

Changes:

  • Replaces the assert on a null CgInstruction *MI in CgSplitEditor::enterIntvAfter with logic that:
    • Locates the owning CgBasicBlock for the given CgSlotIndex.
    • Delegates to enterIntvAtEnd when the index is at or past the block end or when no suitable next instruction is found in the same block.
    • Otherwise, finds the next non-null slot index in the same block and inserts the new def before that instruction via defFromParent.
  • Preserves existing behavior when a valid MI is found at the index while adding robust handling for “gap” indices that previously triggered the assertion.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant