[llvm] r265752 - [IR/Verifier] Fix (yet another) crash.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 7 17:01:32 PDT 2016
Author: davide
Date: Thu Apr 7 19:01:32 2016
New Revision: 265752
URL: http://llvm.org/viewvc/llvm-project?rev=265752&view=rev
Log:
[IR/Verifier] Fix (yet another) crash.
We need to check that if we reference a retainedType from
DICompileUnit we're actually referencing a DICompositeType.
Added:
llvm/trunk/test/Verifier/dbg-invalid-retaintypes.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=265752&r1=265751&r2=265752&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Thu Apr 7 19:01:32 2016
@@ -4380,14 +4380,20 @@ void Verifier::verifyTypeRefs() {
// Visit all the compile units again to map the type references.
SmallDenseMap<const MDString *, const DIType *, 32> TypeRefs;
- for (auto *MD : CUs->operands())
- if (auto *CU = dyn_cast<DICompileUnit>(MD))
- for (DIType *Op : CU->getRetainedTypes())
- if (auto *T = dyn_cast_or_null<DICompositeType>(Op))
- if (auto *S = T->getRawIdentifier()) {
- UnresolvedTypeRefs.erase(S);
- TypeRefs.insert(std::make_pair(S, T));
- }
+ for (auto *MD : CUs->operands()) {
+ auto *CU = dyn_cast<DICompileUnit>(MD);
+ if (!CU)
+ continue;
+ auto *Array = CU->getRawRetainedTypes();
+ if (!Array || !isa<MDTuple>(Array))
+ continue;
+ for (DIType *Op : CU->getRetainedTypes())
+ 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
Added: llvm/trunk/test/Verifier/dbg-invalid-retaintypes.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/dbg-invalid-retaintypes.ll?rev=265752&view=auto
==============================================================================
--- llvm/trunk/test/Verifier/dbg-invalid-retaintypes.ll (added)
+++ llvm/trunk/test/Verifier/dbg-invalid-retaintypes.ll Thu Apr 7 19:01:32 2016
@@ -0,0 +1,10 @@
+; RUN: not llvm-as -disable-output <%s 2>&1 | FileCheck %s
+; CHECK: assembly parsed, but does not verify
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.0 (trunk 131941)", isOptimized: true, emissionKind: FullDebug, file: !2, retainedTypes: !1)
+!1 = distinct !DISubprogram(name: "main", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 1, scope: !2)
+!2 = !DIFile(filename: "/davide/test", directory: "/")
+!3 = !{i32 1, !"Debug Info Version", i32 3}
More information about the llvm-commits
mailing list