summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/TargetInstrInfo.cpp
diff options
context:
space:
mode:
authorDjordje Todorovic <djordje.todorovic@rt-rk.com>2019-07-09 11:33:56 +0000
committerDjordje Todorovic <djordje.todorovic@rt-rk.com>2019-07-09 11:33:56 +0000
commit01eaae6dd12862cda6b42d565a215b07a178aba6 (patch)
tree1100521e1eb7dce0a791709349f96a9efa16e432 /llvm/lib/CodeGen/TargetInstrInfo.cpp
parent9b3f38f99085e2bbf9db01bb00d4c6d837f0fc00 (diff)
downloadbcm5719-llvm-01eaae6dd12862cda6b42d565a215b07a178aba6.tar.gz
bcm5719-llvm-01eaae6dd12862cda6b42d565a215b07a178aba6.zip
[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 <asowda@cisco.com> Co-authored-by: Nikola Prica <nikola.prica@rt-rk.com> Co-authored-by: Ivan Baev <ibaev@cisco.com> Differential Revision: https://reviews.llvm.org/D60716 llvm-svn: 365467
Diffstat (limited to 'llvm/lib/CodeGen/TargetInstrInfo.cpp')
-rw-r--r--llvm/lib/CodeGen/TargetInstrInfo.cpp40
1 files changed, 40 insertions, 0 deletions
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<ParamLoadedValue>
+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<unsigned>(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,
OpenPOWER on IntegriCloud