[PATCH] D44262: [DebugInfo] Add verifier for DICompositeType vector

Matt Davis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 8 11:34:00 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL327048: [DebugInfo] Add verifier for DICompositeType vector (authored by mattd, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44262?vs=137605&id=137623#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44262

Files:
  llvm/trunk/lib/IR/Verifier.cpp
  llvm/trunk/test/Verifier/dbg-invalid-vector.ll


Index: llvm/trunk/lib/IR/Verifier.cpp
===================================================================
--- llvm/trunk/lib/IR/Verifier.cpp
+++ llvm/trunk/lib/IR/Verifier.cpp
@@ -959,6 +959,14 @@
            N.getRawVTableHolder());
   AssertDI(!hasConflictingReferenceFlags(N.getFlags()),
            "invalid reference flags", &N);
+
+  if (N.isVector()) {
+    const DINodeArray Elements = N.getElements();
+    AssertDI(Elements.size() == 1 &&
+             Elements[0]->getTag() == dwarf::DW_TAG_subrange_type,
+             "invalid vector, expected one element of type subrange", &N);
+  }
+
   if (auto *Params = N.getRawTemplateParams())
     visitTemplateParams(N, *Params);
 
Index: llvm/trunk/test/Verifier/dbg-invalid-vector.ll
===================================================================
--- llvm/trunk/test/Verifier/dbg-invalid-vector.ll
+++ llvm/trunk/test/Verifier/dbg-invalid-vector.ll
@@ -0,0 +1,36 @@
+; RUN: opt -verify -disable-output <%s 2>&1 | FileCheck %s
+;
+; This test creates an invalid vector by defining multiple elements for the
+; vector's DICompositeType definition.  A vector should only have one element
+; in its DICompositeType 'elements' array.
+;
+; CHECK: invalid vector
+
+ at f.foo = private unnamed_addr constant <6 x float> zeroinitializer, align 32
+
+define void @f() {
+  %1 = alloca <6 x float>, align 32
+  call void @llvm.dbg.declare(metadata <6 x float>* %1, metadata !10, metadata !DIExpression()), !dbg !18
+  ret void
+}
+
+declare void @llvm.dbg.declare(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
+!1 = !DIFile(filename: "test.c", directory: "/dbg/info")
+!2 = !{}
+!3 = !{i32 2, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!7 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 3, type: !8, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
+!8 = !DISubroutineType(types: !9)
+!9 = !{null}
+!10 = !DILocalVariable(name: "foo", scope: !7, file: !1, line: 4, type: !12)
+!12 = !DICompositeType(tag: DW_TAG_array_type, baseType: !13, size: 256, flags: DIFlagVector, elements: !14)
+!13 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float)
+!14 = !{!15, !19}
+!15 = !DISubrange(count: 6)
+!18 = !DILocation(line: 4, column: 48, scope: !7)
+!19 = !DISubrange(count: 42)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44262.137623.patch
Type: text/x-patch
Size: 2548 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180308/270ece11/attachment.bin>


More information about the llvm-commits mailing list