mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-23 17:24:48 +00:00
DebugInfo: Require a DebugLoc in DIBuilder::insertDeclare()
Change `DIBuilder::insertDeclare()` and `insertDbgValueIntrinsic()` to take an `MDLocation*`/`DebugLoc` parameter which it attaches to the created intrinsic. Assert at creation time that the `scope:` field's subprogram matches the variable's. There's a matching `clang` commit to use the API. The context for this is PR22778, which is removing the `inlinedAt:` field from `MDLocalVariable`, instead deferring to the `!dbg` location attached to the debug info intrinsic. The best way to ensure we always have a `!dbg` attachment is to require one at creation time. I'll be adding verifier checks next, but this API change is the best way to shake out frontend bugs. Note: I added an `llvm_unreachable()` in `bindings/go` and passed in `nullptr` for the `DebugLoc`. The `llgo` folks will eventually need to pass a valid `DebugLoc` here. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235041 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -761,10 +761,19 @@ static Value *getDbgIntrinsicValueImpl(LLVMContext &VMContext, Value *V) {
|
||||
return MetadataAsValue::get(VMContext, ValueAsMetadata::get(V));
|
||||
}
|
||||
|
||||
static Instruction *withDebugLoc(Instruction *I, const MDLocation *DL) {
|
||||
I->setDebugLoc(const_cast<MDLocation *>(DL));
|
||||
return I;
|
||||
}
|
||||
|
||||
Instruction *DIBuilder::insertDeclare(Value *Storage, DIVariable VarInfo,
|
||||
DIExpression Expr,
|
||||
DIExpression Expr, const MDLocation *DL,
|
||||
Instruction *InsertBefore) {
|
||||
assert(VarInfo && "empty or invalid DIVariable passed to dbg.declare");
|
||||
assert(DL && "Expected debug loc");
|
||||
assert(DL->getScope()->getSubprogram() ==
|
||||
VarInfo->getScope()->getSubprogram() &&
|
||||
"Expected matching subprograms");
|
||||
if (!DeclareFn)
|
||||
DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
|
||||
|
||||
@ -773,13 +782,17 @@ Instruction *DIBuilder::insertDeclare(Value *Storage, DIVariable VarInfo,
|
||||
Value *Args[] = {getDbgIntrinsicValueImpl(VMContext, Storage),
|
||||
MetadataAsValue::get(VMContext, VarInfo),
|
||||
MetadataAsValue::get(VMContext, Expr)};
|
||||
return CallInst::Create(DeclareFn, Args, "", InsertBefore);
|
||||
return withDebugLoc(CallInst::Create(DeclareFn, Args, "", InsertBefore), DL);
|
||||
}
|
||||
|
||||
Instruction *DIBuilder::insertDeclare(Value *Storage, DIVariable VarInfo,
|
||||
DIExpression Expr,
|
||||
DIExpression Expr, const MDLocation *DL,
|
||||
BasicBlock *InsertAtEnd) {
|
||||
assert(VarInfo && "empty or invalid DIVariable passed to dbg.declare");
|
||||
assert(DL && "Expected debug loc");
|
||||
assert(DL->getScope()->getSubprogram() ==
|
||||
VarInfo->getScope()->getSubprogram() &&
|
||||
"Expected matching subprograms");
|
||||
if (!DeclareFn)
|
||||
DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
|
||||
|
||||
@ -792,17 +805,21 @@ Instruction *DIBuilder::insertDeclare(Value *Storage, DIVariable VarInfo,
|
||||
// If this block already has a terminator then insert this intrinsic
|
||||
// before the terminator.
|
||||
if (TerminatorInst *T = InsertAtEnd->getTerminator())
|
||||
return CallInst::Create(DeclareFn, Args, "", T);
|
||||
else
|
||||
return CallInst::Create(DeclareFn, Args, "", InsertAtEnd);
|
||||
return withDebugLoc(CallInst::Create(DeclareFn, Args, "", T), DL);
|
||||
return withDebugLoc(CallInst::Create(DeclareFn, Args, "", InsertAtEnd), DL);
|
||||
}
|
||||
|
||||
Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
|
||||
DIVariable VarInfo,
|
||||
DIExpression Expr,
|
||||
const MDLocation *DL,
|
||||
Instruction *InsertBefore) {
|
||||
assert(V && "no value passed to dbg.value");
|
||||
assert(VarInfo && "empty or invalid DIVariable passed to dbg.value");
|
||||
assert(DL && "Expected debug loc");
|
||||
assert(DL->getScope()->getSubprogram() ==
|
||||
VarInfo->getScope()->getSubprogram() &&
|
||||
"Expected matching subprograms");
|
||||
if (!ValueFn)
|
||||
ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
|
||||
|
||||
@ -812,15 +829,20 @@ Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
|
||||
ConstantInt::get(Type::getInt64Ty(VMContext), Offset),
|
||||
MetadataAsValue::get(VMContext, VarInfo),
|
||||
MetadataAsValue::get(VMContext, Expr)};
|
||||
return CallInst::Create(ValueFn, Args, "", InsertBefore);
|
||||
return withDebugLoc(CallInst::Create(ValueFn, Args, "", InsertBefore), DL);
|
||||
}
|
||||
|
||||
Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
|
||||
DIVariable VarInfo,
|
||||
DIExpression Expr,
|
||||
const MDLocation *DL,
|
||||
BasicBlock *InsertAtEnd) {
|
||||
assert(V && "no value passed to dbg.value");
|
||||
assert(VarInfo && "empty or invalid DIVariable passed to dbg.value");
|
||||
assert(DL && "Expected debug loc");
|
||||
assert(DL->getScope()->getSubprogram() ==
|
||||
VarInfo->getScope()->getSubprogram() &&
|
||||
"Expected matching subprograms");
|
||||
if (!ValueFn)
|
||||
ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
|
||||
|
||||
@ -830,7 +852,8 @@ Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
|
||||
ConstantInt::get(Type::getInt64Ty(VMContext), Offset),
|
||||
MetadataAsValue::get(VMContext, VarInfo),
|
||||
MetadataAsValue::get(VMContext, Expr)};
|
||||
return CallInst::Create(ValueFn, Args, "", InsertAtEnd);
|
||||
|
||||
return withDebugLoc(CallInst::Create(ValueFn, Args, "", InsertAtEnd), DL);
|
||||
}
|
||||
|
||||
void DIBuilder::replaceVTableHolder(DICompositeType &T, DICompositeType VTableHolder) {
|
||||
|
Reference in New Issue
Block a user