aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/DIBuilder.cpp
diff options
context:
space:
mode:
authorMichael Gottesman <mgottesman@apple.com>2022-01-16 12:44:52 -0800
committerMichael Gottesman <mgottesman@apple.com>2022-01-18 18:26:50 -0800
commit7ed95d1577558f95db6b03968b561b17bbb0fec3 (patch)
tree5eea30837db840c499d76a660a191a20e370af0b /llvm/lib/IR/DIBuilder.cpp
parentff0b634d97b9dbcd3d245ce60cf763d2c304c80c (diff)
downloadllvm-7ed95d1577558f95db6b03968b561b17bbb0fec3.zip
llvm-7ed95d1577558f95db6b03968b561b17bbb0fec3.tar.gz
llvm-7ed95d1577558f95db6b03968b561b17bbb0fec3.tar.bz2
[debug-info] Add support for llvm.dbg.addr in DIBuilder.
I based this off of the API already create for llvm.dbg.value since both intrinsics have the same arguments at the API level. I added some tests exercising the API a little as well as an additional small test that shows how one can use llvm.dbg.addr to limit the PC range where an address value is available in the debugger. This is done by calling llvm.dbg.value with undef and the same metadata info as one used to create the llvm.dbg.addr. rdar://83957028 Reviewed By: aprantl Differential Revision: https://reviews.llvm.org/D117442
Diffstat (limited to 'llvm/lib/IR/DIBuilder.cpp')
-rw-r--r--llvm/lib/IR/DIBuilder.cpp39
1 files changed, 30 insertions, 9 deletions
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp
index 16429e0..5712f4e 100644
--- a/llvm/lib/IR/DIBuilder.cpp
+++ b/llvm/lib/IR/DIBuilder.cpp
@@ -33,7 +33,7 @@ static cl::opt<bool>
DIBuilder::DIBuilder(Module &m, bool AllowUnresolvedNodes, DICompileUnit *CU)
: M(m), VMContext(M.getContext()), CUNode(CU), DeclareFn(nullptr),
- ValueFn(nullptr), LabelFn(nullptr),
+ ValueFn(nullptr), LabelFn(nullptr), AddrFn(nullptr),
AllowUnresolvedNodes(AllowUnresolvedNodes) {
if (CUNode) {
if (const auto &ETs = CUNode->getEnumTypes())
@@ -974,6 +974,24 @@ Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V,
return insertDbgValueIntrinsic(V, VarInfo, Expr, DL, InsertAtEnd, nullptr);
}
+Instruction *DIBuilder::insertDbgAddrIntrinsic(Value *V,
+ DILocalVariable *VarInfo,
+ DIExpression *Expr,
+ const DILocation *DL,
+ Instruction *InsertBefore) {
+ return insertDbgAddrIntrinsic(
+ V, VarInfo, Expr, DL, InsertBefore ? InsertBefore->getParent() : nullptr,
+ InsertBefore);
+}
+
+Instruction *DIBuilder::insertDbgAddrIntrinsic(Value *V,
+ DILocalVariable *VarInfo,
+ DIExpression *Expr,
+ const DILocation *DL,
+ BasicBlock *InsertAtEnd) {
+ return insertDbgAddrIntrinsic(V, VarInfo, Expr, DL, InsertAtEnd, nullptr);
+}
+
/// Initialize IRBuilder for inserting dbg.declare and dbg.value intrinsics.
/// This abstracts over the various ways to specify an insert position.
static void initIRBuilder(IRBuilder<> &Builder, const DILocation *DL,
@@ -1018,17 +1036,20 @@ Instruction *DIBuilder::insertDeclare(Value *Storage, DILocalVariable *VarInfo,
return B.CreateCall(DeclareFn, Args);
}
-Instruction *DIBuilder::insertDbgValueIntrinsic(
- Value *V, DILocalVariable *VarInfo, DIExpression *Expr,
- const DILocation *DL, BasicBlock *InsertBB, Instruction *InsertBefore) {
- assert(V && "no value passed to dbg.value");
- assert(VarInfo && "empty or invalid DILocalVariable* passed to dbg.value");
+Instruction *DIBuilder::insertDbgIntrinsic(llvm::Function *IntrinsicFn,
+ Value *V, DILocalVariable *VarInfo,
+ DIExpression *Expr,
+ const DILocation *DL,
+ BasicBlock *InsertBB,
+ Instruction *InsertBefore) {
+ assert(IntrinsicFn && "must pass a non-null intrinsic function");
+ assert(V && "must pass a value to a dbg intrinsic");
+ assert(VarInfo &&
+ "empty or invalid DILocalVariable* passed to debug intrinsic");
assert(DL && "Expected debug loc");
assert(DL->getScope()->getSubprogram() ==
VarInfo->getScope()->getSubprogram() &&
"Expected matching subprograms");
- if (!ValueFn)
- ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
trackIfUnresolved(VarInfo);
trackIfUnresolved(Expr);
@@ -1038,7 +1059,7 @@ Instruction *DIBuilder::insertDbgValueIntrinsic(
IRBuilder<> B(DL->getContext());
initIRBuilder(B, DL, InsertBB, InsertBefore);
- return B.CreateCall(ValueFn, Args);
+ return B.CreateCall(IntrinsicFn, Args);
}
Instruction *DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL,