From 01eaae6dd12862cda6b42d565a215b07a178aba6 Mon Sep 17 00:00:00 2001 From: Djordje Todorovic Date: Tue, 9 Jul 2019 11:33:56 +0000 Subject: [DwarfDebug] Dump call site debug info Dump the DWARF information about call sites and call site parameters into debug info sections. The patch also provides an interface for the interpretation of instructions that could load values of a call site parameters in order to generate DWARF about the call site parameters. ([13/13] Introduce the debug entry values.) Co-authored-by: Ananth Sowda Co-authored-by: Nikola Prica Co-authored-by: Ivan Baev Differential Revision: https://reviews.llvm.org/D60716 llvm-svn: 365467 --- llvm/lib/CodeGen/TargetInstrInfo.cpp | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'llvm/lib/CodeGen/TargetInstrInfo.cpp') diff --git a/llvm/lib/CodeGen/TargetInstrInfo.cpp b/llvm/lib/CodeGen/TargetInstrInfo.cpp index 868617ffe14..f7f3e11f18a 100644 --- a/llvm/lib/CodeGen/TargetInstrInfo.cpp +++ b/llvm/lib/CodeGen/TargetInstrInfo.cpp @@ -23,6 +23,7 @@ #include "llvm/CodeGen/TargetRegisterInfo.h" #include "llvm/CodeGen/TargetSchedule.h" #include "llvm/IR/DataLayout.h" +#include "llvm/IR/DebugInfoMetadata.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCInstrItineraries.h" #include "llvm/Support/CommandLine.h" @@ -1120,6 +1121,45 @@ bool TargetInstrInfo::hasLowDefLatency(const TargetSchedModel &SchedModel, return (DefCycle != -1 && DefCycle <= 1); } +Optional +TargetInstrInfo::describeLoadedValue(const MachineInstr &MI) const { + const MachineOperand *Op = nullptr; + DIExpression *Expr = nullptr; + + const MachineOperand *SrcRegOp, *DestRegOp; + const MachineFunction *MF = MI.getMF(); + if (isCopyInstr(MI, SrcRegOp, DestRegOp)) { + Expr = DIExpression::get(MF->getFunction().getContext(), {}); + Op = SrcRegOp; + return ParamLoadedValue(Op, Expr); + } else if (MI.isMoveImmediate()) { + Expr = DIExpression::get(MF->getFunction().getContext(), {}); + Op = &MI.getOperand(1); + return ParamLoadedValue(Op, Expr); + } else if (MI.hasOneMemOperand()) { + int64_t Offset; + const auto &TRI = MF->getSubtarget().getRegisterInfo(); + const auto &TII = MF->getSubtarget().getInstrInfo(); + const MachineOperand *BaseOp; + if (!TII->getMemOperandWithOffset(MI, BaseOp, Offset, TRI)) + return None; + unsigned CastedOffset = static_cast(Offset); + if (Offset > 0) + Expr = DIExpression::get( + MF->getFunction().getContext(), + {dwarf::DW_OP_plus_uconst, CastedOffset, dwarf::DW_OP_deref}); + else + Expr = DIExpression::get(MF->getFunction().getContext(), + {dwarf::DW_OP_constu, -CastedOffset, + dwarf::DW_OP_minus, dwarf::DW_OP_deref}); + + Op = BaseOp; + return ParamLoadedValue(Op, Expr); + } + + return None; +} + /// Both DefMI and UseMI must be valid. By default, call directly to the /// itinerary. This may be overriden by the target. int TargetInstrInfo::getOperandLatency(const InstrItineraryData *ItinData, -- cgit v1.2.3