[llvm] r245795 - Verifier: Don't crash on null entries in debug info retained types list

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 22 15:36:41 PDT 2015


Author: dblaikie
Date: Sat Aug 22 17:36:40 2015
New Revision: 245795

URL: http://llvm.org/viewvc/llvm-project?rev=245795&view=rev
Log:
Verifier: Don't crash on null entries in debug info retained types list

There was already a good error path for this. Added a test for it & made
a minor code change to ensure the error path was actually reached,
rather than crashing before we got that far.

Added:
    llvm/trunk/test/Verifier/dbg-null-retained-type.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=245795&r1=245794&r2=245795&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Sat Aug 22 17:36:40 2015
@@ -3782,7 +3782,7 @@ void Verifier::verifyTypeRefs() {
   for (auto *CU : CUs->operands())
     if (auto Ts = cast<DICompileUnit>(CU)->getRetainedTypes())
       for (DIType *Op : Ts)
-        if (auto *T = dyn_cast<DICompositeType>(Op))
+        if (auto *T = dyn_cast_or_null<DICompositeType>(Op))
           if (auto *S = T->getRawIdentifier()) {
             UnresolvedTypeRefs.erase(S);
             TypeRefs.insert(std::make_pair(S, T));

Added: llvm/trunk/test/Verifier/dbg-null-retained-type.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/dbg-null-retained-type.ll?rev=245795&view=auto
==============================================================================
--- llvm/trunk/test/Verifier/dbg-null-retained-type.ll (added)
+++ llvm/trunk/test/Verifier/dbg-null-retained-type.ll Sat Aug 22 17:36:40 2015
@@ -0,0 +1,10 @@
+; RUN: not llvm-as -disable-output <%s 2>&1 | FileCheck %s
+; CHECK:      assembly parsed, but does not verify
+; CHECK-NEXT: invalid retained type
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 2, !"Debug Info Version", i32 3}
+!llvm.dbg.cu = !{!1}
+!1 = distinct !DICompileUnit(file: !2, language: DW_LANG_C99, retainedTypes: !3)
+!2 = !DIFile(filename: "file.c", directory: "/path/to/dir")
+!3 = !{null}




More information about the llvm-commits mailing list