From 8dc23a3cb58331c7b601d091d1c8c68aefb95041 Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Wed, 6 Apr 2016 03:07:58 +0000 Subject: [IRVerifier] Avoid crashing on an invalid compile unit. llvm-svn: 265514 --- llvm/lib/IR/Verifier.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'llvm/lib/IR/Verifier.cpp') 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 TypeRefs; for (auto *CU : CUs->operands()) - if (auto Ts = cast(CU)->getRetainedTypes()) - for (DIType *Op : Ts) - if (auto *T = dyn_cast_or_null(Op)) - if (auto *S = T->getRawIdentifier()) { - UnresolvedTypeRefs.erase(S); - TypeRefs.insert(std::make_pair(S, T)); - } + if (isa(CU)) + if (auto Ts = cast(CU)->getRetainedTypes()) + for (DIType *Op : Ts) + if (auto *T = dyn_cast_or_null(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 -- cgit v1.2.3