[DebugInstrRef] Substitute debug value numbers to handle optimizations
authorJeremy Morse <jeremy.morse@sony.com>
Thu, 22 Oct 2020 11:48:57 +0000 (12:48 +0100)
committerJeremy Morse <jeremy.morse@sony.com>
Thu, 22 Oct 2020 12:01:03 +0000 (13:01 +0100)
commitd73275993bbc19b38b7818e96953f84decf0653b
treeb4431af43ba28ba214b4f6435c85ee5e2e69a031
parent8556f38b0d6268103a6da08dc01c360f8e20fc32
[DebugInstrRef] Substitute debug value numbers to handle optimizations

This patch touches two optimizations, TwoAddressInstruction and X86's
FixupLEAs pass, both of which optimize by re-creating instructions. For
LEAs, various bits of arithmetic are better represented as LEAs on X86,
while TwoAddressInstruction sometimes converts instrs into three address
instructions if it's profitable.

For debug instruction referencing, both of these require substitutions to
be created -- the old instruction number must be pointed to the new
instruction number, as illustrated in the added test. If this isn't done,
any variable locations based on the optimized instruction are
conservatively dropped.

Differential Revision: https://reviews.llvm.org/D85756
llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
llvm/lib/Target/X86/X86FixupLEAs.cpp
llvm/test/DebugInfo/MIR/InstrRef/twoaddr-to-threeaddr-sub.mir [new file with mode: 0644]