Verifier: Check that @llvm.dbg.* intrinsics have a !dbg attachment
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Wed, 15 Apr 2015 22:15:46 +0000 (22:15 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Wed, 15 Apr 2015 22:15:46 +0000 (22:15 +0000)
commit94255c8eb0bd037ad3f186f15b664ab680771358
tree51723e12fe89d419762d719fd5d546f3803c9535
parentf422262d55901a482875094f7f2e6ad5739813f7
Verifier: Check that @llvm.dbg.* intrinsics have a !dbg attachment

Before we start to rely on valid `!dbg` attachments, add a check to the
verifier that `@llvm.dbg.*` intrinsics always have one.  Also check that
the `scope:` fields point at the same `MDSubprogram`.

This is in the context of PR22778.  The check that the `inlinedAt:`
fields agree has baked for a while (since r234021), so I'll kill [1] the
`MDLocalVariable::getInlinedAt()` field soon.

[1]: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20150330/269387.html

Unfortunately, that means it's impossible to keep the current `Verifier`
checks, which rely on comparing `inlinedAt:` fields.  We'll be able to
keep the checks I'm adding here.

If this breaks your out-of-tree testcases, the upgrade script
(add-dbg-to-intrinsics.sh) attached to PR22778 that I used for r235040
might fix them for you.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235048 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/IR/DebugInfoMetadata.h
lib/IR/Verifier.cpp
test/Verifier/llvm.dbg.declare-variable.ll
test/Verifier/llvm.dbg.intrinsic-dbg-attachment.ll [new file with mode: 0644]
test/Verifier/llvm.dbg.value-expression.ll
test/Verifier/llvm.dbg.value-variable.ll