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.
This commit is contained in:
David Blaikie 2025-01-17 19:42:21 +00:00
parent 9324e6a7a5
commit 42043c423f
4 changed files with 10 additions and 4 deletions

View File

@ -1319,6 +1319,8 @@ void Verifier::visitDICompositeType(const DICompositeType &N) {
unsigned DIBlockByRefStruct = 1 << 4; unsigned DIBlockByRefStruct = 1 << 4;
CheckDI((N.getFlags() & DIBlockByRefStruct) == 0, CheckDI((N.getFlags() & DIBlockByRefStruct) == 0,
"DIBlockByRefStruct on DICompositeType is no longer supported", &N); "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()) { if (N.isVector()) {
const DINodeArray Elements = N.getElements(); const DINodeArray Elements = N.getElements();

View File

@ -109,7 +109,7 @@ attributes #1 = { nofree nosync nounwind readnone speculatable willreturn }
!31 = !DISubroutineType(types: !32) !31 = !DISubroutineType(types: !32)
!32 = !{!33, !35} !32 = !{!33, !35}
!33 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "ADDR", baseType: !34, size: 64, align: 64) !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) !35 = !DIBasicType(name: "INTEGER", size: 64, encoding: DW_ATE_signed)
!36 = !DILocation(line: 23, scope: !30) !36 = !DILocation(line: 23, scope: !30)
!37 = !DILocalVariable(name: "mode", arg: 1, scope: !30, file: !2, line: 22, type: !35) !37 = !DILocalVariable(name: "mode", arg: 1, scope: !30, file: !2, line: 22, type: !35)

View File

@ -51,10 +51,8 @@ attributes #1 = { nounwind readnone }
!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
!1 = !DIGlobalVariable(name: "A", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true) !1 = !DIGlobalVariable(name: "A", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
!2 = !DIFile(filename: "test", directory: "/path/to/somewhere") !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) !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()) !7 = !DIGlobalVariableExpression(var: !8, expr: !DIExpression())
!8 = !DIGlobalVariable(name: "B", scope: null, file: !2, line: 2, type: !3, isLocal: false, isDefinition: true) !8 = !DIGlobalVariable(name: "B", scope: null, file: !2, line: 2, type: !3, isLocal: false, isDefinition: true)
!9 = !DIGlobalVariableExpression(var: !10, expr: !DIExpression()) !9 = !DIGlobalVariableExpression(var: !10, expr: !DIExpression())

View File

@ -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}