[all-commits] [llvm/llvm-project] 422af7: [MIR] Save internal VirtRegMap state in MIR (#197361)

Quentin Colombet via All-commits all-commits at lists.llvm.org
Fri Jun 12 08:42:42 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 422af7cca672a717bd9505a486e287fa2734bbc9
      https://github.com/llvm/llvm-project/commit/422af7cca672a717bd9505a486e287fa2734bbc9
  Author: Quentin Colombet <quentin.colombet at gmail.com>
  Date:   2026-06-12 (Fri, 12 Jun 2026)

  Changed paths:
    M llvm/include/llvm/CodeGen/MIRPrinter.h
    M llvm/include/llvm/CodeGen/MIRYamlMapping.h
    M llvm/include/llvm/CodeGen/MachineFunction.h
    M llvm/include/llvm/CodeGen/MachineRegisterInfo.h
    M llvm/lib/CodeGen/MIRParser/MIRParser.cpp
    M llvm/lib/CodeGen/MIRPrinter.cpp
    M llvm/lib/CodeGen/MIRPrintingPass.cpp
    M llvm/lib/CodeGen/MachineFunction.cpp
    M llvm/lib/CodeGen/VirtRegMap.cpp
    A llvm/test/CodeGen/MIR/AMDGPU/virtregmap-stash-bad-phys.mir
    A llvm/test/CodeGen/MIR/AMDGPU/virtregmap-stash-bad-split.mir
    A llvm/test/CodeGen/MIR/AMDGPU/virtregmap-stash-self-split.mir
    A llvm/test/CodeGen/MIR/AMDGPU/virtregmap-stash.mir

  Log Message:
  -----------
  [MIR] Save internal VirtRegMap state in MIR (#197361)

Adds two optional fields to the per-vreg YAML record so MIR tests can
express VirtRegMap state that previously had no representation:

  registers:
    - { id: 1, class: vgpr_32, split-from: '%0', assigned-phys: '$vgpr5' }

Testing passes that consume sibling-register information (e.g.
InlineSpiller) requires constructing a VirtRegMap with split
relationships from a MIR test, which implies triggering live-range
splitting at minimum and make reproducers unnecessarily complicated.

So this change introduces a mechanism to serialize/deserialize the state
of the VirtRegMap pass.

Mechanism:
- For serialization:
  - MIRPrinter emits the new fields only when the VirtRegMap is available.
- For deserialization:
  - MIRParser stashes parsed entries in the MachineRegisterInfo object
  - VirtRegMap::init() drains the stash via assignVirt2Phys and
    setIsSplitFromReg, then clears it.

Validation at parse time:
  - 'assigned-phys' must be a physical register.
  - 'split-from' must reference a different vreg than 'id'.
  - 'split-from' physregs / named-vreg references already rejected
    by parseStandaloneVirtualRegister.

I'm not super happy about stashing the VRM info in the MRI, but that's
a small price to pay.



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