[llvm] r265514 - [IRVerifier] Avoid crashing on an invalid compile unit.

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 6 08:25:25 PDT 2016


On Tue, Apr 5, 2016 at 8:07 PM, Davide Italiano via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: davide
> Date: Tue Apr  5 22:07:58 2016
> New Revision: 265514
>
> URL: http://llvm.org/viewvc/llvm-project?rev=265514&view=rev
> Log:
> [IRVerifier] Avoid crashing on an invalid compile unit.
>
> Added:
>     llvm/trunk/test/Verifier/dbg-invalid-compileunit.ll
> Modified:
>     llvm/trunk/lib/IR/Verifier.cpp
>
> Modified: llvm/trunk/lib/IR/Verifier.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=265514&r1=265513&r2=265514&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/IR/Verifier.cpp (original)
> +++ llvm/trunk/lib/IR/Verifier.cpp Tue Apr  5 22:07:58 2016
> @@ -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))
>

Total aside. I assume something should be checking that there aren't any
null entries in the retained types list (or indeed any entries that aren't
composite types, either)


> +            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
>
> Added: llvm/trunk/test/Verifier/dbg-invalid-compileunit.ll
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/dbg-invalid-compileunit.ll?rev=265514&view=auto
>
> ==============================================================================
> --- llvm/trunk/test/Verifier/dbg-invalid-compileunit.ll (added)
> +++ llvm/trunk/test/Verifier/dbg-invalid-compileunit.ll Tue Apr  5
> 22:07:58 2016
> @@ -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: "")
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160406/3b1dcdad/attachment.html>


More information about the llvm-commits mailing list