diff options
| -rw-r--r-- | llvm/lib/IR/Verifier.cpp | 15 | ||||
| -rw-r--r-- | llvm/test/Verifier/dbg-invalid-compileunit.ll | 8 | 
2 files changed, 16 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 diff --git a/llvm/test/Verifier/dbg-invalid-compileunit.ll b/llvm/test/Verifier/dbg-invalid-compileunit.ll new file mode 100644 index 00000000000..8f8a3d975f7 --- /dev/null +++ b/llvm/test/Verifier/dbg-invalid-compileunit.ll @@ -0,0 +1,8 @@ +; RUN: not llvm-as -disable-output <%s 2>&1 | FileCheck %s +; CHECK:      assembly parsed, but does not verify + +!llvm.module.flags = !{!0} +!llvm.dbg.cu = !{!1} + +!0 = !{i32 2, !"Debug Info Version", i32 3} +!1 = !DIFile(filename: "davide.f", directory: "")  | 

