summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/DebugInfo.cpp
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2014-08-01 22:11:58 +0000
committerAdrian Prantl <aprantl@apple.com>2014-08-01 22:11:58 +0000
commitb1416837f97cd1ec212673fb90fab0fb7df6c442 (patch)
tree22c532dbd53626600d03903704c6911f00e3d9af /llvm/lib/IR/DebugInfo.cpp
parent4184c79975256bbb9d3eec1622b99361770a6644 (diff)
downloadbcm5719-llvm-b1416837f97cd1ec212673fb90fab0fb7df6c442.tar.gz
bcm5719-llvm-b1416837f97cd1ec212673fb90fab0fb7df6c442.zip
Debug info: Infrastructure to support debug locations for fragmented
variables (for example, by-value struct arguments passed in registers, or large integer values split across several smaller registers). On the IR level, this adds a new type of complex address operation OpPiece to DIVariable that describes size and offset of a variable fragment. On the DWARF emitter level, all pieces describing the same variable are collected, sorted and emitted as DWARF expressions using the DW_OP_piece and DW_OP_bit_piece operators. http://reviews.llvm.org/D3373 rdar://problem/15928306 What this patch doesn't do / Future work: - This patch only adds the backend machinery to make this work, patches that change SROA and SelectionDAG's type legalizer to actually create such debug info will follow. (http://reviews.llvm.org/D2680) - Making the DIVariable complex expressions into an argument of dbg.value will reduce the memory footprint of the debug metadata. - The sorting/uniquing of pieces should be moved into DebugLocEntry, to facilitate the merging of multi-piece entries. llvm-svn: 214576
Diffstat (limited to 'llvm/lib/IR/DebugInfo.cpp')
-rw-r--r--llvm/lib/IR/DebugInfo.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index b08755ed707..c59b77eca0a 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -19,6 +19,7 @@
#include "llvm/ADT/SmallString.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/Constants.h"
+#include "llvm/IR/DIBuilder.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
@@ -150,6 +151,36 @@ uint64_t DIVariable::getAddrElement(unsigned Idx) const {
/// getInlinedAt - If this variable is inlined then return inline location.
MDNode *DIVariable::getInlinedAt() const { return getNodeField(DbgNode, 7); }
+bool DIVariable::isVariablePiece() const {
+ return hasComplexAddress() && getAddrElement(0) == DIBuilder::OpPiece;
+}
+
+uint64_t DIVariable::getPieceOffset() const {
+ assert(isVariablePiece());
+ return getAddrElement(1);
+}
+
+uint64_t DIVariable::getPieceSize() const {
+ assert(isVariablePiece());
+ return getAddrElement(2);
+}
+
+/// Return the size reported by the variable's type.
+unsigned DIVariable::getSizeInBits(const DITypeIdentifierMap &Map) {
+ DIType Ty = getType().resolve(Map);
+ // Follow derived types until we reach a type that
+ // reports back a size.
+ while (Ty.isDerivedType() && !Ty.getSizeInBits()) {
+ DIDerivedType DT(&*Ty);
+ Ty = DT.getTypeDerivedFrom().resolve(Map);
+ }
+ assert(Ty.getSizeInBits() && "type with size 0");
+ return Ty.getSizeInBits();
+}
+
+
+
+
//===----------------------------------------------------------------------===//
// Predicates
//===----------------------------------------------------------------------===//
@@ -904,6 +935,19 @@ DIVariable llvm::cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext) {
return DIVariable(MDNode::get(VMContext, Elts));
}
+
+/// getEntireVariable - Remove OpPiece exprs from the variable.
+DIVariable llvm::getEntireVariable(DIVariable DV) {
+ if (!DV.isVariablePiece())
+ return DV;
+
+ SmallVector<Value *, 8> Elts;
+ for (unsigned i = 0; i < 8; ++i)
+ Elts.push_back(DV->getOperand(i));
+
+ return DIVariable(MDNode::get(DV->getContext(), Elts));
+}
+
/// getDISubprogram - Find subprogram that is enclosing this scope.
DISubprogram llvm::getDISubprogram(const MDNode *Scope) {
DIDescriptor D(Scope);
@@ -1393,6 +1437,10 @@ void DIVariable::printInternal(raw_ostream &OS) const {
OS << " [" << Res << ']';
OS << " [line " << getLineNumber() << ']';
+
+ if (isVariablePiece())
+ OS << " [piece, size " << getPieceSize()
+ << ", offset " << getPieceOffset() << ']';
}
void DIObjCProperty::printInternal(raw_ostream &OS) const {
OpenPOWER on IntegriCloud