From 57fcd3454a5c3285fe7959e14601b8c307ed03b6 Mon Sep 17 00:00:00 2001 From: Francis Visoiu Mistrih Date: Wed, 25 Apr 2018 18:58:06 +0000 Subject: [MIR] Add support for debug metadata for fixed stack objects Debug var, expr and loc were only supported for non-fixed stack objects. This patch adds the following fields to the "fixedStack:" entries, and renames the ones from "stack:" to: * debug-info-variable * debug-info-expression * debug-info-location Differential Revision: https://reviews.llvm.org/D46032 llvm-svn: 330859 --- llvm/lib/CodeGen/MIRPrinter.cpp | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'llvm/lib/CodeGen/MIRPrinter.cpp') diff --git a/llvm/lib/CodeGen/MIRPrinter.cpp b/llvm/lib/CodeGen/MIRPrinter.cpp index 15a6a578ce7..797affa9431 100644 --- a/llvm/lib/CodeGen/MIRPrinter.cpp +++ b/llvm/lib/CodeGen/MIRPrinter.cpp @@ -256,6 +256,21 @@ static void printRegClassOrBank(unsigned Reg, yaml::StringValue &Dest, OS << printRegClassOrBank(Reg, RegInfo, TRI); } +template +static void +printStackObjectDbgInfo(const MachineFunction::VariableDbgInfo &DebugVar, + T &Object, ModuleSlotTracker &MST) { + std::array Outputs{{&Object.DebugVar.Value, + &Object.DebugExpr.Value, + &Object.DebugLoc.Value}}; + std::array Metas{{DebugVar.Var, + DebugVar.Expr, + DebugVar.Loc}}; + for (unsigned i = 0; i < 3; ++i) { + raw_string_ostream StrOS(*Outputs[i]); + Metas[i]->printAsOperand(StrOS, MST); + } +} void MIRPrinter::convert(yaml::MachineFunction &MF, const MachineRegisterInfo &RegInfo, @@ -421,19 +436,12 @@ void MIRPrinter::convertStackObjects(yaml::MachineFunction &YMF, assert(StackObjectInfo != StackObjectOperandMapping.end() && "Invalid stack object index"); const FrameIndexOperand &StackObject = StackObjectInfo->second; - assert(!StackObject.IsFixed && "Expected a non-fixed stack object"); - auto &Object = YMF.StackObjects[StackObject.ID]; - { - raw_string_ostream StrOS(Object.DebugVar.Value); - DebugVar.Var->printAsOperand(StrOS, MST); - } - { - raw_string_ostream StrOS(Object.DebugExpr.Value); - DebugVar.Expr->printAsOperand(StrOS, MST); - } - { - raw_string_ostream StrOS(Object.DebugLoc.Value); - DebugVar.Loc->printAsOperand(StrOS, MST); + if (StackObject.IsFixed) { + auto &Object = YMF.FixedStackObjects[StackObject.ID]; + printStackObjectDbgInfo(DebugVar, Object, MST); + } else { + auto &Object = YMF.StackObjects[StackObject.ID]; + printStackObjectDbgInfo(DebugVar, Object, MST); } } } -- cgit v1.2.3