[all-commits] [llvm/llvm-project] 642bbb: [2/3][RegAlloc][LiveRegMatrix] Fix inconsistency w...

Dhruva Chakrabarti via All-commits all-commits at lists.llvm.org
Thu May 28 13:57:24 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 642bbbaf57ed1d0ce6b7871a8d3dc1386e95926b
      https://github.com/llvm/llvm-project/commit/642bbbaf57ed1d0ce6b7871a8d3dc1386e95926b
  Author: Dhruva Chakrabarti <Dhruva.Chakrabarti at amd.com>
  Date:   2026-05-28 (Thu, 28 May 2026)

  Changed paths:
    M llvm/lib/CodeGen/InlineSpiller.cpp
    M llvm/lib/CodeGen/LiveRangeEdit.cpp

  Log Message:
  -----------
  [2/3][RegAlloc][LiveRegMatrix] Fix inconsistency when fold creates a CopyMI (#197776)

When TargetInstrInfo::foldMemoryOperand produces a side-effect CopyMI,
the copy destination vreg's LiveInterval is extended via addSegment. If
that vreg is already assigned in LiveRegMatrix, the matrix becomes
inconsistent because it still holds the old (smaller) interval.

Fix this in two places:

- InlineSpiller::foldMemoryOperand: unassign the vreg from the matrix
before addSegment, reassign after, so the matrix reflects the updated
interval.

- LiveRangeEdit::foldAsLoad: notify the delegate via
LRE_WillShrinkVirtReg before addSegment.

LIT test exercised by this patch (i.e. if I introduce consistency
verification as in https://github.com/llvm/llvm-project/pull/197778 but
not this patch, the following test fails):
CodeGen/X86/apx/pr191368.ll

Assisted-by: Cursor/Claude Opus



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list