From ee3eee71e41547050040a8d1ef44b38f6d22f0d2 Mon Sep 17 00:00:00 2001 From: Jeremy Morse Date: Mon, 25 Oct 2021 15:09:42 +0100 Subject: [DebugInfo][InstrRef] Track values fused into stack spills During register allocation, some instructions can have stack spills fused into them. It means that when vregs are allocated on the stack we can convert: SETCCr %0 DBG_VALUE %0 to SETCCm %stack.0 DBG_VALUE %stack.0 Unfortunately instruction referencing finds this harder: a store to the stack doesn't have a specific operand number, therefore we don't substitute the old operand for a new operand, and the location is dropped. This patch implements a solution: just recognise the memory operand attached to an instruction with a Special Number (TM), and record a substitution between the old value and the new one. This patch adds substitution code to InlineSpiller to record such fused spills, and tracking in InstrRefBasedLDV to recognise such values, and produce the value numbers for them. Everything to do with the movement of stack-defined values is already handled in InstrRefBasedLDV. Differential Revision: https://reviews.llvm.org/D111317 --- llvm/lib/CodeGen/MachineFunction.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'llvm/lib/CodeGen/MachineFunction.cpp') diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp index 4a838b8..d8f786e 100644 --- a/llvm/lib/CodeGen/MachineFunction.cpp +++ b/llvm/lib/CodeGen/MachineFunction.cpp @@ -974,6 +974,9 @@ void MachineFunction::makeDebugValueSubstitution(DebugInstrOperandPair A, unsigned Subreg) { // Catch any accidental self-loops. assert(A.first != B.first); + // Don't allow any substitutions _from_ the memory operand number. + assert(A.second != DebugOperandMemNumber); + DebugValueSubstitutions.push_back({A, B, Subreg}); } @@ -1239,6 +1242,9 @@ bool MachineFunction::useDebugInstrRef() const { return false; } +// Use one million as a high / reserved number. +const unsigned MachineFunction::DebugOperandMemNumber = 1000000; + /// \} //===----------------------------------------------------------------------===// -- cgit v1.1