[DebugInfo] Enforce DISubprogram type as required in LLParser#196299
Conversation
|
@llvm/pr-subscribers-mlir-llvm @llvm/pr-subscribers-backend-arm Author: Jiang Ning (JiangNingHX) ChangesAdd a parse-time check so that LLParser treats the Update existing hand-written LLVM IR tests to supply a minimal valid Scope. This patch covers the LLParser path only. Two entry points
Follow-up to #194556. Patch is 75.43 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/196299.diff 88 Files Affected:
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 820f64bf30ba7..dd11661e75f12 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -6201,7 +6201,7 @@ bool LLParser::parseDISubprogram(MDNode *&Result, bool IsDistinct) {
OPTIONAL(linkageName, MDStringField, ); \
OPTIONAL(file, MDField, ); \
OPTIONAL(line, LineField, ); \
- OPTIONAL(type, MDField, ); \
+ REQUIRED(type, MDField, (/* AllowNull */ false)); \
OPTIONAL(isLocal, MDBoolField, ); \
OPTIONAL(isDefinition, MDBoolField, (true)); \
OPTIONAL(scopeLine, LineField, ); \
diff --git a/llvm/test/Analysis/CostModel/X86/free-intrinsics.ll b/llvm/test/Analysis/CostModel/X86/free-intrinsics.ll
index cef960d3bcd30..773ef494a51b6 100644
--- a/llvm/test/Analysis/CostModel/X86/free-intrinsics.ll
+++ b/llvm/test/Analysis/CostModel/X86/free-intrinsics.ll
@@ -76,7 +76,7 @@ declare void @llvm.var.annotation(ptr, ptr, ptr, i32, ptr)
!llvm.module.flags = !{!7}
!0 = !DILocalVariable(scope: !1)
-!1 = distinct !DISubprogram(name: "dummy", line: 79, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, file: !3, unit: !9)
+!1 = distinct !DISubprogram(name: "dummy", line: 79, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, file: !3, unit: !9, type: !12)
!2 = !DILabel(scope: !1, name: "label", file: !3, line: 7)
!3 = !DIFile(filename: "debug-label.c", directory: "./")
!4 = !{ !5 }
@@ -86,3 +86,5 @@ declare void @llvm.var.annotation(ptr, ptr, ptr, i32, ptr)
!8 = !DILocation(line: 0, scope: !1)
!9 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "clang")
!10 = distinct !DIAssignID()
+!11 = !{null}
+!12 = !DISubroutineType(types: !11)
diff --git a/llvm/test/Analysis/CostModel/free-intrinsics-datalayout.ll b/llvm/test/Analysis/CostModel/free-intrinsics-datalayout.ll
index 2acc8e8cf4e20..f2117123ab8eb 100644
--- a/llvm/test/Analysis/CostModel/free-intrinsics-datalayout.ll
+++ b/llvm/test/Analysis/CostModel/free-intrinsics-datalayout.ll
@@ -84,7 +84,7 @@ declare void @llvm.var.annotation(ptr, ptr, ptr, i32, ptr)
!llvm.module.flags = !{!7}
!0 = !DILocalVariable(scope: !1)
-!1 = distinct !DISubprogram(name: "dummy", line: 79, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, file: !3, unit: !9)
+!1 = distinct !DISubprogram(name: "dummy", line: 79, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, file: !3, unit: !9, type: !12)
!2 = !DILabel(scope: !1, name: "label", file: !3, line: 7)
!3 = !DIFile(filename: "debug-label.c", directory: "./")
!4 = !{ !5 }
@@ -94,3 +94,5 @@ declare void @llvm.var.annotation(ptr, ptr, ptr, i32, ptr)
!8 = !DILocation(line: 0, scope: !1)
!9 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "clang")
!10 = distinct !DIAssignID()
+!11 = !{null}
+!12 = !DISubroutineType(types: !11)
diff --git a/llvm/test/Analysis/CostModel/free-intrinsics-no_info.ll b/llvm/test/Analysis/CostModel/free-intrinsics-no_info.ll
index 7f002d0ee88e4..e454f110e0ee3 100644
--- a/llvm/test/Analysis/CostModel/free-intrinsics-no_info.ll
+++ b/llvm/test/Analysis/CostModel/free-intrinsics-no_info.ll
@@ -82,7 +82,7 @@ declare void @llvm.var.annotation(ptr, ptr, ptr, i32, ptr)
!llvm.module.flags = !{!7}
!0 = !DILocalVariable(scope: !1)
-!1 = distinct !DISubprogram(name: "dummy", line: 79, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, file: !3, unit: !9)
+!1 = distinct !DISubprogram(name: "dummy", line: 79, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, file: !3, unit: !9, type: !12)
!2 = !DILabel(scope: !1, name: "label", file: !3, line: 7)
!3 = !DIFile(filename: "debug-label.c", directory: "./")
!4 = !{ !5 }
@@ -92,3 +92,5 @@ declare void @llvm.var.annotation(ptr, ptr, ptr, i32, ptr)
!8 = !DILocation(line: 0, scope: !1)
!9 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "clang")
!10 = distinct !DIAssignID()
+!11 = !{null}
+!12 = !DISubroutineType(types: !11)
diff --git a/llvm/test/Assembler/disubprogram-type-required.ll b/llvm/test/Assembler/disubprogram-type-required.ll
new file mode 100644
index 0000000000000..65fd19a364c8d
--- /dev/null
+++ b/llvm/test/Assembler/disubprogram-type-required.ll
@@ -0,0 +1,29 @@
+; Test that LLParser rejects DISubprogram with missing or null 'type' field.
+; These are parse-time errors, not verifier errors. See issue #186557.
+;
+; RUN: split-file %s %t
+; RUN: not llvm-as %t/missing.ll -disable-output 2>&1 | FileCheck %s --check-prefix=MISSING
+; RUN: not llvm-as %t/null.ll -disable-output 2>&1 | FileCheck %s --check-prefix=NULL
+;
+; MISSING: missing required field 'type'
+; NULL: 'type' cannot be null
+
+;--- missing.ll
+define void @f() !dbg !4 { ret void }
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3}
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, emissionKind: FullDebug)
+!1 = !DIFile(filename: "x.c", directory: "/")
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1,
+ scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0)
+
+;--- null.ll
+define void @f() !dbg !4 { ret void }
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3}
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, emissionKind: FullDebug)
+!1 = !DIFile(filename: "x.c", directory: "/")
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1,
+ scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, type: null)
diff --git a/llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll b/llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll
index c8b235757afba..7bb61601747b4 100644
--- a/llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll
+++ b/llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll
@@ -25,4 +25,6 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
!llvm.module.flags = !{!0}
!0 = !{i32 2, !"Debug Info Version", i32 3}
-!1 = distinct !DISubprogram(name: "foo")
+!1 = distinct !DISubprogram(name: "foo", type: !3)
+!2 = !{null}
+!3 = !DISubroutineType(types: !2)
diff --git a/llvm/test/Assembler/invalid-diflag-bad.ll b/llvm/test/Assembler/invalid-diflag-bad.ll
index cde59f6ce6674..0c5ec6e3a630a 100644
--- a/llvm/test/Assembler/invalid-diflag-bad.ll
+++ b/llvm/test/Assembler/invalid-diflag-bad.ll
@@ -1,4 +1,6 @@
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
; CHECK: <stdin>:[[@LINE+1]]:27: error: invalid debug info flag 'DIFlagUnknown'
-!0 = !DISubprogram(flags: DIFlagUnknown)
+!0 = !DISubprogram(flags: DIFlagUnknown, type: !2)
+!1 = !{null}
+!2 = !DISubroutineType(types: !1)
diff --git a/llvm/test/Assembler/invalid-disubprogram-uniqued-definition.ll b/llvm/test/Assembler/invalid-disubprogram-uniqued-definition.ll
index 6641e6dc21d72..2d406d5df2b1c 100644
--- a/llvm/test/Assembler/invalid-disubprogram-uniqued-definition.ll
+++ b/llvm/test/Assembler/invalid-disubprogram-uniqued-definition.ll
@@ -1,4 +1,6 @@
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
; CHECK: <stdin>:[[@LINE+1]]:6: error: missing 'distinct', required for !DISubprogram that is a Definition
-!0 = !DISubprogram(isDefinition: true)
+!0 = !DISubprogram(isDefinition: true, type: !2)
+!1 = !{null}
+!2 = !DISubroutineType(types: !1)
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/fconstant-dbg-loc.ll b/llvm/test/CodeGen/AArch64/GlobalISel/fconstant-dbg-loc.ll
index 6281c2f5c0a78..4661a0132afc0 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/fconstant-dbg-loc.ll
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/fconstant-dbg-loc.ll
@@ -21,5 +21,7 @@ define float @main() #0 !dbg !14 {
!11 = !{i32 1, !"wchar_size", i32 4}
!12 = !{i32 7, !"PIC Level", i32 2}
!13 = !{!"clang"}
-!14 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 3, scopeLine: 3, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !4)
+!14 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 3, scopeLine: 3, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !4, type: !26)
!24 = !DILocation(line: 7, column: 3, scope: !14)
+!25 = !{null}
+!26 = !DISubroutineType(types: !25)
diff --git a/llvm/test/CodeGen/AArch64/sdag-no-typesize-warnings-regandsizes.ll b/llvm/test/CodeGen/AArch64/sdag-no-typesize-warnings-regandsizes.ll
index 4fb816172b19d..e3ef90db8cde3 100644
--- a/llvm/test/CodeGen/AArch64/sdag-no-typesize-warnings-regandsizes.ll
+++ b/llvm/test/CodeGen/AArch64/sdag-no-typesize-warnings-regandsizes.ll
@@ -23,5 +23,7 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
!1 = !DIFile(filename: "file.c", directory: "/")
!2 = !{i32 2, !"Debug Info Version", i32 3}
!3 = !DILocalVariable(scope: !4)
-!4 = distinct !DISubprogram(unit: !0)
+!4 = distinct !DISubprogram(unit: !0, type: !7)
!5 = !DILocation(scope: !4)
+!6 = !{null}
+!7 = !DISubroutineType(types: !6)
diff --git a/llvm/test/CodeGen/AArch64/selectiondag-order.ll b/llvm/test/CodeGen/AArch64/selectiondag-order.ll
index fb40653723fec..46a7ae6521e45 100644
--- a/llvm/test/CodeGen/AArch64/selectiondag-order.ll
+++ b/llvm/test/CodeGen/AArch64/selectiondag-order.ll
@@ -90,7 +90,9 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata)
!2 = !DIFile(filename: "test.ll", directory: ".")
!3 = !{i32 2, !"Dwarf Version", i32 4}
!4 = !{i32 2, !"Debug Info Version", i32 3}
-!5 = distinct !DISubprogram(name: "simulateWithDebugIntrinsic", scope: !2, file: !2, line: 64, isLocal: false, isDefinition: true, scopeLine: 65, unit: !1)
+!5 = distinct !DISubprogram(name: "simulateWithDebugIntrinsic", scope: !2, file: !2, line: 64, isLocal: false, isDefinition: true, scopeLine: 65, unit: !1, type: !10)
!6 = !DILocalVariable(name: "randv", scope: !5, file: !2, line: 69)
!7 = !DIExpression()
!8 = !DILocation(line: 132, column: 2, scope: !5)
+!9 = !{null}
+!10 = !DISubroutineType(types: !9)
diff --git a/llvm/test/CodeGen/AMDGPU/simplify-libcalls2.ll b/llvm/test/CodeGen/AMDGPU/simplify-libcalls2.ll
index 692a73a9bc593..9edefe5ff53ff 100644
--- a/llvm/test/CodeGen/AMDGPU/simplify-libcalls2.ll
+++ b/llvm/test/CodeGen/AMDGPU/simplify-libcalls2.ll
@@ -20,5 +20,7 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !DIFile(filename: "1", directory: "1"))
!1 = !{i32 2, !"Debug Info Version", i32 3}
-!2 = distinct !DISubprogram(unit: !0)
+!2 = distinct !DISubprogram(unit: !0, type: !5)
!3 = !DILocation(line: 1, column: 1, scope: !2)
+!4 = !{null}
+!5 = !DISubroutineType(types: !4)
diff --git a/llvm/test/CodeGen/ARM/2009-10-16-Scope.ll b/llvm/test/CodeGen/ARM/2009-10-16-Scope.ll
index c01f3bf352b18..90a72db645fa5 100644
--- a/llvm/test/CodeGen/ARM/2009-10-16-Scope.ll
+++ b/llvm/test/CodeGen/ARM/2009-10-16-Scope.ll
@@ -25,7 +25,7 @@ declare i32 @foo(i32) ssp
!llvm.dbg.cu = !{!0}
!0 = !DILocation(line: 5, column: 2, scope: !1)
!1 = distinct !DILexicalBlock(line: 1, column: 1, file: null, scope: !2)
-!2 = distinct !DISubprogram(name: "bar", linkageName: "bar", line: 4, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !3, scope: !3)
+!2 = distinct !DISubprogram(name: "bar", linkageName: "bar", line: 4, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !3, scope: !3, type: !11)
!3 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang 1.1", isOptimized: true, emissionKind: FullDebug, file: !8, retainedTypes: !9)
!4 = !DILocalVariable(name: "count_", line: 5, scope: !5, file: !3, type: !6)
!5 = distinct !DILexicalBlock(line: 1, column: 1, file: null, scope: !1)
@@ -33,3 +33,5 @@ declare i32 @foo(i32) ssp
!7 = !DILocation(line: 6, column: 1, scope: !2)
!8 = !DIFile(filename: "genmodes.i", directory: "/Users/yash/Downloads")
!9 = !{i32 0}
+!10 = !{null}
+!11 = !DISubroutineType(types: !10)
diff --git a/llvm/test/CodeGen/ARM/analyze-branch-bkpt.ll b/llvm/test/CodeGen/ARM/analyze-branch-bkpt.ll
index cba89fe998700..d6a2f58589c32 100644
--- a/llvm/test/CodeGen/ARM/analyze-branch-bkpt.ll
+++ b/llvm/test/CodeGen/ARM/analyze-branch-bkpt.ll
@@ -50,12 +50,14 @@ attributes #1 = { nounwind }
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug)
!1 = !DIFile(filename: "a", directory: "")
!2 = !{i32 2, !"Debug Info Version", i32 3}
-!3 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0)
+!3 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, type: !13)
!4 = !DILocation(line: 0, scope: !5, inlinedAt: !6)
-!5 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0)
+!5 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, type: !13)
!6 = !DILocation(line: 0, scope: !3)
!7 = !DILocalVariable(scope: !8)
-!8 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0)
+!8 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, type: !13)
!9 = !DILocation(line: 0, scope: !8, inlinedAt: !6)
!10 = !DILocation(line: 0, scope: !11, inlinedAt: !6)
!11 = !DILexicalBlock(scope: !8)
+!12 = !{null}
+!13 = !DISubroutineType(types: !12)
diff --git a/llvm/test/CodeGen/Generic/dbg_value.ll b/llvm/test/CodeGen/Generic/dbg_value.ll
index a143801bf7eba..54870d51bb2e3 100644
--- a/llvm/test/CodeGen/Generic/dbg_value.ll
+++ b/llvm/test/CodeGen/Generic/dbg_value.ll
@@ -12,4 +12,6 @@ declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnon
; !0 should conform to the format of DIVariable.
!0 = !DILocalVariable(name: "a", arg: 1, scope: !1)
-!1 = distinct !DISubprogram()
+!1 = distinct !DISubprogram(type: !3)
+!2 = !{null}
+!3 = !DISubroutineType(types: !2)
diff --git a/llvm/test/CodeGen/MIR/X86/fixed-stack-di.mir b/llvm/test/CodeGen/MIR/X86/fixed-stack-di.mir
index fca249320bc82..6351b9bded8c8 100644
--- a/llvm/test/CodeGen/MIR/X86/fixed-stack-di.mir
+++ b/llvm/test/CodeGen/MIR/X86/fixed-stack-di.mir
@@ -23,8 +23,10 @@
!1 = !DIFile(filename: "file.cpp", directory: "/dir")
!2 = !{i32 2, !"Debug Info Version", i32 3}
!3 = !DILocalVariable(name: "dstRect", scope: !4)
- !4 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !0, file: !1, line: 42, unit: !0)
+ !4 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !0, file: !1, line: 42, unit: !0, type: !7)
!5 = !DILocation(line: 42, column: 85, scope: !4)
+ !6 = !{null}
+ !7 = !DISubroutineType(types: !6)
...
---
diff --git a/llvm/test/CodeGen/MIR/X86/invalid-metadata-node-type.mir b/llvm/test/CodeGen/MIR/X86/invalid-metadata-node-type.mir
index 1a83f891d1fa4..ec98834857f1f 100644
--- a/llvm/test/CodeGen/MIR/X86/invalid-metadata-node-type.mir
+++ b/llvm/test/CodeGen/MIR/X86/invalid-metadata-node-type.mir
@@ -27,10 +27,12 @@
!2 = !{}
!3 = !{i32 1, !"Debug Info Version", i32 3}
!4 = !DILocalVariable(name: "x", scope: !5, file: !1, line: 16, type: !6)
- !5 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0)
+ !5 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, type: !10)
!6 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)
!7 = !DIExpression()
!8 = !DILocation(line: 0, scope: !5)
+ !9 = !{null}
+ !10 = !DISubroutineType(types: !9)
...
---
name: foo
diff --git a/llvm/test/CodeGen/RISCV/rvv/get-vlen-debugloc.mir b/llvm/test/CodeGen/RISCV/rvv/get-vlen-debugloc.mir
index c493a6ca180aa..1d9b8b2d429be 100644
--- a/llvm/test/CodeGen/RISCV/rvv/get-vlen-debugloc.mir
+++ b/llvm/test/CodeGen/RISCV/rvv/get-vlen-debugloc.mir
@@ -11,9 +11,11 @@
ret void, !dbg !2
}
- !0 = distinct !DISubprogram(name: "foo", line: 3, scopeLine: 3)
+ !0 = distinct !DISubprogram(name: "foo", line: 3, scopeLine: 3, type: !4)
!1 = !DILocation(line: 4, column: 14, scope: !0)
!2 = !DILocation(line: 5, column: 3, scope: !0)
+ !3 = !{null}
+ !4 = !DISubroutineType(types: !3)
...
---
diff --git a/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll b/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
index 51dcf2fc7ec62..bb80e4886da5e 100644
--- a/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
+++ b/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
@@ -302,9 +302,11 @@ attributes #3 = { allocsize(0) }
!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = !DIFile(filename: "lower-em-sjlj.c", directory: "test")
!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1)
-!3 = distinct !DISubprogram(name: "setjmp_debug_info", unit:!2, file: !1, line: 1)
+!3 = distinct !DISubprogram(name: "setjmp_debug_info", unit:!2, file: !1, line: 1, type: !10)
!4 = !DILocation(line:2, scope: !3)
!5 = !DILocation(line:3, scope: !3)
!6 = !DILocation(line:4, scope: !3)
!7 = !DILocation(line:5, scope: !3)
!8 = !DILocation(line:6, scope: !3)
+!9 = !{null}
+!10 = !DISubroutineType(types: !9)
diff --git a/llvm/test/CodeGen/X86/2009-10-16-Scope.ll b/llvm/test/CodeGen/X86/2009-10-16-Scope.ll
index bb568713d5c6a..1e3356fcc08b3 100644
--- a/llvm/test/CodeGen/X86/2009-10-16-Scope.ll
+++ b/llvm/test/CodeGen/X86/2009-10-16-Scope.ll
@@ -25,7 +25,7 @@ declare i32 @foo(i32) ssp
!llvm.dbg.cu = !{!3}
!0 = !DILocation(line: 5, column: 2, scope: !1)
!1 = distinct !DILexicalBlock(line: 1, column: 1, file: null, scope: !2)
-!2 = distinct !DISubprogram(name: "bar", linkageName: "bar", line: 4, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !3, scope: !3)
+!2 = distinct !DISubprogram(name: "bar", linkageName: "bar", line: 4, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !3, scope: !3, type: !11)
!3 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang 1.1", isOptimized: true, emissionKind: FullDebug, file: !8, retainedTypes: !9)
!4 = !DILocalVariable(name: "count_", line: 5, scope: !5, file: !3, type: !6)
!5 = distinct !DILexicalBlock(line: 1, column: 1, file: null, scope: !1)
@@ -33,3 +33,5 @@ declare i32 @foo(i32) ssp
!7 = !DILocation(line: 6, column: 1, scope: !2)
!8 = !DIFile(filename: "genmodes.i", directory: "/Users/yash/Downloads")
!9 = !{i32 0}
+!10 = !{null}
+!11 = !DISubroutineType(types: !10)
diff --git a/llvm/test/CodeGen/X86/AMX/amx-ldtilecfg-insert.ll b/llvm/test/CodeGen/X86/AMX/amx-ldtilecfg-insert.ll
index 8a8e7a3b4df2c..972e507793799 100644
--- a/llvm/test/CodeGen/X86/AMX/amx-ldtilecfg-insert.ll
+++ b/llvm/test/CodeGen/X86/AMX/amx-ldtilecfg-insert.ll
@@ -366,5 +366,7 @@ declare void @llvm.x86.tilestored64.internal(i16, i16, ptr, i64, x86_amx)
!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !DIFile(filename: "1", directory: "1"))
!1 = !{i32 2, !"Debug Info Version", i32 3}
-!2 = distinct !DISubprogram(unit: !0)
+!2 = distinct !DISubprogram(unit: !0, type: !5)
!3 = !DILocation(line: 1, column: 1, scope: !2)
+!4 = !{null}
+!5 = !DISubroutineType(types: !4)
diff --git a/llvm/test/CodeGen/X86/GlobalISel/regbankselect-dbg-value-physreg-crash.mir b/llvm/test/CodeGen/X86/GlobalISel/regbankselect-dbg-value-physreg-crash.mir
index 79523b904ee9a..085fa2c55b645 100644
--- a/llvm/test/CodeGen/X86/GlobalISel/regbankselect-dbg-value-physreg-crash.mir
+++ b/llvm/test/CodeGen/X86/GlobalISel/regbankselect-dbg-value-physreg-crash.mir
@@ -11,8 +11,10 @@
ret void
}
- !0 = distinct !DISubprogram(name: "foo")
+ !0 = distinct !DISubprogram(name: "foo", type: !3)
!1 = !DILocation(line: 1, column: 1, scope: !0)
+ !2 = !{null}
+ !3 = !DISubroutineType(types: !2)
...
---
diff --git a/llvm/test/CodeGen/X86/StackColoring-dbg.ll b/llvm/test/CodeGen/X86/StackColoring-dbg.ll
index ccb1c3fdb27fe..c1b29a773adfb 100644
--- a/llvm/test/CodeGen/X86/StackColoring-dbg.ll
+++ b/llvm/test/CodeGen/X86...
[truncated]
|
|
@llvm/pr-subscribers-backend-amdgpu Author: Jiang Ning (JiangNingHX) ChangesAdd a parse-time check so that LLParser treats the Update existing hand-written LLVM IR tests to supply a minimal valid Scope. This patch covers the LLParser path only. Two entry points
Follow-up to #194556. Patch is 75.43 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/196299.diff 88 Files Affected:
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 820f64bf30ba7..dd11661e75f12 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -6201,7 +6201,7 @@ bool LLParser::parseDISubprogram(MDNode *&Result, bool IsDistinct) {
OPTIONAL(linkageName, MDStringField, ); \
OPTIONAL(file, MDField, ); \
OPTIONAL(line, LineField, ); \
- OPTIONAL(type, MDField, ); \
+ REQUIRED(type, MDField, (/* AllowNull */ false)); \
OPTIONAL(isLocal, MDBoolField, ); \
OPTIONAL(isDefinition, MDBoolField, (true)); \
OPTIONAL(scopeLine, LineField, ); \
diff --git a/llvm/test/Analysis/CostModel/X86/free-intrinsics.ll b/llvm/test/Analysis/CostModel/X86/free-intrinsics.ll
index cef960d3bcd30..773ef494a51b6 100644
--- a/llvm/test/Analysis/CostModel/X86/free-intrinsics.ll
+++ b/llvm/test/Analysis/CostModel/X86/free-intrinsics.ll
@@ -76,7 +76,7 @@ declare void @llvm.var.annotation(ptr, ptr, ptr, i32, ptr)
!llvm.module.flags = !{!7}
!0 = !DILocalVariable(scope: !1)
-!1 = distinct !DISubprogram(name: "dummy", line: 79, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, file: !3, unit: !9)
+!1 = distinct !DISubprogram(name: "dummy", line: 79, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, file: !3, unit: !9, type: !12)
!2 = !DILabel(scope: !1, name: "label", file: !3, line: 7)
!3 = !DIFile(filename: "debug-label.c", directory: "./")
!4 = !{ !5 }
@@ -86,3 +86,5 @@ declare void @llvm.var.annotation(ptr, ptr, ptr, i32, ptr)
!8 = !DILocation(line: 0, scope: !1)
!9 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "clang")
!10 = distinct !DIAssignID()
+!11 = !{null}
+!12 = !DISubroutineType(types: !11)
diff --git a/llvm/test/Analysis/CostModel/free-intrinsics-datalayout.ll b/llvm/test/Analysis/CostModel/free-intrinsics-datalayout.ll
index 2acc8e8cf4e20..f2117123ab8eb 100644
--- a/llvm/test/Analysis/CostModel/free-intrinsics-datalayout.ll
+++ b/llvm/test/Analysis/CostModel/free-intrinsics-datalayout.ll
@@ -84,7 +84,7 @@ declare void @llvm.var.annotation(ptr, ptr, ptr, i32, ptr)
!llvm.module.flags = !{!7}
!0 = !DILocalVariable(scope: !1)
-!1 = distinct !DISubprogram(name: "dummy", line: 79, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, file: !3, unit: !9)
+!1 = distinct !DISubprogram(name: "dummy", line: 79, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, file: !3, unit: !9, type: !12)
!2 = !DILabel(scope: !1, name: "label", file: !3, line: 7)
!3 = !DIFile(filename: "debug-label.c", directory: "./")
!4 = !{ !5 }
@@ -94,3 +94,5 @@ declare void @llvm.var.annotation(ptr, ptr, ptr, i32, ptr)
!8 = !DILocation(line: 0, scope: !1)
!9 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "clang")
!10 = distinct !DIAssignID()
+!11 = !{null}
+!12 = !DISubroutineType(types: !11)
diff --git a/llvm/test/Analysis/CostModel/free-intrinsics-no_info.ll b/llvm/test/Analysis/CostModel/free-intrinsics-no_info.ll
index 7f002d0ee88e4..e454f110e0ee3 100644
--- a/llvm/test/Analysis/CostModel/free-intrinsics-no_info.ll
+++ b/llvm/test/Analysis/CostModel/free-intrinsics-no_info.ll
@@ -82,7 +82,7 @@ declare void @llvm.var.annotation(ptr, ptr, ptr, i32, ptr)
!llvm.module.flags = !{!7}
!0 = !DILocalVariable(scope: !1)
-!1 = distinct !DISubprogram(name: "dummy", line: 79, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, file: !3, unit: !9)
+!1 = distinct !DISubprogram(name: "dummy", line: 79, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, file: !3, unit: !9, type: !12)
!2 = !DILabel(scope: !1, name: "label", file: !3, line: 7)
!3 = !DIFile(filename: "debug-label.c", directory: "./")
!4 = !{ !5 }
@@ -92,3 +92,5 @@ declare void @llvm.var.annotation(ptr, ptr, ptr, i32, ptr)
!8 = !DILocation(line: 0, scope: !1)
!9 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "clang")
!10 = distinct !DIAssignID()
+!11 = !{null}
+!12 = !DISubroutineType(types: !11)
diff --git a/llvm/test/Assembler/disubprogram-type-required.ll b/llvm/test/Assembler/disubprogram-type-required.ll
new file mode 100644
index 0000000000000..65fd19a364c8d
--- /dev/null
+++ b/llvm/test/Assembler/disubprogram-type-required.ll
@@ -0,0 +1,29 @@
+; Test that LLParser rejects DISubprogram with missing or null 'type' field.
+; These are parse-time errors, not verifier errors. See issue #186557.
+;
+; RUN: split-file %s %t
+; RUN: not llvm-as %t/missing.ll -disable-output 2>&1 | FileCheck %s --check-prefix=MISSING
+; RUN: not llvm-as %t/null.ll -disable-output 2>&1 | FileCheck %s --check-prefix=NULL
+;
+; MISSING: missing required field 'type'
+; NULL: 'type' cannot be null
+
+;--- missing.ll
+define void @f() !dbg !4 { ret void }
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3}
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, emissionKind: FullDebug)
+!1 = !DIFile(filename: "x.c", directory: "/")
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1,
+ scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0)
+
+;--- null.ll
+define void @f() !dbg !4 { ret void }
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3}
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, emissionKind: FullDebug)
+!1 = !DIFile(filename: "x.c", directory: "/")
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1,
+ scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, type: null)
diff --git a/llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll b/llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll
index c8b235757afba..7bb61601747b4 100644
--- a/llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll
+++ b/llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll
@@ -25,4 +25,6 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
!llvm.module.flags = !{!0}
!0 = !{i32 2, !"Debug Info Version", i32 3}
-!1 = distinct !DISubprogram(name: "foo")
+!1 = distinct !DISubprogram(name: "foo", type: !3)
+!2 = !{null}
+!3 = !DISubroutineType(types: !2)
diff --git a/llvm/test/Assembler/invalid-diflag-bad.ll b/llvm/test/Assembler/invalid-diflag-bad.ll
index cde59f6ce6674..0c5ec6e3a630a 100644
--- a/llvm/test/Assembler/invalid-diflag-bad.ll
+++ b/llvm/test/Assembler/invalid-diflag-bad.ll
@@ -1,4 +1,6 @@
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
; CHECK: <stdin>:[[@LINE+1]]:27: error: invalid debug info flag 'DIFlagUnknown'
-!0 = !DISubprogram(flags: DIFlagUnknown)
+!0 = !DISubprogram(flags: DIFlagUnknown, type: !2)
+!1 = !{null}
+!2 = !DISubroutineType(types: !1)
diff --git a/llvm/test/Assembler/invalid-disubprogram-uniqued-definition.ll b/llvm/test/Assembler/invalid-disubprogram-uniqued-definition.ll
index 6641e6dc21d72..2d406d5df2b1c 100644
--- a/llvm/test/Assembler/invalid-disubprogram-uniqued-definition.ll
+++ b/llvm/test/Assembler/invalid-disubprogram-uniqued-definition.ll
@@ -1,4 +1,6 @@
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
; CHECK: <stdin>:[[@LINE+1]]:6: error: missing 'distinct', required for !DISubprogram that is a Definition
-!0 = !DISubprogram(isDefinition: true)
+!0 = !DISubprogram(isDefinition: true, type: !2)
+!1 = !{null}
+!2 = !DISubroutineType(types: !1)
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/fconstant-dbg-loc.ll b/llvm/test/CodeGen/AArch64/GlobalISel/fconstant-dbg-loc.ll
index 6281c2f5c0a78..4661a0132afc0 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/fconstant-dbg-loc.ll
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/fconstant-dbg-loc.ll
@@ -21,5 +21,7 @@ define float @main() #0 !dbg !14 {
!11 = !{i32 1, !"wchar_size", i32 4}
!12 = !{i32 7, !"PIC Level", i32 2}
!13 = !{!"clang"}
-!14 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 3, scopeLine: 3, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !4)
+!14 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 3, scopeLine: 3, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !4, type: !26)
!24 = !DILocation(line: 7, column: 3, scope: !14)
+!25 = !{null}
+!26 = !DISubroutineType(types: !25)
diff --git a/llvm/test/CodeGen/AArch64/sdag-no-typesize-warnings-regandsizes.ll b/llvm/test/CodeGen/AArch64/sdag-no-typesize-warnings-regandsizes.ll
index 4fb816172b19d..e3ef90db8cde3 100644
--- a/llvm/test/CodeGen/AArch64/sdag-no-typesize-warnings-regandsizes.ll
+++ b/llvm/test/CodeGen/AArch64/sdag-no-typesize-warnings-regandsizes.ll
@@ -23,5 +23,7 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
!1 = !DIFile(filename: "file.c", directory: "/")
!2 = !{i32 2, !"Debug Info Version", i32 3}
!3 = !DILocalVariable(scope: !4)
-!4 = distinct !DISubprogram(unit: !0)
+!4 = distinct !DISubprogram(unit: !0, type: !7)
!5 = !DILocation(scope: !4)
+!6 = !{null}
+!7 = !DISubroutineType(types: !6)
diff --git a/llvm/test/CodeGen/AArch64/selectiondag-order.ll b/llvm/test/CodeGen/AArch64/selectiondag-order.ll
index fb40653723fec..46a7ae6521e45 100644
--- a/llvm/test/CodeGen/AArch64/selectiondag-order.ll
+++ b/llvm/test/CodeGen/AArch64/selectiondag-order.ll
@@ -90,7 +90,9 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata)
!2 = !DIFile(filename: "test.ll", directory: ".")
!3 = !{i32 2, !"Dwarf Version", i32 4}
!4 = !{i32 2, !"Debug Info Version", i32 3}
-!5 = distinct !DISubprogram(name: "simulateWithDebugIntrinsic", scope: !2, file: !2, line: 64, isLocal: false, isDefinition: true, scopeLine: 65, unit: !1)
+!5 = distinct !DISubprogram(name: "simulateWithDebugIntrinsic", scope: !2, file: !2, line: 64, isLocal: false, isDefinition: true, scopeLine: 65, unit: !1, type: !10)
!6 = !DILocalVariable(name: "randv", scope: !5, file: !2, line: 69)
!7 = !DIExpression()
!8 = !DILocation(line: 132, column: 2, scope: !5)
+!9 = !{null}
+!10 = !DISubroutineType(types: !9)
diff --git a/llvm/test/CodeGen/AMDGPU/simplify-libcalls2.ll b/llvm/test/CodeGen/AMDGPU/simplify-libcalls2.ll
index 692a73a9bc593..9edefe5ff53ff 100644
--- a/llvm/test/CodeGen/AMDGPU/simplify-libcalls2.ll
+++ b/llvm/test/CodeGen/AMDGPU/simplify-libcalls2.ll
@@ -20,5 +20,7 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !DIFile(filename: "1", directory: "1"))
!1 = !{i32 2, !"Debug Info Version", i32 3}
-!2 = distinct !DISubprogram(unit: !0)
+!2 = distinct !DISubprogram(unit: !0, type: !5)
!3 = !DILocation(line: 1, column: 1, scope: !2)
+!4 = !{null}
+!5 = !DISubroutineType(types: !4)
diff --git a/llvm/test/CodeGen/ARM/2009-10-16-Scope.ll b/llvm/test/CodeGen/ARM/2009-10-16-Scope.ll
index c01f3bf352b18..90a72db645fa5 100644
--- a/llvm/test/CodeGen/ARM/2009-10-16-Scope.ll
+++ b/llvm/test/CodeGen/ARM/2009-10-16-Scope.ll
@@ -25,7 +25,7 @@ declare i32 @foo(i32) ssp
!llvm.dbg.cu = !{!0}
!0 = !DILocation(line: 5, column: 2, scope: !1)
!1 = distinct !DILexicalBlock(line: 1, column: 1, file: null, scope: !2)
-!2 = distinct !DISubprogram(name: "bar", linkageName: "bar", line: 4, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !3, scope: !3)
+!2 = distinct !DISubprogram(name: "bar", linkageName: "bar", line: 4, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !3, scope: !3, type: !11)
!3 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang 1.1", isOptimized: true, emissionKind: FullDebug, file: !8, retainedTypes: !9)
!4 = !DILocalVariable(name: "count_", line: 5, scope: !5, file: !3, type: !6)
!5 = distinct !DILexicalBlock(line: 1, column: 1, file: null, scope: !1)
@@ -33,3 +33,5 @@ declare i32 @foo(i32) ssp
!7 = !DILocation(line: 6, column: 1, scope: !2)
!8 = !DIFile(filename: "genmodes.i", directory: "/Users/yash/Downloads")
!9 = !{i32 0}
+!10 = !{null}
+!11 = !DISubroutineType(types: !10)
diff --git a/llvm/test/CodeGen/ARM/analyze-branch-bkpt.ll b/llvm/test/CodeGen/ARM/analyze-branch-bkpt.ll
index cba89fe998700..d6a2f58589c32 100644
--- a/llvm/test/CodeGen/ARM/analyze-branch-bkpt.ll
+++ b/llvm/test/CodeGen/ARM/analyze-branch-bkpt.ll
@@ -50,12 +50,14 @@ attributes #1 = { nounwind }
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug)
!1 = !DIFile(filename: "a", directory: "")
!2 = !{i32 2, !"Debug Info Version", i32 3}
-!3 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0)
+!3 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, type: !13)
!4 = !DILocation(line: 0, scope: !5, inlinedAt: !6)
-!5 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0)
+!5 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, type: !13)
!6 = !DILocation(line: 0, scope: !3)
!7 = !DILocalVariable(scope: !8)
-!8 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0)
+!8 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, type: !13)
!9 = !DILocation(line: 0, scope: !8, inlinedAt: !6)
!10 = !DILocation(line: 0, scope: !11, inlinedAt: !6)
!11 = !DILexicalBlock(scope: !8)
+!12 = !{null}
+!13 = !DISubroutineType(types: !12)
diff --git a/llvm/test/CodeGen/Generic/dbg_value.ll b/llvm/test/CodeGen/Generic/dbg_value.ll
index a143801bf7eba..54870d51bb2e3 100644
--- a/llvm/test/CodeGen/Generic/dbg_value.ll
+++ b/llvm/test/CodeGen/Generic/dbg_value.ll
@@ -12,4 +12,6 @@ declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnon
; !0 should conform to the format of DIVariable.
!0 = !DILocalVariable(name: "a", arg: 1, scope: !1)
-!1 = distinct !DISubprogram()
+!1 = distinct !DISubprogram(type: !3)
+!2 = !{null}
+!3 = !DISubroutineType(types: !2)
diff --git a/llvm/test/CodeGen/MIR/X86/fixed-stack-di.mir b/llvm/test/CodeGen/MIR/X86/fixed-stack-di.mir
index fca249320bc82..6351b9bded8c8 100644
--- a/llvm/test/CodeGen/MIR/X86/fixed-stack-di.mir
+++ b/llvm/test/CodeGen/MIR/X86/fixed-stack-di.mir
@@ -23,8 +23,10 @@
!1 = !DIFile(filename: "file.cpp", directory: "/dir")
!2 = !{i32 2, !"Debug Info Version", i32 3}
!3 = !DILocalVariable(name: "dstRect", scope: !4)
- !4 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !0, file: !1, line: 42, unit: !0)
+ !4 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !0, file: !1, line: 42, unit: !0, type: !7)
!5 = !DILocation(line: 42, column: 85, scope: !4)
+ !6 = !{null}
+ !7 = !DISubroutineType(types: !6)
...
---
diff --git a/llvm/test/CodeGen/MIR/X86/invalid-metadata-node-type.mir b/llvm/test/CodeGen/MIR/X86/invalid-metadata-node-type.mir
index 1a83f891d1fa4..ec98834857f1f 100644
--- a/llvm/test/CodeGen/MIR/X86/invalid-metadata-node-type.mir
+++ b/llvm/test/CodeGen/MIR/X86/invalid-metadata-node-type.mir
@@ -27,10 +27,12 @@
!2 = !{}
!3 = !{i32 1, !"Debug Info Version", i32 3}
!4 = !DILocalVariable(name: "x", scope: !5, file: !1, line: 16, type: !6)
- !5 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0)
+ !5 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, type: !10)
!6 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)
!7 = !DIExpression()
!8 = !DILocation(line: 0, scope: !5)
+ !9 = !{null}
+ !10 = !DISubroutineType(types: !9)
...
---
name: foo
diff --git a/llvm/test/CodeGen/RISCV/rvv/get-vlen-debugloc.mir b/llvm/test/CodeGen/RISCV/rvv/get-vlen-debugloc.mir
index c493a6ca180aa..1d9b8b2d429be 100644
--- a/llvm/test/CodeGen/RISCV/rvv/get-vlen-debugloc.mir
+++ b/llvm/test/CodeGen/RISCV/rvv/get-vlen-debugloc.mir
@@ -11,9 +11,11 @@
ret void, !dbg !2
}
- !0 = distinct !DISubprogram(name: "foo", line: 3, scopeLine: 3)
+ !0 = distinct !DISubprogram(name: "foo", line: 3, scopeLine: 3, type: !4)
!1 = !DILocation(line: 4, column: 14, scope: !0)
!2 = !DILocation(line: 5, column: 3, scope: !0)
+ !3 = !{null}
+ !4 = !DISubroutineType(types: !3)
...
---
diff --git a/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll b/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
index 51dcf2fc7ec62..bb80e4886da5e 100644
--- a/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
+++ b/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
@@ -302,9 +302,11 @@ attributes #3 = { allocsize(0) }
!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = !DIFile(filename: "lower-em-sjlj.c", directory: "test")
!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1)
-!3 = distinct !DISubprogram(name: "setjmp_debug_info", unit:!2, file: !1, line: 1)
+!3 = distinct !DISubprogram(name: "setjmp_debug_info", unit:!2, file: !1, line: 1, type: !10)
!4 = !DILocation(line:2, scope: !3)
!5 = !DILocation(line:3, scope: !3)
!6 = !DILocation(line:4, scope: !3)
!7 = !DILocation(line:5, scope: !3)
!8 = !DILocation(line:6, scope: !3)
+!9 = !{null}
+!10 = !DISubroutineType(types: !9)
diff --git a/llvm/test/CodeGen/X86/2009-10-16-Scope.ll b/llvm/test/CodeGen/X86/2009-10-16-Scope.ll
index bb568713d5c6a..1e3356fcc08b3 100644
--- a/llvm/test/CodeGen/X86/2009-10-16-Scope.ll
+++ b/llvm/test/CodeGen/X86/2009-10-16-Scope.ll
@@ -25,7 +25,7 @@ declare i32 @foo(i32) ssp
!llvm.dbg.cu = !{!3}
!0 = !DILocation(line: 5, column: 2, scope: !1)
!1 = distinct !DILexicalBlock(line: 1, column: 1, file: null, scope: !2)
-!2 = distinct !DISubprogram(name: "bar", linkageName: "bar", line: 4, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !3, scope: !3)
+!2 = distinct !DISubprogram(name: "bar", linkageName: "bar", line: 4, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !3, scope: !3, type: !11)
!3 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang 1.1", isOptimized: true, emissionKind: FullDebug, file: !8, retainedTypes: !9)
!4 = !DILocalVariable(name: "count_", line: 5, scope: !5, file: !3, type: !6)
!5 = distinct !DILexicalBlock(line: 1, column: 1, file: null, scope: !1)
@@ -33,3 +33,5 @@ declare i32 @foo(i32) ssp
!7 = !DILocation(line: 6, column: 1, scope: !2)
!8 = !DIFile(filename: "genmodes.i", directory: "/Users/yash/Downloads")
!9 = !{i32 0}
+!10 = !{null}
+!11 = !DISubroutineType(types: !10)
diff --git a/llvm/test/CodeGen/X86/AMX/amx-ldtilecfg-insert.ll b/llvm/test/CodeGen/X86/AMX/amx-ldtilecfg-insert.ll
index 8a8e7a3b4df2c..972e507793799 100644
--- a/llvm/test/CodeGen/X86/AMX/amx-ldtilecfg-insert.ll
+++ b/llvm/test/CodeGen/X86/AMX/amx-ldtilecfg-insert.ll
@@ -366,5 +366,7 @@ declare void @llvm.x86.tilestored64.internal(i16, i16, ptr, i64, x86_amx)
!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !DIFile(filename: "1", directory: "1"))
!1 = !{i32 2, !"Debug Info Version", i32 3}
-!2 = distinct !DISubprogram(unit: !0)
+!2 = distinct !DISubprogram(unit: !0, type: !5)
!3 = !DILocation(line: 1, column: 1, scope: !2)
+!4 = !{null}
+!5 = !DISubroutineType(types: !4)
diff --git a/llvm/test/CodeGen/X86/GlobalISel/regbankselect-dbg-value-physreg-crash.mir b/llvm/test/CodeGen/X86/GlobalISel/regbankselect-dbg-value-physreg-crash.mir
index 79523b904ee9a..085fa2c55b645 100644
--- a/llvm/test/CodeGen/X86/GlobalISel/regbankselect-dbg-value-physreg-crash.mir
+++ b/llvm/test/CodeGen/X86/GlobalISel/regbankselect-dbg-value-physreg-crash.mir
@@ -11,8 +11,10 @@
ret void
}
- !0 = distinct !DISubprogram(name: "foo")
+ !0 = distinct !DISubprogram(name: "foo", type: !3)
!1 = !DILocation(line: 1, column: 1, scope: !0)
+ !2 = !{null}
+ !3 = !DISubroutineType(types: !2)
...
---
diff --git a/llvm/test/CodeGen/X86/StackColoring-dbg.ll b/llvm/test/CodeGen/X86/StackColoring-dbg.ll
index ccb1c3fdb27fe..c1b29a773adfb 100644
--- a/llvm/test/CodeGen/X86/StackColoring-dbg.ll
+++ b/llvm/test/CodeGen/X86...
[truncated]
|
|
@llvm/pr-subscribers-backend-x86 Author: Jiang Ning (JiangNingHX) ChangesAdd a parse-time check so that LLParser treats the Update existing hand-written LLVM IR tests to supply a minimal valid Scope. This patch covers the LLParser path only. Two entry points
Follow-up to #194556. Patch is 75.43 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/196299.diff 88 Files Affected:
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 820f64bf30ba7..dd11661e75f12 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -6201,7 +6201,7 @@ bool LLParser::parseDISubprogram(MDNode *&Result, bool IsDistinct) {
OPTIONAL(linkageName, MDStringField, ); \
OPTIONAL(file, MDField, ); \
OPTIONAL(line, LineField, ); \
- OPTIONAL(type, MDField, ); \
+ REQUIRED(type, MDField, (/* AllowNull */ false)); \
OPTIONAL(isLocal, MDBoolField, ); \
OPTIONAL(isDefinition, MDBoolField, (true)); \
OPTIONAL(scopeLine, LineField, ); \
diff --git a/llvm/test/Analysis/CostModel/X86/free-intrinsics.ll b/llvm/test/Analysis/CostModel/X86/free-intrinsics.ll
index cef960d3bcd30..773ef494a51b6 100644
--- a/llvm/test/Analysis/CostModel/X86/free-intrinsics.ll
+++ b/llvm/test/Analysis/CostModel/X86/free-intrinsics.ll
@@ -76,7 +76,7 @@ declare void @llvm.var.annotation(ptr, ptr, ptr, i32, ptr)
!llvm.module.flags = !{!7}
!0 = !DILocalVariable(scope: !1)
-!1 = distinct !DISubprogram(name: "dummy", line: 79, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, file: !3, unit: !9)
+!1 = distinct !DISubprogram(name: "dummy", line: 79, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, file: !3, unit: !9, type: !12)
!2 = !DILabel(scope: !1, name: "label", file: !3, line: 7)
!3 = !DIFile(filename: "debug-label.c", directory: "./")
!4 = !{ !5 }
@@ -86,3 +86,5 @@ declare void @llvm.var.annotation(ptr, ptr, ptr, i32, ptr)
!8 = !DILocation(line: 0, scope: !1)
!9 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "clang")
!10 = distinct !DIAssignID()
+!11 = !{null}
+!12 = !DISubroutineType(types: !11)
diff --git a/llvm/test/Analysis/CostModel/free-intrinsics-datalayout.ll b/llvm/test/Analysis/CostModel/free-intrinsics-datalayout.ll
index 2acc8e8cf4e20..f2117123ab8eb 100644
--- a/llvm/test/Analysis/CostModel/free-intrinsics-datalayout.ll
+++ b/llvm/test/Analysis/CostModel/free-intrinsics-datalayout.ll
@@ -84,7 +84,7 @@ declare void @llvm.var.annotation(ptr, ptr, ptr, i32, ptr)
!llvm.module.flags = !{!7}
!0 = !DILocalVariable(scope: !1)
-!1 = distinct !DISubprogram(name: "dummy", line: 79, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, file: !3, unit: !9)
+!1 = distinct !DISubprogram(name: "dummy", line: 79, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, file: !3, unit: !9, type: !12)
!2 = !DILabel(scope: !1, name: "label", file: !3, line: 7)
!3 = !DIFile(filename: "debug-label.c", directory: "./")
!4 = !{ !5 }
@@ -94,3 +94,5 @@ declare void @llvm.var.annotation(ptr, ptr, ptr, i32, ptr)
!8 = !DILocation(line: 0, scope: !1)
!9 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "clang")
!10 = distinct !DIAssignID()
+!11 = !{null}
+!12 = !DISubroutineType(types: !11)
diff --git a/llvm/test/Analysis/CostModel/free-intrinsics-no_info.ll b/llvm/test/Analysis/CostModel/free-intrinsics-no_info.ll
index 7f002d0ee88e4..e454f110e0ee3 100644
--- a/llvm/test/Analysis/CostModel/free-intrinsics-no_info.ll
+++ b/llvm/test/Analysis/CostModel/free-intrinsics-no_info.ll
@@ -82,7 +82,7 @@ declare void @llvm.var.annotation(ptr, ptr, ptr, i32, ptr)
!llvm.module.flags = !{!7}
!0 = !DILocalVariable(scope: !1)
-!1 = distinct !DISubprogram(name: "dummy", line: 79, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, file: !3, unit: !9)
+!1 = distinct !DISubprogram(name: "dummy", line: 79, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, file: !3, unit: !9, type: !12)
!2 = !DILabel(scope: !1, name: "label", file: !3, line: 7)
!3 = !DIFile(filename: "debug-label.c", directory: "./")
!4 = !{ !5 }
@@ -92,3 +92,5 @@ declare void @llvm.var.annotation(ptr, ptr, ptr, i32, ptr)
!8 = !DILocation(line: 0, scope: !1)
!9 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "clang")
!10 = distinct !DIAssignID()
+!11 = !{null}
+!12 = !DISubroutineType(types: !11)
diff --git a/llvm/test/Assembler/disubprogram-type-required.ll b/llvm/test/Assembler/disubprogram-type-required.ll
new file mode 100644
index 0000000000000..65fd19a364c8d
--- /dev/null
+++ b/llvm/test/Assembler/disubprogram-type-required.ll
@@ -0,0 +1,29 @@
+; Test that LLParser rejects DISubprogram with missing or null 'type' field.
+; These are parse-time errors, not verifier errors. See issue #186557.
+;
+; RUN: split-file %s %t
+; RUN: not llvm-as %t/missing.ll -disable-output 2>&1 | FileCheck %s --check-prefix=MISSING
+; RUN: not llvm-as %t/null.ll -disable-output 2>&1 | FileCheck %s --check-prefix=NULL
+;
+; MISSING: missing required field 'type'
+; NULL: 'type' cannot be null
+
+;--- missing.ll
+define void @f() !dbg !4 { ret void }
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3}
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, emissionKind: FullDebug)
+!1 = !DIFile(filename: "x.c", directory: "/")
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1,
+ scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0)
+
+;--- null.ll
+define void @f() !dbg !4 { ret void }
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3}
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, emissionKind: FullDebug)
+!1 = !DIFile(filename: "x.c", directory: "/")
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1,
+ scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, type: null)
diff --git a/llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll b/llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll
index c8b235757afba..7bb61601747b4 100644
--- a/llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll
+++ b/llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll
@@ -25,4 +25,6 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
!llvm.module.flags = !{!0}
!0 = !{i32 2, !"Debug Info Version", i32 3}
-!1 = distinct !DISubprogram(name: "foo")
+!1 = distinct !DISubprogram(name: "foo", type: !3)
+!2 = !{null}
+!3 = !DISubroutineType(types: !2)
diff --git a/llvm/test/Assembler/invalid-diflag-bad.ll b/llvm/test/Assembler/invalid-diflag-bad.ll
index cde59f6ce6674..0c5ec6e3a630a 100644
--- a/llvm/test/Assembler/invalid-diflag-bad.ll
+++ b/llvm/test/Assembler/invalid-diflag-bad.ll
@@ -1,4 +1,6 @@
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
; CHECK: <stdin>:[[@LINE+1]]:27: error: invalid debug info flag 'DIFlagUnknown'
-!0 = !DISubprogram(flags: DIFlagUnknown)
+!0 = !DISubprogram(flags: DIFlagUnknown, type: !2)
+!1 = !{null}
+!2 = !DISubroutineType(types: !1)
diff --git a/llvm/test/Assembler/invalid-disubprogram-uniqued-definition.ll b/llvm/test/Assembler/invalid-disubprogram-uniqued-definition.ll
index 6641e6dc21d72..2d406d5df2b1c 100644
--- a/llvm/test/Assembler/invalid-disubprogram-uniqued-definition.ll
+++ b/llvm/test/Assembler/invalid-disubprogram-uniqued-definition.ll
@@ -1,4 +1,6 @@
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
; CHECK: <stdin>:[[@LINE+1]]:6: error: missing 'distinct', required for !DISubprogram that is a Definition
-!0 = !DISubprogram(isDefinition: true)
+!0 = !DISubprogram(isDefinition: true, type: !2)
+!1 = !{null}
+!2 = !DISubroutineType(types: !1)
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/fconstant-dbg-loc.ll b/llvm/test/CodeGen/AArch64/GlobalISel/fconstant-dbg-loc.ll
index 6281c2f5c0a78..4661a0132afc0 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/fconstant-dbg-loc.ll
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/fconstant-dbg-loc.ll
@@ -21,5 +21,7 @@ define float @main() #0 !dbg !14 {
!11 = !{i32 1, !"wchar_size", i32 4}
!12 = !{i32 7, !"PIC Level", i32 2}
!13 = !{!"clang"}
-!14 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 3, scopeLine: 3, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !4)
+!14 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 3, scopeLine: 3, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !4, type: !26)
!24 = !DILocation(line: 7, column: 3, scope: !14)
+!25 = !{null}
+!26 = !DISubroutineType(types: !25)
diff --git a/llvm/test/CodeGen/AArch64/sdag-no-typesize-warnings-regandsizes.ll b/llvm/test/CodeGen/AArch64/sdag-no-typesize-warnings-regandsizes.ll
index 4fb816172b19d..e3ef90db8cde3 100644
--- a/llvm/test/CodeGen/AArch64/sdag-no-typesize-warnings-regandsizes.ll
+++ b/llvm/test/CodeGen/AArch64/sdag-no-typesize-warnings-regandsizes.ll
@@ -23,5 +23,7 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
!1 = !DIFile(filename: "file.c", directory: "/")
!2 = !{i32 2, !"Debug Info Version", i32 3}
!3 = !DILocalVariable(scope: !4)
-!4 = distinct !DISubprogram(unit: !0)
+!4 = distinct !DISubprogram(unit: !0, type: !7)
!5 = !DILocation(scope: !4)
+!6 = !{null}
+!7 = !DISubroutineType(types: !6)
diff --git a/llvm/test/CodeGen/AArch64/selectiondag-order.ll b/llvm/test/CodeGen/AArch64/selectiondag-order.ll
index fb40653723fec..46a7ae6521e45 100644
--- a/llvm/test/CodeGen/AArch64/selectiondag-order.ll
+++ b/llvm/test/CodeGen/AArch64/selectiondag-order.ll
@@ -90,7 +90,9 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata)
!2 = !DIFile(filename: "test.ll", directory: ".")
!3 = !{i32 2, !"Dwarf Version", i32 4}
!4 = !{i32 2, !"Debug Info Version", i32 3}
-!5 = distinct !DISubprogram(name: "simulateWithDebugIntrinsic", scope: !2, file: !2, line: 64, isLocal: false, isDefinition: true, scopeLine: 65, unit: !1)
+!5 = distinct !DISubprogram(name: "simulateWithDebugIntrinsic", scope: !2, file: !2, line: 64, isLocal: false, isDefinition: true, scopeLine: 65, unit: !1, type: !10)
!6 = !DILocalVariable(name: "randv", scope: !5, file: !2, line: 69)
!7 = !DIExpression()
!8 = !DILocation(line: 132, column: 2, scope: !5)
+!9 = !{null}
+!10 = !DISubroutineType(types: !9)
diff --git a/llvm/test/CodeGen/AMDGPU/simplify-libcalls2.ll b/llvm/test/CodeGen/AMDGPU/simplify-libcalls2.ll
index 692a73a9bc593..9edefe5ff53ff 100644
--- a/llvm/test/CodeGen/AMDGPU/simplify-libcalls2.ll
+++ b/llvm/test/CodeGen/AMDGPU/simplify-libcalls2.ll
@@ -20,5 +20,7 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !DIFile(filename: "1", directory: "1"))
!1 = !{i32 2, !"Debug Info Version", i32 3}
-!2 = distinct !DISubprogram(unit: !0)
+!2 = distinct !DISubprogram(unit: !0, type: !5)
!3 = !DILocation(line: 1, column: 1, scope: !2)
+!4 = !{null}
+!5 = !DISubroutineType(types: !4)
diff --git a/llvm/test/CodeGen/ARM/2009-10-16-Scope.ll b/llvm/test/CodeGen/ARM/2009-10-16-Scope.ll
index c01f3bf352b18..90a72db645fa5 100644
--- a/llvm/test/CodeGen/ARM/2009-10-16-Scope.ll
+++ b/llvm/test/CodeGen/ARM/2009-10-16-Scope.ll
@@ -25,7 +25,7 @@ declare i32 @foo(i32) ssp
!llvm.dbg.cu = !{!0}
!0 = !DILocation(line: 5, column: 2, scope: !1)
!1 = distinct !DILexicalBlock(line: 1, column: 1, file: null, scope: !2)
-!2 = distinct !DISubprogram(name: "bar", linkageName: "bar", line: 4, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !3, scope: !3)
+!2 = distinct !DISubprogram(name: "bar", linkageName: "bar", line: 4, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !3, scope: !3, type: !11)
!3 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang 1.1", isOptimized: true, emissionKind: FullDebug, file: !8, retainedTypes: !9)
!4 = !DILocalVariable(name: "count_", line: 5, scope: !5, file: !3, type: !6)
!5 = distinct !DILexicalBlock(line: 1, column: 1, file: null, scope: !1)
@@ -33,3 +33,5 @@ declare i32 @foo(i32) ssp
!7 = !DILocation(line: 6, column: 1, scope: !2)
!8 = !DIFile(filename: "genmodes.i", directory: "/Users/yash/Downloads")
!9 = !{i32 0}
+!10 = !{null}
+!11 = !DISubroutineType(types: !10)
diff --git a/llvm/test/CodeGen/ARM/analyze-branch-bkpt.ll b/llvm/test/CodeGen/ARM/analyze-branch-bkpt.ll
index cba89fe998700..d6a2f58589c32 100644
--- a/llvm/test/CodeGen/ARM/analyze-branch-bkpt.ll
+++ b/llvm/test/CodeGen/ARM/analyze-branch-bkpt.ll
@@ -50,12 +50,14 @@ attributes #1 = { nounwind }
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug)
!1 = !DIFile(filename: "a", directory: "")
!2 = !{i32 2, !"Debug Info Version", i32 3}
-!3 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0)
+!3 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, type: !13)
!4 = !DILocation(line: 0, scope: !5, inlinedAt: !6)
-!5 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0)
+!5 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, type: !13)
!6 = !DILocation(line: 0, scope: !3)
!7 = !DILocalVariable(scope: !8)
-!8 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0)
+!8 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, type: !13)
!9 = !DILocation(line: 0, scope: !8, inlinedAt: !6)
!10 = !DILocation(line: 0, scope: !11, inlinedAt: !6)
!11 = !DILexicalBlock(scope: !8)
+!12 = !{null}
+!13 = !DISubroutineType(types: !12)
diff --git a/llvm/test/CodeGen/Generic/dbg_value.ll b/llvm/test/CodeGen/Generic/dbg_value.ll
index a143801bf7eba..54870d51bb2e3 100644
--- a/llvm/test/CodeGen/Generic/dbg_value.ll
+++ b/llvm/test/CodeGen/Generic/dbg_value.ll
@@ -12,4 +12,6 @@ declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnon
; !0 should conform to the format of DIVariable.
!0 = !DILocalVariable(name: "a", arg: 1, scope: !1)
-!1 = distinct !DISubprogram()
+!1 = distinct !DISubprogram(type: !3)
+!2 = !{null}
+!3 = !DISubroutineType(types: !2)
diff --git a/llvm/test/CodeGen/MIR/X86/fixed-stack-di.mir b/llvm/test/CodeGen/MIR/X86/fixed-stack-di.mir
index fca249320bc82..6351b9bded8c8 100644
--- a/llvm/test/CodeGen/MIR/X86/fixed-stack-di.mir
+++ b/llvm/test/CodeGen/MIR/X86/fixed-stack-di.mir
@@ -23,8 +23,10 @@
!1 = !DIFile(filename: "file.cpp", directory: "/dir")
!2 = !{i32 2, !"Debug Info Version", i32 3}
!3 = !DILocalVariable(name: "dstRect", scope: !4)
- !4 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !0, file: !1, line: 42, unit: !0)
+ !4 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !0, file: !1, line: 42, unit: !0, type: !7)
!5 = !DILocation(line: 42, column: 85, scope: !4)
+ !6 = !{null}
+ !7 = !DISubroutineType(types: !6)
...
---
diff --git a/llvm/test/CodeGen/MIR/X86/invalid-metadata-node-type.mir b/llvm/test/CodeGen/MIR/X86/invalid-metadata-node-type.mir
index 1a83f891d1fa4..ec98834857f1f 100644
--- a/llvm/test/CodeGen/MIR/X86/invalid-metadata-node-type.mir
+++ b/llvm/test/CodeGen/MIR/X86/invalid-metadata-node-type.mir
@@ -27,10 +27,12 @@
!2 = !{}
!3 = !{i32 1, !"Debug Info Version", i32 3}
!4 = !DILocalVariable(name: "x", scope: !5, file: !1, line: 16, type: !6)
- !5 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0)
+ !5 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, type: !10)
!6 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)
!7 = !DIExpression()
!8 = !DILocation(line: 0, scope: !5)
+ !9 = !{null}
+ !10 = !DISubroutineType(types: !9)
...
---
name: foo
diff --git a/llvm/test/CodeGen/RISCV/rvv/get-vlen-debugloc.mir b/llvm/test/CodeGen/RISCV/rvv/get-vlen-debugloc.mir
index c493a6ca180aa..1d9b8b2d429be 100644
--- a/llvm/test/CodeGen/RISCV/rvv/get-vlen-debugloc.mir
+++ b/llvm/test/CodeGen/RISCV/rvv/get-vlen-debugloc.mir
@@ -11,9 +11,11 @@
ret void, !dbg !2
}
- !0 = distinct !DISubprogram(name: "foo", line: 3, scopeLine: 3)
+ !0 = distinct !DISubprogram(name: "foo", line: 3, scopeLine: 3, type: !4)
!1 = !DILocation(line: 4, column: 14, scope: !0)
!2 = !DILocation(line: 5, column: 3, scope: !0)
+ !3 = !{null}
+ !4 = !DISubroutineType(types: !3)
...
---
diff --git a/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll b/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
index 51dcf2fc7ec62..bb80e4886da5e 100644
--- a/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
+++ b/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
@@ -302,9 +302,11 @@ attributes #3 = { allocsize(0) }
!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = !DIFile(filename: "lower-em-sjlj.c", directory: "test")
!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1)
-!3 = distinct !DISubprogram(name: "setjmp_debug_info", unit:!2, file: !1, line: 1)
+!3 = distinct !DISubprogram(name: "setjmp_debug_info", unit:!2, file: !1, line: 1, type: !10)
!4 = !DILocation(line:2, scope: !3)
!5 = !DILocation(line:3, scope: !3)
!6 = !DILocation(line:4, scope: !3)
!7 = !DILocation(line:5, scope: !3)
!8 = !DILocation(line:6, scope: !3)
+!9 = !{null}
+!10 = !DISubroutineType(types: !9)
diff --git a/llvm/test/CodeGen/X86/2009-10-16-Scope.ll b/llvm/test/CodeGen/X86/2009-10-16-Scope.ll
index bb568713d5c6a..1e3356fcc08b3 100644
--- a/llvm/test/CodeGen/X86/2009-10-16-Scope.ll
+++ b/llvm/test/CodeGen/X86/2009-10-16-Scope.ll
@@ -25,7 +25,7 @@ declare i32 @foo(i32) ssp
!llvm.dbg.cu = !{!3}
!0 = !DILocation(line: 5, column: 2, scope: !1)
!1 = distinct !DILexicalBlock(line: 1, column: 1, file: null, scope: !2)
-!2 = distinct !DISubprogram(name: "bar", linkageName: "bar", line: 4, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !3, scope: !3)
+!2 = distinct !DISubprogram(name: "bar", linkageName: "bar", line: 4, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !3, scope: !3, type: !11)
!3 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang 1.1", isOptimized: true, emissionKind: FullDebug, file: !8, retainedTypes: !9)
!4 = !DILocalVariable(name: "count_", line: 5, scope: !5, file: !3, type: !6)
!5 = distinct !DILexicalBlock(line: 1, column: 1, file: null, scope: !1)
@@ -33,3 +33,5 @@ declare i32 @foo(i32) ssp
!7 = !DILocation(line: 6, column: 1, scope: !2)
!8 = !DIFile(filename: "genmodes.i", directory: "/Users/yash/Downloads")
!9 = !{i32 0}
+!10 = !{null}
+!11 = !DISubroutineType(types: !10)
diff --git a/llvm/test/CodeGen/X86/AMX/amx-ldtilecfg-insert.ll b/llvm/test/CodeGen/X86/AMX/amx-ldtilecfg-insert.ll
index 8a8e7a3b4df2c..972e507793799 100644
--- a/llvm/test/CodeGen/X86/AMX/amx-ldtilecfg-insert.ll
+++ b/llvm/test/CodeGen/X86/AMX/amx-ldtilecfg-insert.ll
@@ -366,5 +366,7 @@ declare void @llvm.x86.tilestored64.internal(i16, i16, ptr, i64, x86_amx)
!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !DIFile(filename: "1", directory: "1"))
!1 = !{i32 2, !"Debug Info Version", i32 3}
-!2 = distinct !DISubprogram(unit: !0)
+!2 = distinct !DISubprogram(unit: !0, type: !5)
!3 = !DILocation(line: 1, column: 1, scope: !2)
+!4 = !{null}
+!5 = !DISubroutineType(types: !4)
diff --git a/llvm/test/CodeGen/X86/GlobalISel/regbankselect-dbg-value-physreg-crash.mir b/llvm/test/CodeGen/X86/GlobalISel/regbankselect-dbg-value-physreg-crash.mir
index 79523b904ee9a..085fa2c55b645 100644
--- a/llvm/test/CodeGen/X86/GlobalISel/regbankselect-dbg-value-physreg-crash.mir
+++ b/llvm/test/CodeGen/X86/GlobalISel/regbankselect-dbg-value-physreg-crash.mir
@@ -11,8 +11,10 @@
ret void
}
- !0 = distinct !DISubprogram(name: "foo")
+ !0 = distinct !DISubprogram(name: "foo", type: !3)
!1 = !DILocation(line: 1, column: 1, scope: !0)
+ !2 = !{null}
+ !3 = !DISubroutineType(types: !2)
...
---
diff --git a/llvm/test/CodeGen/X86/StackColoring-dbg.ll b/llvm/test/CodeGen/X86/StackColoring-dbg.ll
index ccb1c3fdb27fe..c1b29a773adfb 100644
--- a/llvm/test/CodeGen/X86/StackColoring-dbg.ll
+++ b/llvm/test/CodeGen/X86...
[truncated]
|
|
@llvm/pr-subscribers-lto Author: Jiang Ning (JiangNingHX) ChangesAdd a parse-time check so that LLParser treats the Update existing hand-written LLVM IR tests to supply a minimal valid Scope. This patch covers the LLParser path only. Two entry points
Follow-up to #194556. Patch is 75.43 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/196299.diff 88 Files Affected:
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 820f64bf30ba7..dd11661e75f12 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -6201,7 +6201,7 @@ bool LLParser::parseDISubprogram(MDNode *&Result, bool IsDistinct) {
OPTIONAL(linkageName, MDStringField, ); \
OPTIONAL(file, MDField, ); \
OPTIONAL(line, LineField, ); \
- OPTIONAL(type, MDField, ); \
+ REQUIRED(type, MDField, (/* AllowNull */ false)); \
OPTIONAL(isLocal, MDBoolField, ); \
OPTIONAL(isDefinition, MDBoolField, (true)); \
OPTIONAL(scopeLine, LineField, ); \
diff --git a/llvm/test/Analysis/CostModel/X86/free-intrinsics.ll b/llvm/test/Analysis/CostModel/X86/free-intrinsics.ll
index cef960d3bcd30..773ef494a51b6 100644
--- a/llvm/test/Analysis/CostModel/X86/free-intrinsics.ll
+++ b/llvm/test/Analysis/CostModel/X86/free-intrinsics.ll
@@ -76,7 +76,7 @@ declare void @llvm.var.annotation(ptr, ptr, ptr, i32, ptr)
!llvm.module.flags = !{!7}
!0 = !DILocalVariable(scope: !1)
-!1 = distinct !DISubprogram(name: "dummy", line: 79, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, file: !3, unit: !9)
+!1 = distinct !DISubprogram(name: "dummy", line: 79, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, file: !3, unit: !9, type: !12)
!2 = !DILabel(scope: !1, name: "label", file: !3, line: 7)
!3 = !DIFile(filename: "debug-label.c", directory: "./")
!4 = !{ !5 }
@@ -86,3 +86,5 @@ declare void @llvm.var.annotation(ptr, ptr, ptr, i32, ptr)
!8 = !DILocation(line: 0, scope: !1)
!9 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "clang")
!10 = distinct !DIAssignID()
+!11 = !{null}
+!12 = !DISubroutineType(types: !11)
diff --git a/llvm/test/Analysis/CostModel/free-intrinsics-datalayout.ll b/llvm/test/Analysis/CostModel/free-intrinsics-datalayout.ll
index 2acc8e8cf4e20..f2117123ab8eb 100644
--- a/llvm/test/Analysis/CostModel/free-intrinsics-datalayout.ll
+++ b/llvm/test/Analysis/CostModel/free-intrinsics-datalayout.ll
@@ -84,7 +84,7 @@ declare void @llvm.var.annotation(ptr, ptr, ptr, i32, ptr)
!llvm.module.flags = !{!7}
!0 = !DILocalVariable(scope: !1)
-!1 = distinct !DISubprogram(name: "dummy", line: 79, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, file: !3, unit: !9)
+!1 = distinct !DISubprogram(name: "dummy", line: 79, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, file: !3, unit: !9, type: !12)
!2 = !DILabel(scope: !1, name: "label", file: !3, line: 7)
!3 = !DIFile(filename: "debug-label.c", directory: "./")
!4 = !{ !5 }
@@ -94,3 +94,5 @@ declare void @llvm.var.annotation(ptr, ptr, ptr, i32, ptr)
!8 = !DILocation(line: 0, scope: !1)
!9 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "clang")
!10 = distinct !DIAssignID()
+!11 = !{null}
+!12 = !DISubroutineType(types: !11)
diff --git a/llvm/test/Analysis/CostModel/free-intrinsics-no_info.ll b/llvm/test/Analysis/CostModel/free-intrinsics-no_info.ll
index 7f002d0ee88e4..e454f110e0ee3 100644
--- a/llvm/test/Analysis/CostModel/free-intrinsics-no_info.ll
+++ b/llvm/test/Analysis/CostModel/free-intrinsics-no_info.ll
@@ -82,7 +82,7 @@ declare void @llvm.var.annotation(ptr, ptr, ptr, i32, ptr)
!llvm.module.flags = !{!7}
!0 = !DILocalVariable(scope: !1)
-!1 = distinct !DISubprogram(name: "dummy", line: 79, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, file: !3, unit: !9)
+!1 = distinct !DISubprogram(name: "dummy", line: 79, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, file: !3, unit: !9, type: !12)
!2 = !DILabel(scope: !1, name: "label", file: !3, line: 7)
!3 = !DIFile(filename: "debug-label.c", directory: "./")
!4 = !{ !5 }
@@ -92,3 +92,5 @@ declare void @llvm.var.annotation(ptr, ptr, ptr, i32, ptr)
!8 = !DILocation(line: 0, scope: !1)
!9 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "clang")
!10 = distinct !DIAssignID()
+!11 = !{null}
+!12 = !DISubroutineType(types: !11)
diff --git a/llvm/test/Assembler/disubprogram-type-required.ll b/llvm/test/Assembler/disubprogram-type-required.ll
new file mode 100644
index 0000000000000..65fd19a364c8d
--- /dev/null
+++ b/llvm/test/Assembler/disubprogram-type-required.ll
@@ -0,0 +1,29 @@
+; Test that LLParser rejects DISubprogram with missing or null 'type' field.
+; These are parse-time errors, not verifier errors. See issue #186557.
+;
+; RUN: split-file %s %t
+; RUN: not llvm-as %t/missing.ll -disable-output 2>&1 | FileCheck %s --check-prefix=MISSING
+; RUN: not llvm-as %t/null.ll -disable-output 2>&1 | FileCheck %s --check-prefix=NULL
+;
+; MISSING: missing required field 'type'
+; NULL: 'type' cannot be null
+
+;--- missing.ll
+define void @f() !dbg !4 { ret void }
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3}
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, emissionKind: FullDebug)
+!1 = !DIFile(filename: "x.c", directory: "/")
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1,
+ scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0)
+
+;--- null.ll
+define void @f() !dbg !4 { ret void }
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3}
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, emissionKind: FullDebug)
+!1 = !DIFile(filename: "x.c", directory: "/")
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1,
+ scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, type: null)
diff --git a/llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll b/llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll
index c8b235757afba..7bb61601747b4 100644
--- a/llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll
+++ b/llvm/test/Assembler/drop-debug-info-nonzero-alloca.ll
@@ -25,4 +25,6 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
!llvm.module.flags = !{!0}
!0 = !{i32 2, !"Debug Info Version", i32 3}
-!1 = distinct !DISubprogram(name: "foo")
+!1 = distinct !DISubprogram(name: "foo", type: !3)
+!2 = !{null}
+!3 = !DISubroutineType(types: !2)
diff --git a/llvm/test/Assembler/invalid-diflag-bad.ll b/llvm/test/Assembler/invalid-diflag-bad.ll
index cde59f6ce6674..0c5ec6e3a630a 100644
--- a/llvm/test/Assembler/invalid-diflag-bad.ll
+++ b/llvm/test/Assembler/invalid-diflag-bad.ll
@@ -1,4 +1,6 @@
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
; CHECK: <stdin>:[[@LINE+1]]:27: error: invalid debug info flag 'DIFlagUnknown'
-!0 = !DISubprogram(flags: DIFlagUnknown)
+!0 = !DISubprogram(flags: DIFlagUnknown, type: !2)
+!1 = !{null}
+!2 = !DISubroutineType(types: !1)
diff --git a/llvm/test/Assembler/invalid-disubprogram-uniqued-definition.ll b/llvm/test/Assembler/invalid-disubprogram-uniqued-definition.ll
index 6641e6dc21d72..2d406d5df2b1c 100644
--- a/llvm/test/Assembler/invalid-disubprogram-uniqued-definition.ll
+++ b/llvm/test/Assembler/invalid-disubprogram-uniqued-definition.ll
@@ -1,4 +1,6 @@
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
; CHECK: <stdin>:[[@LINE+1]]:6: error: missing 'distinct', required for !DISubprogram that is a Definition
-!0 = !DISubprogram(isDefinition: true)
+!0 = !DISubprogram(isDefinition: true, type: !2)
+!1 = !{null}
+!2 = !DISubroutineType(types: !1)
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/fconstant-dbg-loc.ll b/llvm/test/CodeGen/AArch64/GlobalISel/fconstant-dbg-loc.ll
index 6281c2f5c0a78..4661a0132afc0 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/fconstant-dbg-loc.ll
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/fconstant-dbg-loc.ll
@@ -21,5 +21,7 @@ define float @main() #0 !dbg !14 {
!11 = !{i32 1, !"wchar_size", i32 4}
!12 = !{i32 7, !"PIC Level", i32 2}
!13 = !{!"clang"}
-!14 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 3, scopeLine: 3, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !4)
+!14 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 3, scopeLine: 3, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !4, type: !26)
!24 = !DILocation(line: 7, column: 3, scope: !14)
+!25 = !{null}
+!26 = !DISubroutineType(types: !25)
diff --git a/llvm/test/CodeGen/AArch64/sdag-no-typesize-warnings-regandsizes.ll b/llvm/test/CodeGen/AArch64/sdag-no-typesize-warnings-regandsizes.ll
index 4fb816172b19d..e3ef90db8cde3 100644
--- a/llvm/test/CodeGen/AArch64/sdag-no-typesize-warnings-regandsizes.ll
+++ b/llvm/test/CodeGen/AArch64/sdag-no-typesize-warnings-regandsizes.ll
@@ -23,5 +23,7 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
!1 = !DIFile(filename: "file.c", directory: "/")
!2 = !{i32 2, !"Debug Info Version", i32 3}
!3 = !DILocalVariable(scope: !4)
-!4 = distinct !DISubprogram(unit: !0)
+!4 = distinct !DISubprogram(unit: !0, type: !7)
!5 = !DILocation(scope: !4)
+!6 = !{null}
+!7 = !DISubroutineType(types: !6)
diff --git a/llvm/test/CodeGen/AArch64/selectiondag-order.ll b/llvm/test/CodeGen/AArch64/selectiondag-order.ll
index fb40653723fec..46a7ae6521e45 100644
--- a/llvm/test/CodeGen/AArch64/selectiondag-order.ll
+++ b/llvm/test/CodeGen/AArch64/selectiondag-order.ll
@@ -90,7 +90,9 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata)
!2 = !DIFile(filename: "test.ll", directory: ".")
!3 = !{i32 2, !"Dwarf Version", i32 4}
!4 = !{i32 2, !"Debug Info Version", i32 3}
-!5 = distinct !DISubprogram(name: "simulateWithDebugIntrinsic", scope: !2, file: !2, line: 64, isLocal: false, isDefinition: true, scopeLine: 65, unit: !1)
+!5 = distinct !DISubprogram(name: "simulateWithDebugIntrinsic", scope: !2, file: !2, line: 64, isLocal: false, isDefinition: true, scopeLine: 65, unit: !1, type: !10)
!6 = !DILocalVariable(name: "randv", scope: !5, file: !2, line: 69)
!7 = !DIExpression()
!8 = !DILocation(line: 132, column: 2, scope: !5)
+!9 = !{null}
+!10 = !DISubroutineType(types: !9)
diff --git a/llvm/test/CodeGen/AMDGPU/simplify-libcalls2.ll b/llvm/test/CodeGen/AMDGPU/simplify-libcalls2.ll
index 692a73a9bc593..9edefe5ff53ff 100644
--- a/llvm/test/CodeGen/AMDGPU/simplify-libcalls2.ll
+++ b/llvm/test/CodeGen/AMDGPU/simplify-libcalls2.ll
@@ -20,5 +20,7 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !DIFile(filename: "1", directory: "1"))
!1 = !{i32 2, !"Debug Info Version", i32 3}
-!2 = distinct !DISubprogram(unit: !0)
+!2 = distinct !DISubprogram(unit: !0, type: !5)
!3 = !DILocation(line: 1, column: 1, scope: !2)
+!4 = !{null}
+!5 = !DISubroutineType(types: !4)
diff --git a/llvm/test/CodeGen/ARM/2009-10-16-Scope.ll b/llvm/test/CodeGen/ARM/2009-10-16-Scope.ll
index c01f3bf352b18..90a72db645fa5 100644
--- a/llvm/test/CodeGen/ARM/2009-10-16-Scope.ll
+++ b/llvm/test/CodeGen/ARM/2009-10-16-Scope.ll
@@ -25,7 +25,7 @@ declare i32 @foo(i32) ssp
!llvm.dbg.cu = !{!0}
!0 = !DILocation(line: 5, column: 2, scope: !1)
!1 = distinct !DILexicalBlock(line: 1, column: 1, file: null, scope: !2)
-!2 = distinct !DISubprogram(name: "bar", linkageName: "bar", line: 4, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !3, scope: !3)
+!2 = distinct !DISubprogram(name: "bar", linkageName: "bar", line: 4, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !3, scope: !3, type: !11)
!3 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang 1.1", isOptimized: true, emissionKind: FullDebug, file: !8, retainedTypes: !9)
!4 = !DILocalVariable(name: "count_", line: 5, scope: !5, file: !3, type: !6)
!5 = distinct !DILexicalBlock(line: 1, column: 1, file: null, scope: !1)
@@ -33,3 +33,5 @@ declare i32 @foo(i32) ssp
!7 = !DILocation(line: 6, column: 1, scope: !2)
!8 = !DIFile(filename: "genmodes.i", directory: "/Users/yash/Downloads")
!9 = !{i32 0}
+!10 = !{null}
+!11 = !DISubroutineType(types: !10)
diff --git a/llvm/test/CodeGen/ARM/analyze-branch-bkpt.ll b/llvm/test/CodeGen/ARM/analyze-branch-bkpt.ll
index cba89fe998700..d6a2f58589c32 100644
--- a/llvm/test/CodeGen/ARM/analyze-branch-bkpt.ll
+++ b/llvm/test/CodeGen/ARM/analyze-branch-bkpt.ll
@@ -50,12 +50,14 @@ attributes #1 = { nounwind }
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug)
!1 = !DIFile(filename: "a", directory: "")
!2 = !{i32 2, !"Debug Info Version", i32 3}
-!3 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0)
+!3 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, type: !13)
!4 = !DILocation(line: 0, scope: !5, inlinedAt: !6)
-!5 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0)
+!5 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, type: !13)
!6 = !DILocation(line: 0, scope: !3)
!7 = !DILocalVariable(scope: !8)
-!8 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0)
+!8 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, type: !13)
!9 = !DILocation(line: 0, scope: !8, inlinedAt: !6)
!10 = !DILocation(line: 0, scope: !11, inlinedAt: !6)
!11 = !DILexicalBlock(scope: !8)
+!12 = !{null}
+!13 = !DISubroutineType(types: !12)
diff --git a/llvm/test/CodeGen/Generic/dbg_value.ll b/llvm/test/CodeGen/Generic/dbg_value.ll
index a143801bf7eba..54870d51bb2e3 100644
--- a/llvm/test/CodeGen/Generic/dbg_value.ll
+++ b/llvm/test/CodeGen/Generic/dbg_value.ll
@@ -12,4 +12,6 @@ declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnon
; !0 should conform to the format of DIVariable.
!0 = !DILocalVariable(name: "a", arg: 1, scope: !1)
-!1 = distinct !DISubprogram()
+!1 = distinct !DISubprogram(type: !3)
+!2 = !{null}
+!3 = !DISubroutineType(types: !2)
diff --git a/llvm/test/CodeGen/MIR/X86/fixed-stack-di.mir b/llvm/test/CodeGen/MIR/X86/fixed-stack-di.mir
index fca249320bc82..6351b9bded8c8 100644
--- a/llvm/test/CodeGen/MIR/X86/fixed-stack-di.mir
+++ b/llvm/test/CodeGen/MIR/X86/fixed-stack-di.mir
@@ -23,8 +23,10 @@
!1 = !DIFile(filename: "file.cpp", directory: "/dir")
!2 = !{i32 2, !"Debug Info Version", i32 3}
!3 = !DILocalVariable(name: "dstRect", scope: !4)
- !4 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !0, file: !1, line: 42, unit: !0)
+ !4 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !0, file: !1, line: 42, unit: !0, type: !7)
!5 = !DILocation(line: 42, column: 85, scope: !4)
+ !6 = !{null}
+ !7 = !DISubroutineType(types: !6)
...
---
diff --git a/llvm/test/CodeGen/MIR/X86/invalid-metadata-node-type.mir b/llvm/test/CodeGen/MIR/X86/invalid-metadata-node-type.mir
index 1a83f891d1fa4..ec98834857f1f 100644
--- a/llvm/test/CodeGen/MIR/X86/invalid-metadata-node-type.mir
+++ b/llvm/test/CodeGen/MIR/X86/invalid-metadata-node-type.mir
@@ -27,10 +27,12 @@
!2 = !{}
!3 = !{i32 1, !"Debug Info Version", i32 3}
!4 = !DILocalVariable(name: "x", scope: !5, file: !1, line: 16, type: !6)
- !5 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0)
+ !5 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, type: !10)
!6 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)
!7 = !DIExpression()
!8 = !DILocation(line: 0, scope: !5)
+ !9 = !{null}
+ !10 = !DISubroutineType(types: !9)
...
---
name: foo
diff --git a/llvm/test/CodeGen/RISCV/rvv/get-vlen-debugloc.mir b/llvm/test/CodeGen/RISCV/rvv/get-vlen-debugloc.mir
index c493a6ca180aa..1d9b8b2d429be 100644
--- a/llvm/test/CodeGen/RISCV/rvv/get-vlen-debugloc.mir
+++ b/llvm/test/CodeGen/RISCV/rvv/get-vlen-debugloc.mir
@@ -11,9 +11,11 @@
ret void, !dbg !2
}
- !0 = distinct !DISubprogram(name: "foo", line: 3, scopeLine: 3)
+ !0 = distinct !DISubprogram(name: "foo", line: 3, scopeLine: 3, type: !4)
!1 = !DILocation(line: 4, column: 14, scope: !0)
!2 = !DILocation(line: 5, column: 3, scope: !0)
+ !3 = !{null}
+ !4 = !DISubroutineType(types: !3)
...
---
diff --git a/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll b/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
index 51dcf2fc7ec62..bb80e4886da5e 100644
--- a/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
+++ b/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
@@ -302,9 +302,11 @@ attributes #3 = { allocsize(0) }
!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = !DIFile(filename: "lower-em-sjlj.c", directory: "test")
!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1)
-!3 = distinct !DISubprogram(name: "setjmp_debug_info", unit:!2, file: !1, line: 1)
+!3 = distinct !DISubprogram(name: "setjmp_debug_info", unit:!2, file: !1, line: 1, type: !10)
!4 = !DILocation(line:2, scope: !3)
!5 = !DILocation(line:3, scope: !3)
!6 = !DILocation(line:4, scope: !3)
!7 = !DILocation(line:5, scope: !3)
!8 = !DILocation(line:6, scope: !3)
+!9 = !{null}
+!10 = !DISubroutineType(types: !9)
diff --git a/llvm/test/CodeGen/X86/2009-10-16-Scope.ll b/llvm/test/CodeGen/X86/2009-10-16-Scope.ll
index bb568713d5c6a..1e3356fcc08b3 100644
--- a/llvm/test/CodeGen/X86/2009-10-16-Scope.ll
+++ b/llvm/test/CodeGen/X86/2009-10-16-Scope.ll
@@ -25,7 +25,7 @@ declare i32 @foo(i32) ssp
!llvm.dbg.cu = !{!3}
!0 = !DILocation(line: 5, column: 2, scope: !1)
!1 = distinct !DILexicalBlock(line: 1, column: 1, file: null, scope: !2)
-!2 = distinct !DISubprogram(name: "bar", linkageName: "bar", line: 4, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !3, scope: !3)
+!2 = distinct !DISubprogram(name: "bar", linkageName: "bar", line: 4, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !3, scope: !3, type: !11)
!3 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang 1.1", isOptimized: true, emissionKind: FullDebug, file: !8, retainedTypes: !9)
!4 = !DILocalVariable(name: "count_", line: 5, scope: !5, file: !3, type: !6)
!5 = distinct !DILexicalBlock(line: 1, column: 1, file: null, scope: !1)
@@ -33,3 +33,5 @@ declare i32 @foo(i32) ssp
!7 = !DILocation(line: 6, column: 1, scope: !2)
!8 = !DIFile(filename: "genmodes.i", directory: "/Users/yash/Downloads")
!9 = !{i32 0}
+!10 = !{null}
+!11 = !DISubroutineType(types: !10)
diff --git a/llvm/test/CodeGen/X86/AMX/amx-ldtilecfg-insert.ll b/llvm/test/CodeGen/X86/AMX/amx-ldtilecfg-insert.ll
index 8a8e7a3b4df2c..972e507793799 100644
--- a/llvm/test/CodeGen/X86/AMX/amx-ldtilecfg-insert.ll
+++ b/llvm/test/CodeGen/X86/AMX/amx-ldtilecfg-insert.ll
@@ -366,5 +366,7 @@ declare void @llvm.x86.tilestored64.internal(i16, i16, ptr, i64, x86_amx)
!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !DIFile(filename: "1", directory: "1"))
!1 = !{i32 2, !"Debug Info Version", i32 3}
-!2 = distinct !DISubprogram(unit: !0)
+!2 = distinct !DISubprogram(unit: !0, type: !5)
!3 = !DILocation(line: 1, column: 1, scope: !2)
+!4 = !{null}
+!5 = !DISubroutineType(types: !4)
diff --git a/llvm/test/CodeGen/X86/GlobalISel/regbankselect-dbg-value-physreg-crash.mir b/llvm/test/CodeGen/X86/GlobalISel/regbankselect-dbg-value-physreg-crash.mir
index 79523b904ee9a..085fa2c55b645 100644
--- a/llvm/test/CodeGen/X86/GlobalISel/regbankselect-dbg-value-physreg-crash.mir
+++ b/llvm/test/CodeGen/X86/GlobalISel/regbankselect-dbg-value-physreg-crash.mir
@@ -11,8 +11,10 @@
ret void
}
- !0 = distinct !DISubprogram(name: "foo")
+ !0 = distinct !DISubprogram(name: "foo", type: !3)
!1 = !DILocation(line: 1, column: 1, scope: !0)
+ !2 = !{null}
+ !3 = !DISubroutineType(types: !2)
...
---
diff --git a/llvm/test/CodeGen/X86/StackColoring-dbg.ll b/llvm/test/CodeGen/X86/StackColoring-dbg.ll
index ccb1c3fdb27fe..c1b29a773adfb 100644
--- a/llvm/test/CodeGen/X86/StackColoring-dbg.ll
+++ b/llvm/test/CodeGen/X86...
[truncated]
|
🪟 Windows x64 Test Results
✅ The build succeeded and all tests passed. |
🐧 Linux x64 Test Results
✅ The build succeeded and all tests passed. |
1b62b76 to
0a3d240
Compare
Add a parse-time check so that the LLParser treats the `type:` field of
DISubprogram as required and non-null, producing a clear parse-time
error ("missing required field 'type'" / "'type' cannot be null") in
addition to the existing verifier check added in llvm#194556.
Update existing tests to supply a minimal valid type field where they
are not intentionally testing malformed debug info.
0a3d240 to
211c919
Compare
jmorse
left a comment
There was a problem hiding this comment.
LGTM. Thanks for driving this through!
|
Thanks for the review, @jmorse! The pre-merge checks are green now. I don't have commit access yet, so could you or another maintainer help land this when convenient? |
|
One comment regarding the description:
The writer currently does: We'll want to update this to unconditionally But happy to keep that as a follow-up |
…96299) Add a parse-time check so that LLParser treats the `type:` field of `DISubprogram` as required and non-null. Attempting to assemble IR with a missing or null `type:` now produces a clear parse-time error ("missing required field 'type'" or "'type' cannot be null") rather than relying solely on the verifier warning added in llvm#194556. Update existing hand-written LLVM IR tests to supply a minimal valid `DISubroutineType` where they are not intentionally testing malformed debug info. **Scope.** This patch covers the LLParser path only. Two entry points are intentionally deferred: - *MetadataLoader*: pre-LLVM-5 bitcode legitimately stores null `DISubprogram.type`; auto-upgrading that field requires more careful backward-compatibility handling (see `llvm/test/Bitcode/dityperefs-3.8.ll`). - *BitcodeWriter*: IR written to bitcode has already passed the verifier, which guarantees a non-null type; no additional check is needed in the writer. Follow-up to llvm#194556.
…96299) Add a parse-time check so that LLParser treats the `type:` field of `DISubprogram` as required and non-null. Attempting to assemble IR with a missing or null `type:` now produces a clear parse-time error ("missing required field 'type'" or "'type' cannot be null") rather than relying solely on the verifier warning added in llvm#194556. Update existing hand-written LLVM IR tests to supply a minimal valid `DISubroutineType` where they are not intentionally testing malformed debug info. **Scope.** This patch covers the LLParser path only. Two entry points are intentionally deferred: - *MetadataLoader*: pre-LLVM-5 bitcode legitimately stores null `DISubprogram.type`; auto-upgrading that field requires more careful backward-compatibility handling (see `llvm/test/Bitcode/dityperefs-3.8.ll`). - *BitcodeWriter*: IR written to bitcode has already passed the verifier, which guarantees a non-null type; no additional check is needed in the writer. Follow-up to llvm#194556.
…96299) Add a parse-time check so that LLParser treats the `type:` field of `DISubprogram` as required and non-null. Attempting to assemble IR with a missing or null `type:` now produces a clear parse-time error ("missing required field 'type'" or "'type' cannot be null") rather than relying solely on the verifier warning added in llvm#194556. Update existing hand-written LLVM IR tests to supply a minimal valid `DISubroutineType` where they are not intentionally testing malformed debug info. **Scope.** This patch covers the LLParser path only. Two entry points are intentionally deferred: - *MetadataLoader*: pre-LLVM-5 bitcode legitimately stores null `DISubprogram.type`; auto-upgrading that field requires more careful backward-compatibility handling (see `llvm/test/Bitcode/dityperefs-3.8.ll`). - *BitcodeWriter*: IR written to bitcode has already passed the verifier, which guarantees a non-null type; no additional check is needed in the writer. Follow-up to llvm#194556.
Add a parse-time check so that LLParser treats the
type:field ofDISubprogramas required and non-null. Attempting to assemble IR witha missing or null
type:now produces a clear parse-time error("missing required field 'type'" or "'type' cannot be null") rather
than relying solely on the verifier warning added in #194556.
Update existing hand-written LLVM IR tests to supply a minimal valid
DISubroutineTypewhere they are not intentionally testing malformeddebug info.
Scope. This patch covers the LLParser path only. Two entry points
are intentionally deferred:
DISubprogram.type; auto-upgrading that field requires more carefulbackward-compatibility handling (see
llvm/test/Bitcode/dityperefs-3.8.ll).verifier, which guarantees a non-null type; no additional check is
needed in the writer.
Follow-up to #194556.