summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Verifier.cpp
diff options
context:
space:
mode:
authorDavide Italiano <davide@freebsd.org>2016-04-12 18:22:33 +0000
committerDavide Italiano <davide@freebsd.org>2016-04-12 18:22:33 +0000
commitb390d8ee3980f729d1dc777c0cf422a2d72eb625 (patch)
tree1ff64a6944685e5c8c674b3451f2ff0b4cceec9f /llvm/lib/IR/Verifier.cpp
parentc3943574301f575ec22c1789836898614f96b86b (diff)
downloadbcm5719-llvm-b390d8ee3980f729d1dc777c0cf422a2d72eb625.tar.gz
bcm5719-llvm-b390d8ee3980f729d1dc777c0cf422a2d72eb625.zip
[IR/Verifier] Each DISubprogram with isDefinition: true must belong to a CU.
Add a check to catch violations. ~60 tests were broken and prevented this change to be committed. Adrian and I (thanks Adrian!) went through them in the last week or so updating. The check can be done more efficiently but I'd still like to get this in ASAP to avoid more broken tests to be checked in (if any). PR: 27101 llvm-svn: 266102
Diffstat (limited to 'llvm/lib/IR/Verifier.cpp')
-rw-r--r--llvm/lib/IR/Verifier.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 8f055886efe..cb9b641a73f 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -1011,6 +1011,22 @@ void Verifier::visitDISubprogram(const DISubprogram &N) {
if (N.isDefinition())
Assert(N.isDistinct(), "subprogram definitions must be distinct", &N);
+
+ // Ensure that every DISubprogram with isDefinition: true belongs
+ // to a DICompileUnit.
+ // FIXME: This is a very inefficient way of handling the problem.
+ // Use a SmallSetPtr which contains the Listed DISubprograms in the CU
+ // instead.
+ if (N.isDefinition()) {
+ auto *CUs = M->getNamedMetadata("llvm.dbg.cu");
+ Assert(CUs, "subprogram must belong to a compile unit", &N);
+ for (auto *CU : CUs->operands())
+ if (auto Subprograms = cast<DICompileUnit>(CU)->getSubprograms())
+ for (const auto *Sp : Subprograms)
+ if (Sp == &N)
+ return;
+ Assert(false, "subprogram not found in any compile unit", &N);
+ }
}
void Verifier::visitDILexicalBlockBase(const DILexicalBlockBase &N) {
OpenPOWER on IntegriCloud