[llvm] 42043c4 - Reapply "Verifier: Add check for DICompositeType elements being null"

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 23 14:30:14 PST 2025


Author: David Blaikie
Date: 2025-01-23T22:29:30Z
New Revision: 42043c423ff01d8d07f33aed76819d3b716bba0c

URL: https://github.com/llvm/llvm-project/commit/42043c423ff01d8d07f33aed76819d3b716bba0c
DIFF: https://github.com/llvm/llvm-project/commit/42043c423ff01d8d07f33aed76819d3b716bba0c.diff

LOG: Reapply "Verifier: Add check for DICompositeType elements being null"

This remove some erroneous debug info from tests that should address the
test failures that showed up when the this was previously committed.

This reverts commit 6716ce8b641f0e42e2343e1694ee578b027be0c4.

Added: 
    llvm/test/Verifier/dicompositetype-elements-null.ll

Modified: 
    llvm/lib/IR/Verifier.cpp
    llvm/test/DebugInfo/X86/set.ll
    llvm/test/Transforms/LoopVectorize/dbg.value.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 7b6f7b5aa6171a..00280dbe5300b2 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -1319,6 +1319,8 @@ void Verifier::visitDICompositeType(const DICompositeType &N) {
   unsigned DIBlockByRefStruct = 1 << 4;
   CheckDI((N.getFlags() & DIBlockByRefStruct) == 0,
           "DIBlockByRefStruct on DICompositeType is no longer supported", &N);
+  CheckDI(llvm::all_of(N.getElements(), [](const DINode *N) { return N; }),
+          "DISubprogram contains null entry in `elements` field", &N);
 
   if (N.isVector()) {
     const DINodeArray Elements = N.getElements();

diff  --git a/llvm/test/DebugInfo/X86/set.ll b/llvm/test/DebugInfo/X86/set.ll
index 292c7c6e4a5773..85ad1af53d3e6d 100644
--- a/llvm/test/DebugInfo/X86/set.ll
+++ b/llvm/test/DebugInfo/X86/set.ll
@@ -109,7 +109,7 @@ attributes #1 = { nofree nosync nounwind readnone speculatable willreturn }
 !31 = !DISubroutineType(types: !32)
 !32 = !{!33, !35}
 !33 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "ADDR", baseType: !34, size: 64, align: 64)
-!34 = !DICompositeType(tag: DW_TAG_class_type, name: "ADDR__HeapObject", scope: !5, file: !2, line: 22, size: 64, align: 64, elements: !7, identifier: "AJWxb1")
+!34 = !DICompositeType(tag: DW_TAG_class_type, name: "ADDR__HeapObject", scope: !5, file: !2, line: 22, size: 64, align: 64, identifier: "AJWxb1")
 !35 = !DIBasicType(name: "INTEGER", size: 64, encoding: DW_ATE_signed)
 !36 = !DILocation(line: 23, scope: !30)
 !37 = !DILocalVariable(name: "mode", arg: 1, scope: !30, file: !2, line: 22, type: !35)

diff  --git a/llvm/test/Transforms/LoopVectorize/dbg.value.ll b/llvm/test/Transforms/LoopVectorize/dbg.value.ll
index 16d6f8bdde3063..19ef3ccf769a1d 100644
--- a/llvm/test/Transforms/LoopVectorize/dbg.value.ll
+++ b/llvm/test/Transforms/LoopVectorize/dbg.value.ll
@@ -51,10 +51,8 @@ attributes #1 = { nounwind readnone }
 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
 !1 = !DIGlobalVariable(name: "A", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
 !2 = !DIFile(filename: "test", directory: "/path/to/somewhere")
-!3 = !DICompositeType(tag: DW_TAG_array_type, baseType: !4, size: 32768, align: 32, elements: !5)
+!3 = !DICompositeType(tag: DW_TAG_array_type, baseType: !4, size: 32768, align: 32)
 !4 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
-!5 = !{!6}
-!6 = !{i32 786465, i64 0, i64 1024}
 !7 = !DIGlobalVariableExpression(var: !8, expr: !DIExpression())
 !8 = !DIGlobalVariable(name: "B", scope: null, file: !2, line: 2, type: !3, isLocal: false, isDefinition: true)
 !9 = !DIGlobalVariableExpression(var: !10, expr: !DIExpression())

diff  --git a/llvm/test/Verifier/dicompositetype-elements-null.ll b/llvm/test/Verifier/dicompositetype-elements-null.ll
new file mode 100644
index 00000000000000..c0aca47852bac0
--- /dev/null
+++ b/llvm/test/Verifier/dicompositetype-elements-null.ll
@@ -0,0 +1,6 @@
+; RUN: not opt -S < %s 2>&1 | FileCheck %s
+
+!named = !{!0}
+; CHECK: DISubprogram contains null entry in `elements` field
+!0 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t1", elements: !1)
+!1 = !{null}


        


More information about the llvm-commits mailing list