summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2017-08-18 18:07:00 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2017-08-18 18:07:00 +0000
commite101b07a1d7a17e2a6298f8e5fa09fd279a37d3b (patch)
tree2068d93ddcef6d270bbdd7da4074c6d6b6096ccb /llvm/lib/CodeGen
parent7b76de2dcb17920b5afeed97efa878527a454c09 (diff)
downloadbcm5719-llvm-e101b07a1d7a17e2a6298f8e5fa09fd279a37d3b.tar.gz
bcm5719-llvm-e101b07a1d7a17e2a6298f8e5fa09fd279a37d3b.zip
[Debug info] Transfer DI to fragment expressions for split integer values.
This patch teaches the SDag type legalizer how to split up debug info for integer values that are split into a hi and lo part. (re-commit) Differential Revision: https://reviews.llvm.org/D36805 llvm-svn: 311181
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp38
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h25
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp12
3 files changed, 59 insertions, 16 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
index 001eed9fb8f..7bef90d01a0 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
@@ -14,8 +14,12 @@
//===----------------------------------------------------------------------===//
#include "LegalizeTypes.h"
+#include "SDNodeDbgValue.h"
#include "llvm/ADT/SetVector.h"
+#include "llvm/CodeGen/MachineFunction.h"
+#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/IR/CallingConv.h"
+#include "llvm/IR/DIBuilder.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
@@ -822,6 +826,34 @@ void DAGTypeLegalizer::GetExpandedInteger(SDValue Op, SDValue &Lo,
Hi = Entry.second;
}
+/// Transfer debug valies by generating fragment expressions for split-up
+/// values.
+static void transferDbgValues(SelectionDAG &DAG, DIBuilder &DIB, SDValue From,
+ SDValue To, unsigned OffsetInBits) {
+ SDNode *FromNode = From.getNode();
+ SDNode *ToNode = To.getNode();
+ assert(FromNode != ToNode);
+
+ for (SDDbgValue *Dbg : DAG.GetDbgValues(FromNode)) {
+ if (Dbg->getKind() != SDDbgValue::SDNODE)
+ break;
+
+ DIVariable *Var = Dbg->getVariable();
+ DIExpression *Fragment = DIB.createFragmentExpression(
+ OffsetInBits, To.getValueSizeInBits(),
+ cast_or_null<DIExpression>(Dbg->getExpression()));
+ SDDbgValue *Clone =
+ DAG.getDbgValue(Var, Fragment, ToNode, To.getResNo(), Dbg->isIndirect(),
+ Dbg->getDebugLoc(), Dbg->getOrder());
+ Dbg->setIsInvalidated();
+ DAG.AddDbgValue(Clone, ToNode, false);
+
+ // Add the expression to the metadata graph so isn't lost in MIR dumps.
+ const Module *M = DAG.getMachineFunction().getMMI().getModule();
+ M->getNamedMetadata("llvm.dbg.mir")->addOperand(Fragment);
+ }
+}
+
void DAGTypeLegalizer::SetExpandedInteger(SDValue Op, SDValue Lo,
SDValue Hi) {
assert(Lo.getValueType() ==
@@ -832,6 +864,12 @@ void DAGTypeLegalizer::SetExpandedInteger(SDValue Op, SDValue Lo,
AnalyzeNewValue(Lo);
AnalyzeNewValue(Hi);
+ // Transfer debug values.
+ const Module *M = DAG.getMachineFunction().getMMI().getModule();
+ DIBuilder DIB(*const_cast<Module *>(M));
+ transferDbgValues(DAG, DIB, Op, Lo, 0);
+ transferDbgValues(DAG, DIB, Op, Hi, Lo.getValueSizeInBits());
+
// Remember that this is the result of the node.
std::pair<SDValue, SDValue> &Entry = ExpandedIntegers[Op];
assert(!Entry.first.getNode() && "Node already expanded");
diff --git a/llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h b/llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h
index a1b1c78fb8c..cd5b4c12f1d 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h
+++ b/llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h
@@ -20,7 +20,8 @@
namespace llvm {
-class MDNode;
+class DIVariable;
+class DIExpression;
class SDNode;
class Value;
@@ -43,8 +44,8 @@ private:
const Value *Const; // valid for constants
unsigned FrameIx; // valid for stack objects
} u;
- MDNode *Var;
- MDNode *Expr;
+ DIVariable *Var;
+ DIExpression *Expr;
DebugLoc DL;
unsigned Order;
enum DbgValueKind kind;
@@ -53,8 +54,8 @@ private:
public:
// Constructor for non-constants.
- SDDbgValue(MDNode *Var, MDNode *Expr, SDNode *N, unsigned R, bool indir,
- DebugLoc dl, unsigned O)
+ SDDbgValue(DIVariable *Var, DIExpression *Expr, SDNode *N, unsigned R,
+ bool indir, DebugLoc dl, unsigned O)
: Var(Var), Expr(Expr), DL(std::move(dl)), Order(O), IsIndirect(indir) {
kind = SDNODE;
u.s.Node = N;
@@ -62,14 +63,16 @@ public:
}
// Constructor for constants.
- SDDbgValue(MDNode *Var, MDNode *Expr, const Value *C, DebugLoc dl, unsigned O)
+ SDDbgValue(DIVariable *Var, DIExpression *Expr, const Value *C, DebugLoc dl,
+ unsigned O)
: Var(Var), Expr(Expr), DL(std::move(dl)), Order(O), IsIndirect(false) {
kind = CONST;
u.Const = C;
}
// Constructor for frame indices.
- SDDbgValue(MDNode *Var, MDNode *Expr, unsigned FI, DebugLoc dl, unsigned O)
+ SDDbgValue(DIVariable *Var, DIExpression *Expr, unsigned FI, DebugLoc dl,
+ unsigned O)
: Var(Var), Expr(Expr), DL(std::move(dl)), Order(O), IsIndirect(false) {
kind = FRAMEIX;
u.FrameIx = FI;
@@ -78,11 +81,11 @@ public:
// Returns the kind.
DbgValueKind getKind() const { return kind; }
- // Returns the MDNode pointer for the variable.
- MDNode *getVariable() const { return Var; }
+ // Returns the DIVariable pointer for the variable.
+ DIVariable *getVariable() const { return Var; }
- // Returns the MDNode pointer for the expression.
- MDNode *getExpression() const { return Expr; }
+ // Returns the DIExpression pointer for the expression.
+ DIExpression *getExpression() const { return Expr; }
// Returns the SDNode* for a register ref
SDNode *getSDNode() const { assert (kind==SDNODE); return u.s.Node; }
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 0ef8adaabbb..508316a1fad 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -6879,8 +6879,8 @@ SDNode *SelectionDAG::getNodeIfExists(unsigned Opcode, SDVTList VTList,
/// getDbgValue - Creates a SDDbgValue node.
///
/// SDNode
-SDDbgValue *SelectionDAG::getDbgValue(MDNode *Var, MDNode *Expr, SDNode *N,
- unsigned R, bool IsIndirect,
+SDDbgValue *SelectionDAG::getDbgValue(DIVariable *Var, DIExpression *Expr,
+ SDNode *N, unsigned R, bool IsIndirect,
const DebugLoc &DL, unsigned O) {
assert(cast<DILocalVariable>(Var)->isValidLocationForIntrinsic(DL) &&
"Expected inlined-at fields to agree");
@@ -6889,7 +6889,8 @@ SDDbgValue *SelectionDAG::getDbgValue(MDNode *Var, MDNode *Expr, SDNode *N,
}
/// Constant
-SDDbgValue *SelectionDAG::getConstantDbgValue(MDNode *Var, MDNode *Expr,
+SDDbgValue *SelectionDAG::getConstantDbgValue(DIVariable *Var,
+ DIExpression *Expr,
const Value *C,
const DebugLoc &DL, unsigned O) {
assert(cast<DILocalVariable>(Var)->isValidLocationForIntrinsic(DL) &&
@@ -6898,8 +6899,9 @@ SDDbgValue *SelectionDAG::getConstantDbgValue(MDNode *Var, MDNode *Expr,
}
/// FrameIndex
-SDDbgValue *SelectionDAG::getFrameIndexDbgValue(MDNode *Var, MDNode *Expr,
- unsigned FI, const DebugLoc &DL,
+SDDbgValue *SelectionDAG::getFrameIndexDbgValue(DIVariable *Var,
+ DIExpression *Expr, unsigned FI,
+ const DebugLoc &DL,
unsigned O) {
assert(cast<DILocalVariable>(Var)->isValidLocationForIntrinsic(DL) &&
"Expected inlined-at fields to agree");
OpenPOWER on IntegriCloud