summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Verifier.cpp
diff options
context:
space:
mode:
authorDavide Italiano <davide@freebsd.org>2016-04-06 03:07:58 +0000
committerDavide Italiano <davide@freebsd.org>2016-04-06 03:07:58 +0000
commit8dc23a3cb58331c7b601d091d1c8c68aefb95041 (patch)
tree7a6623da5b5b86fc7deffc1b260895bda19530c4 /llvm/lib/IR/Verifier.cpp
parent8e594fdf1990ab227260d6e28b3bcd5438620e57 (diff)
downloadbcm5719-llvm-8dc23a3cb58331c7b601d091d1c8c68aefb95041.tar.gz
bcm5719-llvm-8dc23a3cb58331c7b601d091d1c8c68aefb95041.zip
[IRVerifier] Avoid crashing on an invalid compile unit.
llvm-svn: 265514
Diffstat (limited to 'llvm/lib/IR/Verifier.cpp')
-rw-r--r--llvm/lib/IR/Verifier.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 5770d6c8770..fe3d6eb6cf4 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -4376,13 +4376,14 @@ void Verifier::verifyTypeRefs() {
// Visit all the compile units again to map the type references.
SmallDenseMap<const MDString *, const DIType *, 32> TypeRefs;
for (auto *CU : CUs->operands())
- if (auto Ts = cast<DICompileUnit>(CU)->getRetainedTypes())
- for (DIType *Op : Ts)
- if (auto *T = dyn_cast_or_null<DICompositeType>(Op))
- if (auto *S = T->getRawIdentifier()) {
- UnresolvedTypeRefs.erase(S);
- TypeRefs.insert(std::make_pair(S, T));
- }
+ if (isa<DICompileUnit>(CU))
+ if (auto Ts = cast<DICompileUnit>(CU)->getRetainedTypes())
+ for (DIType *Op : Ts)
+ if (auto *T = dyn_cast_or_null<DICompositeType>(Op))
+ if (auto *S = T->getRawIdentifier()) {
+ UnresolvedTypeRefs.erase(S);
+ TypeRefs.insert(std::make_pair(S, T));
+ }
// Verify debug info intrinsic bit piece expressions. This needs a second
// pass through the intructions, since we haven't built TypeRefs yet when
OpenPOWER on IntegriCloud