[DebugInfo] Make postra sinking of DBG_VALUEs subregister-safe
authorJeremy Morse <jeremy.morse.llvm@gmail.com>
Mon, 19 Aug 2019 09:53:07 +0000 (09:53 +0000)
committerJeremy Morse <jeremy.morse.llvm@gmail.com>
Mon, 19 Aug 2019 09:53:07 +0000 (09:53 +0000)
commit176bbd5cde362ad965dcda5cc72b655117685a5a
tree5240dd93e0201d521712863fa8221ef9dc05cd05
parent2cafd872fb97f2899ac0f1b01ed82ee88581c86d
[DebugInfo] Make postra sinking of DBG_VALUEs subregister-safe

Currently the machine instruction sinker identifies DBG_VALUE insts that
also need to sink by comparing register numbers. Unfortunately this isn't
safe, because (after register allocation) a DBG_VALUE may read a register
that aliases what's being sunk. To fix this, identify the DBG_VALUEs that
need to sink by recording & examining their register units. Register units
gives us the following guarantee:

  "Two registers overlap if and only if they have a common register unit"
  [MCRegisterInfo.h]

Thus we can always identify aliasing DBG_VALUEs if the set of register
units read by the DBG_VALUE, and the register units of the instruction
being sunk, intersect. (MachineSink already uses classes like
"LiveRegUnits" for determining sinking validity anyway).

The test added checks for super and subregister DBG_VALUE reads of a sunk
copy being sunk as well.

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

llvm-svn: 369247
llvm/lib/CodeGen/MachineSink.cpp
llvm/test/DebugInfo/MIR/X86/postra-subreg-sink.mir [new file with mode: 0644]