[all-commits] [llvm/llvm-project] e7084c: [DebugInfo][Instr] Track subregisters across stack...

Jeremy Morse via All-commits all-commits at lists.llvm.org
Fri Oct 22 11:24:00 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e7084ceab31223a0d983996d61c24486032b537b
      https://github.com/llvm/llvm-project/commit/e7084ceab31223a0d983996d61c24486032b537b
  Author: Jeremy Morse <jeremy.morse at sony.com>
  Date:   2021-10-22 (Fri, 22 Oct 2021)

  Changed paths:
    M llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
    M llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.h
    A llvm/test/DebugInfo/MIR/InstrRef/livedebugvalues_stackslot_subregs.mir
    M llvm/test/DebugInfo/MIR/InstrRef/livedebugvalues_subreg_substitutions.mir
    M llvm/unittests/CodeGen/InstrRefLDVTest.cpp

  Log Message:
  -----------
  [DebugInfo][Instr] Track subregisters across stack spills/restores

Sometimes we generate code that writes to a subregister, then spills /
restores a super-register to the stack, for example:

    $eax = MOV32ri 0
    MOV64mr $rsp, 1, $noreg, 16, $noreg, $rax
    $rcx = MOV64rm $rsp, 1, $noreg, 8, $noreg

This patch takes a different approach: it adds another index to
MLocTracker that identifies a size/offset within a stack slot. A location
on the stack is then a pari of {FrameIndex, SlotNum}. Spilling and
restoring now involves pairing up the src/dest register numbers, and the
dest/src stack position to be transferred to/from. Location coverage
improves as a result, compile-time performance decreases, alas.

One limitation is that if a PHI occurs inside a stack slot:

    DBG_PHI %stack.0, 1

We don't know how large the resulting value is, and so might have
difficulty picking which value to use. DBG_PHI might need to be augmented
in the future with such a size.

Unit tests added ensure that spills and restores correctly transfer to
positions in the Location => Value map, and that different register classes
written to the stack will correctly clobber all other positions in the
stack slot.

Differential Revision: https://reviews.llvm.org/D112133




More information about the All-commits mailing list