summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Verifier.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/IR/Verifier.cpp')
-rw-r--r--llvm/lib/IR/Verifier.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 31ddd6543a7..15e354b8dfc 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -3372,6 +3372,20 @@ void Verifier::visitDbgIntrinsic(StringRef Kind, DbgIntrinsicTy &DII) {
Assert(isa<MDExpression>(DII.getRawExpression()),
"invalid llvm.dbg." + Kind + " intrinsic expression", &DII,
DII.getRawExpression());
+
+ // Ignore broken !dbg attachments; they're checked elsewhere.
+ if (MDNode *N = DII.getDebugLoc().getAsMDNode())
+ if (!isa<MDLocation>(N))
+ return;
+
+ // The inlined-at attachments for variables and !dbg attachments must agree.
+ MDLocalVariable *Var = DII.getVariable();
+ MDLocation *VarIA = Var->getInlinedAt();
+ MDLocation *Loc = DII.getDebugLoc();
+ MDLocation *LocIA = Loc ? Loc->getInlinedAt() : nullptr;
+ BasicBlock *BB = DII.getParent();
+ Assert(VarIA == LocIA, "mismatched variable and !dbg inlined-at", &DII, BB,
+ BB ? BB->getParent() : nullptr, Var, VarIA, Loc, LocIA);
}
void Verifier::visitUnresolvedTypeRef(const MDString *S, const MDNode *N) {
OpenPOWER on IntegriCloud