Issue 178867
Summary [CodeGen] Crash in SplitKit::addDeadDef when child interval has subrange not in parent
Labels new issue
Assignees
Reporter kdupontbe
    Summary
The greedy register allocator crashes in SplitKit::addDeadDef() when splitting a register with partial subranges. The crash occurs when a child interval has a subrange that doesn't exist in the parent interval at the split point.

Environment
LLVM Version: main branch (as of January 2026)
Target: RISC-V 64-bit with vector extensions
Affected File: llvm/lib/CodeGen/SplitKit.cpp
Function: SplitEditor::addDeadDef()
Root Cause
The old code iterates over child subranges and looks them up in the parent:

for (LiveInterval::SubRange &S : LI.subranges()) {
  auto &PS = getSubRangeForMask(S.LaneMask, Edit->getParent());
  // ↑ Calls llvm_unreachable() if child has lane parent doesn't have
  VNInfo *PV = PS.getVNInfoAt(Def);
  if (PV != nullptr && PV->def == Def)
    S.createDeadDef(Def, LIS.getVNInfoAllocator());
}
This crashes when:

Parent register is split, creating a child interval
Child interval has a subrange (lane mask) that parent doesn't have
getSubRangeForMask() calls llvm_unreachable("SubRange for this mask not found")

I could not find a way to reproduce this with a standalone MIR

Dumping the MIR right before the crash would occur 

[splitkit_crash_state.txt](https://github.com/user-attachments/files/24963332/splitkit_crash_state.txt)

SPLITKIT CRASH IMMINENT - MIR DUMP
Function: o
Parent Register: %288 (VRM8)
Child Register: %310 (VRM8)
Def SlotIndex: 2112r

PARENT LiveInterval:
  Subranges:
    LaneMask: 0000000000000004 (0x0004)  ← Parent has only lane 0x0004

CHILD LiveInterval:
  Subranges:
    LaneMask: 0000000000000002 (0x0002)  ← Child has lane 0x0002
      *** NOT FOUND in parent - WILL CRASH ***
    LaneMask: 0000000000000004 (0x0004)
      FOUND in parent
The crash occurs at:

Instruction: undef %288.sub_vrm1_1:vrm8 = INIT_UNDEF
Slot Index: 2112r
Problem: Child has lane 0x0002 which parent doesn't have

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to