aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Hernandez <vhernandez@apple.com>2009-12-07 19:36:34 +0000
committerVictor Hernandez <vhernandez@apple.com>2009-12-07 19:36:34 +0000
commit2f9dac721d6b015fd16730bd51bffc86e29e6fdf (patch)
treec8165e684f0d1518edafa8a8b4eb94656d2dd6e1
parentbc39a795f46ef04326915d881dc1d861144e3e19 (diff)
Introduce the "@llvm.dbg.value" debug intrinsic.
The semantics of llvm.dbg.value are that starting from where it is executed, an offset into the specified user source variable is specified to get a new value. An example: call void @llvm.dbg.value(metadata !{ i32 7 }, i64 0, metadata !2) Here the user source variable associated with metadata #2 gets the value "i32 7" at offset 0. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90788 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Analysis/DebugInfo.h8
-rw-r--r--include/llvm/IntrinsicInst.h20
-rw-r--r--include/llvm/Intrinsics.td3
-rw-r--r--lib/Analysis/DebugInfo.cpp29
4 files changed, 60 insertions, 0 deletions
diff --git a/include/llvm/Analysis/DebugInfo.h b/include/llvm/Analysis/DebugInfo.h
index c560ec2e35..4ddde0158a 100644
--- a/include/llvm/Analysis/DebugInfo.h
+++ b/include/llvm/Analysis/DebugInfo.h
@@ -492,6 +492,7 @@ namespace llvm {
const Type *EmptyStructPtr; // "{}*".
Function *DeclareFn; // llvm.dbg.declare
+ Function *ValueFn; // llvm.dbg.value
DIFactory(const DIFactory &); // DO NOT IMPLEMENT
void operator=(const DIFactory&); // DO NOT IMPLEMENT
@@ -639,6 +640,13 @@ namespace llvm {
Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D,
Instruction *InsertBefore);
+ /// InsertValue - Insert a new llvm.dbg.value intrinsic call.
+ Instruction *InsertValue(llvm::Value *V, llvm::Value *Offset,
+ DIVariable D, BasicBlock *InsertAtEnd);
+
+ /// InsertValue - Insert a new llvm.dbg.value intrinsic call.
+ Instruction *InsertValue(llvm::Value *V, llvm::Value *Offset,
+ DIVariable D, Instruction *InsertBefore);
private:
Constant *GetTagConstant(unsigned TAG);
};
diff --git a/include/llvm/IntrinsicInst.h b/include/llvm/IntrinsicInst.h
index 1e1dca2eba..a516409296 100644
--- a/include/llvm/IntrinsicInst.h
+++ b/include/llvm/IntrinsicInst.h
@@ -70,6 +70,7 @@ namespace llvm {
case Intrinsic::dbg_region_start:
case Intrinsic::dbg_region_end:
case Intrinsic::dbg_declare:
+ case Intrinsic::dbg_value:
return true;
default: return false;
}
@@ -171,6 +172,25 @@ namespace llvm {
}
};
+ /// DbgValueInst - This represents the llvm.dbg.value instruction.
+ ///
+ struct DbgValueInst : public DbgInfoIntrinsic {
+ Value *getValue() const {
+ return cast<MDNode>(getOperand(1))->getElement(0);
+ }
+ Value *getOffset() const { return getOperand(2); }
+ MDNode *getVariable() const { return cast<MDNode>(getOperand(3)); }
+
+ // Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const DbgValueInst *) { return true; }
+ static inline bool classof(const IntrinsicInst *I) {
+ return I->getIntrinsicID() == Intrinsic::dbg_value;
+ }
+ static inline bool classof(const Value *V) {
+ return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
+ }
+ };
+
/// MemIntrinsic - This is the common base class for memset/memcpy/memmove.
///
struct MemIntrinsic : public IntrinsicInst {
diff --git a/include/llvm/Intrinsics.td b/include/llvm/Intrinsics.td
index b3b0678a24..6ff87ba150 100644
--- a/include/llvm/Intrinsics.td
+++ b/include/llvm/Intrinsics.td
@@ -290,6 +290,9 @@ let Properties = [IntrNoMem] in {
def int_dbg_func_start : Intrinsic<[llvm_void_ty], [llvm_metadata_ty]>;
def int_dbg_declare : Intrinsic<[llvm_void_ty],
[llvm_descriptor_ty, llvm_metadata_ty]>;
+ def int_dbg_value : Intrinsic<[llvm_void_ty],
+ [llvm_metadata_ty, llvm_i64_ty,
+ llvm_metadata_ty]>;
}
//===------------------ Exception Handling Intrinsics----------------------===//
diff --git a/lib/Analysis/DebugInfo.cpp b/lib/Analysis/DebugInfo.cpp
index 4a012ce484..74d9e1e179 100644
--- a/lib/Analysis/DebugInfo.cpp
+++ b/lib/Analysis/DebugInfo.cpp
@@ -1050,6 +1050,35 @@ Instruction *DIFactory::InsertDeclare(Value *Storage, DIVariable D,
return CallInst::Create(DeclareFn, Args, Args+2, "", InsertAtEnd);
}
+/// InsertValue - Insert a new llvm.dbg.value intrinsic call.
+Instruction *DIFactory::InsertValue(Value *V, Value *Offset, DIVariable D,
+ Instruction *InsertBefore) {
+ assert(V && "no value passed to dbg.value");
+ assert(Offset->getType() == Type::getInt64Ty(V->getContext()) &&
+ "offset must be i64");
+ if (!ValueFn)
+ ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
+
+ Value *Elts[] = { V };
+ Value *Args[] = { MDNode::get(V->getContext(), Elts, 1), Offset,
+ D.getNode() };
+ return CallInst::Create(ValueFn, Args, Args+3, "", InsertBefore);
+}
+
+/// InsertValue - Insert a new llvm.dbg.value intrinsic call.
+Instruction *DIFactory::InsertValue(Value *V, Value *Offset, DIVariable D,
+ BasicBlock *InsertAtEnd) {
+ assert(V && "no value passed to dbg.value");
+ assert(Offset->getType() == Type::getInt64Ty(V->getContext()) &&
+ "offset must be i64");
+ if (!ValueFn)
+ ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
+
+ Value *Elts[] = { V };
+ Value *Args[] = { MDNode::get(V->getContext(), Elts, 1), Offset,
+ D.getNode() };
+ return CallInst::Create(ValueFn, Args, Args+3, "", InsertAtEnd);
+}
//===----------------------------------------------------------------------===//
// DebugInfoFinder implementations.