[Mlir-commits] [mlir] 81518d0 - [DebugInfo] Verify DISubprogram has a type (#194556)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon May 4 03:32:26 PDT 2026


Author: Jiang Ning
Date: 2026-05-04T11:32:19+01:00
New Revision: 81518d06acaa52b9a6e9221834ab64334a25105d

URL: https://github.com/llvm/llvm-project/commit/81518d06acaa52b9a6e9221834ab64334a25105d
DIFF: https://github.com/llvm/llvm-project/commit/81518d06acaa52b9a6e9221834ab64334a25105d.diff

LOG: [DebugInfo] Verify DISubprogram has a type (#194556)

Require DISubprogram metadata to carry a non-null type in the verifier.

LangRef specifies that the `type:` field of `DISubprogram` points to a
`DISubroutineType`. This patch diagnoses malformed debug info where the
field is omitted or resolves to null, while preserving the existing wrong-type
diagnostic for non-DISubroutineType operands.

Update hand-written LLVM IR tests to use valid DISubprogram metadata
where they are not intentionally testing malformed debug info. These tests now 
use minimal DISubroutineType metadata so the new verifier check does not mask 
their original coverage.

Fixes #186557

Added: 
    llvm/test/Verifier/DISubprogram-type.ll

Modified: 
    lld/test/ELF/lto/pseudo-probe-lto.ll
    llvm/lib/IR/Verifier.cpp
    llvm/test/Analysis/LoopAccessAnalysis/debug-loc.ll
    llvm/test/Assembler/dicompositetype-members.ll
    llvm/test/Assembler/diimportedentity.ll
    llvm/test/Assembler/dilexicalblock.ll
    llvm/test/Assembler/dilocalvariable-arg-large.ll
    llvm/test/Assembler/dilocalvariable.ll
    llvm/test/Assembler/dilocation.ll
    llvm/test/Assembler/disubprogram.ll
    llvm/test/Assembler/metadata.ll
    llvm/test/Bitcode/DILocalVariable-explicit-tags.ll
    llvm/test/Bitcode/DILocalVariable-explicit-tags.ll.bc
    llvm/test/Bitcode/DISubprogram-distinct-definitions.ll
    llvm/test/Bitcode/DISubprogram-distinct-definitions.ll.bc
    llvm/test/Bitcode/DISubprogram-v4.ll
    llvm/test/Bitcode/DISubprogram-v4.ll.bc
    llvm/test/Bitcode/debug-loc-again.ll
    llvm/test/Bitcode/dityperefs-3.8.ll
    llvm/test/CodeGen/AArch64/addrsig-macho.ll
    llvm/test/CodeGen/AArch64/arm64-instruction-mix-remarks.ll
    llvm/test/CodeGen/AArch64/arm64-opt-remarks-lazy-bfi.ll
    llvm/test/CodeGen/AArch64/arm64-summary-remarks.ll
    llvm/test/CodeGen/AArch64/fast-isel-dbg.ll
    llvm/test/CodeGen/AArch64/instr-ref-ldv.ll
    llvm/test/CodeGen/AMDGPU/GlobalISel/trunc-brc.ll
    llvm/test/CodeGen/AMDGPU/opencl-printf-unsupported.ll
    llvm/test/CodeGen/AMDGPU/sched-crash-dbg-value.mir
    llvm/test/CodeGen/AMDGPU/vi-removed-intrinsics.ll
    llvm/test/CodeGen/MIR/X86/stack-object-debug-info.mir
    llvm/test/CodeGen/WebAssembly/lower-em-sjlj-debuginfo.ll
    llvm/test/CodeGen/X86/basic-block-sections-clusters-error.ll
    llvm/test/CodeGen/X86/basic-block-sections-module1.ll
    llvm/test/CodeGen/X86/basic-block-sections-module2.ll
    llvm/test/CodeGen/X86/fixed-stack-di-mir.ll
    llvm/test/CodeGen/X86/pr57673.ll
    llvm/test/CodeGen/X86/select-optimize.ll
    llvm/test/CodeGen/X86/tail-merge-debugloc.ll
    llvm/test/DebugInfo/AMDGPU/bitcast-store-combine-debugloc.ll
    llvm/test/DebugInfo/ARM/move-dbg-value-after-value-list.mir
    llvm/test/DebugInfo/ARM/move-dbg-value-lists.mir
    llvm/test/DebugInfo/ARM/move-dbg-value-same-reg.mir
    llvm/test/DebugInfo/ARM/move-dbg-values.mir
    llvm/test/DebugInfo/Generic/2010-03-19-DbgDeclare.ll
    llvm/test/DebugInfo/Generic/dbg-value-lower-linenos.ll
    llvm/test/DebugInfo/Generic/debuginfofinder-retained-nodes.ll
    llvm/test/DebugInfo/Generic/invalid.ll
    llvm/test/DebugInfo/Generic/sroa-extract-bits.ll
    llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll
    llvm/test/DebugInfo/MIR/X86/dbgcall-site-interpretation.mir
    llvm/test/DebugInfo/MIR/X86/dbgcall-site-lea-interpretation.mir
    llvm/test/DebugInfo/MIR/X86/dbginfo-entryvals.mir
    llvm/test/DebugInfo/MIR/X86/debug-call-site-param.mir
    llvm/test/DebugInfo/MIR/X86/machine-cse.mir
    llvm/test/DebugInfo/X86/instr-ref-opt-bisect2.ll
    llvm/test/DebugInfo/X86/pr40427.ll
    llvm/test/DebugInfo/X86/sunk-compare.ll
    llvm/test/DebugInfo/sroa-handle-dbg-value.ll
    llvm/test/Instrumentation/AddressSanitizer/stack_layout.ll
    llvm/test/Transforms/AggressiveInstCombine/AArch64/combine_ignore_debug.ll
    llvm/test/Transforms/ArgumentPromotion/pr33641_remove_arg_dbgvalue.ll
    llvm/test/Transforms/Attributor/ArgumentPromotion/dbg.ll
    llvm/test/Transforms/Attributor/ArgumentPromotion/pr33641_remove_arg_dbgvalue.ll
    llvm/test/Transforms/CallSiteSplitting/callsite-split-debug.ll
    llvm/test/Transforms/CodeGenPrepare/X86/cast-debuginfo-salvage.ll
    llvm/test/Transforms/Coroutines/declare-value.ll
    llvm/test/Transforms/Inline/debug-invoke.ll
    llvm/test/Transforms/InstCombine/assume.ll
    llvm/test/Transforms/InstCombine/consecutive-fences.ll
    llvm/test/Transforms/LICM/hoist-phi-metadata.ll
    llvm/test/Transforms/LoopDistribute/debug-loc.ll
    llvm/test/Transforms/LoopVectorize/debugloc.ll
    llvm/test/Transforms/LoopVectorize/discriminator.ll
    llvm/test/Transforms/Mem2Reg/dbg_declare_to_value_conversions.ll
    llvm/test/Transforms/PGOProfile/memprof_annotate_indirect_call.test
    llvm/test/Transforms/PGOProfile/memprof_annotate_yaml.test
    llvm/test/Transforms/PGOProfile/memprof_max_cold_threshold.test
    llvm/test/Transforms/SLPVectorizer/X86/debug-info-salvage.ll
    llvm/test/Transforms/SLPVectorizer/X86/phi-node-deletion.ll
    llvm/test/Transforms/SLPVectorizer/X86/schedule_budget_debug_info.ll
    llvm/test/Transforms/SROA/dbg-single-piece.ll
    llvm/test/Transforms/SampleProfile/cold-indirect-call.ll
    llvm/test/Transforms/SampleProfile/csspgo-inline-icall.ll
    llvm/test/Transforms/SampleProfile/early-inline.ll
    llvm/test/Transforms/SampleProfile/function_metadata.ll
    llvm/test/Transforms/SampleProfile/indirect-call-gcc.ll
    llvm/test/Transforms/SampleProfile/indirect-call.ll
    llvm/test/Transforms/SampleProfile/inline-callee-update.ll
    llvm/test/Transforms/SimplifyCFG/X86/hoist-loads-stores-with-cf.ll
    llvm/test/Transforms/SimplifyCFG/X86/remove-debug.ll
    llvm/test/Transforms/SimplifyCFG/pr39807.ll
    llvm/test/Transforms/SimplifyCFG/tail-merge-noreturn.ll
    llvm/test/Transforms/StripSymbols/find-live-cu.ll
    llvm/test/Transforms/Util/trivial-auto-var-init-call.ll
    llvm/test/Transforms/Util/trivial-auto-var-init-store.ll
    llvm/test/Transforms/Util/trivial-auto-var-init-unknown.ll
    llvm/test/Transforms/WholeProgramDevirt/devirt-single-impl.ll
    llvm/test/Transforms/WholeProgramDevirt/devirt_single_after_filtering_unreachable_function.ll
    llvm/test/Transforms/WholeProgramDevirt/speculative-devirt-single-impl.ll
    llvm/test/Verifier/verify-dwarf-no-operands.ll
    llvm/test/tools/llvm-dwarfdump/X86/stats-dbg-callsite-info.ll
    llvm/unittests/IR/DebugInfoTest.cpp
    llvm/unittests/IR/ModuleTest.cpp
    llvm/unittests/IR/VerifierTest.cpp
    llvm/unittests/Transforms/Utils/CloningTest.cpp
    mlir/test/Dialect/LLVMIR/di-expression-legalization.mlir
    mlir/test/Target/LLVMIR/Import/debug-info.ll
    mlir/test/Target/LLVMIR/Import/exception.ll
    mlir/test/Target/LLVMIR/Import/import-failure.ll
    mlir/test/Target/LLVMIR/Import/metadata-loop.ll
    mlir/test/Target/LLVMIR/llvmir-debug.mlir
    mlir/test/Target/LLVMIR/loop-metadata.mlir
    mlir/test/mlir-translate/import-diagnostics.ll

Removed: 
    


################################################################################
diff  --git a/lld/test/ELF/lto/pseudo-probe-lto.ll b/lld/test/ELF/lto/pseudo-probe-lto.ll
index cabd69da33fe2..fbd61adc103c5 100644
--- a/lld/test/ELF/lto/pseudo-probe-lto.ll
+++ b/lld/test/ELF/lto/pseudo-probe-lto.ll
@@ -30,7 +30,9 @@ entry:
 
 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1)
 !1 = !DIFile(filename: "test.c", directory: "")
-!4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 2, unit: !0)
+!4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 2, type: !14, unit: !0)
 !9 = !{i32 2, !"Dwarf Version", i32 4}
 !10 = !{i32 2, !"Debug Info Version", i32 3}
 !13 = !DILocation(line: 2, column: 20, scope: !4)
+!14 = !DISubroutineType(types: !15)
+!15 = !{null}

diff  --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 81903edfbd5f1..748e0cc81acfd 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -1657,8 +1657,9 @@ void Verifier::visitDISubprogram(const DISubprogram &N) {
     CheckDI(isa<DIFile>(F), "invalid file", &N, F);
   else
     CheckDI(N.getLine() == 0, "line specified with no file", &N, N.getLine());
-  if (auto *T = N.getRawType())
-    CheckDI(isa<DISubroutineType>(T), "invalid subroutine type", &N, T);
+  auto *T = N.getRawType();
+  CheckDI(T, "DISubprogram requires a non-null type", &N);
+  CheckDI(isa<DISubroutineType>(T), "invalid subroutine type", &N, T);
   CheckDI(isType(N.getRawContainingType()), "invalid containing type", &N,
           N.getRawContainingType());
   if (auto *Params = N.getRawTemplateParams())

diff  --git a/llvm/test/Analysis/LoopAccessAnalysis/debug-loc.ll b/llvm/test/Analysis/LoopAccessAnalysis/debug-loc.ll
index 320a543d9b3cf..6edb4965a802c 100644
--- a/llvm/test/Analysis/LoopAccessAnalysis/debug-loc.ll
+++ b/llvm/test/Analysis/LoopAccessAnalysis/debug-loc.ll
@@ -26,9 +26,11 @@ exit:
 !llvm.module.flags = !{!5, !6, !7}
 
 !0 = !DIFile(filename: "negative_step.c", directory: "/")
-!1 = distinct !DISubprogram(name: "negative_step", scope: !0, file: !0, unit: !4)
+!1 = distinct !DISubprogram(name: "negative_step", scope: !0, file: !0, type: !8, unit: !4)
 !2 = !DILocation(line: 5, column: 2, scope: !1)
 !4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !0, producer: "clang")
 !5 = !{i32 1, !"Debug Info Version", i32 3}
 !6 = !{i32 2, !"Dwarf Version", i32 2}
 !7 = !{i32 1, !"PIC Level", i32 2}
+!8 = !DISubroutineType(types: !9)
+!9 = !{null}

diff  --git a/llvm/test/Assembler/dicompositetype-members.ll b/llvm/test/Assembler/dicompositetype-members.ll
index f5471bda840cc..c69bc1413ae9b 100644
--- a/llvm/test/Assembler/dicompositetype-members.ll
+++ b/llvm/test/Assembler/dicompositetype-members.ll
@@ -16,39 +16,43 @@
 ; CHECK-NEXT: !3 = !DICompositeType(tag: DW_TAG_structure_type, name: "has-uuid",{{.*}}, identifier: "uuid")
 ; CHECK-NEXT: !4 = !DIDerivedType(tag: DW_TAG_member, name: "field1", scope: !3, file: !1
 ; CHECK-NEXT: !5 = !DIDerivedType(tag: DW_TAG_member, name: "field2", scope: !3, file: !1
-; CHECK-NEXT: !6 = !DISubprogram(name: "foo", linkageName: "foo1", scope: !3, file: !1
-; CHECK-NEXT: !7 = !DISubprogram(name: "foo", linkageName: "foo2", scope: !3, file: !1
+; CHECK-NEXT: !6 = !DISubprogram(name: "foo", linkageName: "foo1", scope: !3, file: !1, type: !7, spFlags: 0)
+; CHECK-NEXT: !7 = !DISubroutineType(types: !8)
+; CHECK-NEXT: !8 = !{null}
+; CHECK-NEXT: !9 = !DISubprogram(name: "foo", linkageName: "foo2", scope: !3, file: !1, type: !7, spFlags: 0)
 !3 = !DICompositeType(tag: DW_TAG_structure_type, name: "has-uuid", file: !1, line: 2, size: 64, align: 32, identifier: "uuid")
 !4 = !DIDerivedType(tag: DW_TAG_member, name: "field1", scope: !3, file: !1, line: 4, baseType: !0, size: 32, align: 32, offset: 32)
 !5 = !DIDerivedType(tag: DW_TAG_member, name: "field2", scope: !3, file: !1, line: 4, baseType: !0, size: 32, align: 32, offset: 32)
-!6 = !DISubprogram(name: "foo", linkageName: "foo1", scope: !3, file: !1, isDefinition: false)
-!7 = !DISubprogram(name: "foo", linkageName: "foo2", scope: !3, file: !1, isDefinition: false)
+!6 = !DISubprogram(name: "foo", linkageName: "foo1", scope: !3, file: !1, isDefinition: false, type: !18)
+!7 = !DISubprogram(name: "foo", linkageName: "foo2", scope: !3, file: !1, isDefinition: false, type: !18)
+!18 = !DISubroutineType(types: !19)
+!19 = !{null}
 
 ; Define an un-identified type with fields and functions.
-; CHECK-NEXT: !8 = !DICompositeType(tag: DW_TAG_structure_type, name: "no-uuid", file: !1
-; CHECK-NEXT: !9 = !DIDerivedType(tag: DW_TAG_member, name: "field1", scope: !8, file: !1
-; CHECK-NEXT: !10 = !DIDerivedType(tag: DW_TAG_member, name: "field2", scope: !8, file: !1
-; CHECK-NEXT: !11 = !DISubprogram(name: "foo", linkageName: "foo1", scope: !8, file: !1
-; CHECK-NEXT: !12 = !DISubprogram(name: "foo", linkageName: "foo2", scope: !8, file: !1
+; CHECK-NEXT: !10 = !DICompositeType(tag: DW_TAG_structure_type, name: "no-uuid", file: !1
+; CHECK-NEXT: !11 = !DIDerivedType(tag: DW_TAG_member, name: "field1", scope: !10, file: !1
+; CHECK-NEXT: !12 = !DIDerivedType(tag: DW_TAG_member, name: "field2", scope: !10, file: !1
+; CHECK-NEXT: !13 = !DISubprogram(name: "foo", linkageName: "foo1", scope: !10, file: !1, type: !7, spFlags: 0)
+; CHECK-NEXT: !14 = !DISubprogram(name: "foo", linkageName: "foo2", scope: !10, file: !1, type: !7, spFlags: 0)
 !8 = !DICompositeType(tag: DW_TAG_structure_type, name: "no-uuid", file: !1, line: 2, size: 64, align: 32)
 !9 = !DIDerivedType(tag: DW_TAG_member, name: "field1", scope: !8, file: !1, line: 4, baseType: !0, size: 32, align: 32, offset: 32)
 !10 = !DIDerivedType(tag: DW_TAG_member, name: "field2", scope: !8, file: !1, line: 4, baseType: !0, size: 32, align: 32, offset: 32)
-!11 = !DISubprogram(name: "foo", linkageName: "foo1", scope: !8, file: !1, isDefinition: false)
-!12 = !DISubprogram(name: "foo", linkageName: "foo2", scope: !8, file: !1, isDefinition: false)
+!11 = !DISubprogram(name: "foo", linkageName: "foo1", scope: !8, file: !1, isDefinition: false, type: !18)
+!12 = !DISubprogram(name: "foo", linkageName: "foo2", scope: !8, file: !1, isDefinition: false, type: !18)
 
 ; Add duplicate fields and members of "no-uuid" in a 
diff erent file.  These
 ; should stick around, since "no-uuid" does not have an "identifier:" field.
-; CHECK-NEXT: !13 = !DIDerivedType(tag: DW_TAG_member, name: "field1", scope: !8, file: !2,
-; CHECK-NEXT: !14 = !DISubprogram(name: "foo", linkageName: "foo1", scope: !8, file: !2,
+; CHECK-NEXT: !15 = !DIDerivedType(tag: DW_TAG_member, name: "field1", scope: !10, file: !2,
+; CHECK-NEXT: !16 = !DISubprogram(name: "foo", linkageName: "foo1", scope: !10, file: !2, type: !7, spFlags: 0)
 !13 = !DIDerivedType(tag: DW_TAG_member, name: "field1", scope: !8, file: !2, line: 4, baseType: !0, size: 32, align: 32, offset: 32)
-!14 = !DISubprogram(name: "foo", linkageName: "foo1", scope: !8, file: !2, isDefinition: false)
+!14 = !DISubprogram(name: "foo", linkageName: "foo1", scope: !8, file: !2, isDefinition: false, type: !18)
 
 ; Add duplicate fields and members of "has-uuid" in a 
diff erent file.  These
 ; should be merged.
 !15 = !DIDerivedType(tag: DW_TAG_member, name: "field1", scope: !3, file: !2, line: 4, baseType: !0, size: 32, align: 32, offset: 32)
-!16 = !DISubprogram(name: "foo", linkageName: "foo1", scope: !3, file: !2, isDefinition: false)
+!16 = !DISubprogram(name: "foo", linkageName: "foo1", scope: !3, file: !2, isDefinition: false, type: !18)
 
-; CHECK-NEXT: !15 = !{!4, !6}
+; CHECK-NEXT: !17 = !{!4, !6}
 ; CHECK-NOT: !DIDerivedType
 ; CHECK-NOT: !DISubprogram
 !17 = !{!15, !16}

diff  --git a/llvm/test/Assembler/diimportedentity.ll b/llvm/test/Assembler/diimportedentity.ll
index 6a0e1eb931c1a..a5c76afcca218 100644
--- a/llvm/test/Assembler/diimportedentity.ll
+++ b/llvm/test/Assembler/diimportedentity.ll
@@ -1,28 +1,34 @@
 ; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s
 ; RUN: verify-uselistorder %s
 
-; CHECK: !named = !{!0, !3, !4, !5, !5}
+; CHECK: !named = !{!0, !5, !6, !7, !7}
 !named = !{!0, !3, !4, !5, !6}
 
 !llvm.module.flags = !{!7}
 !llvm.dbg.cu = !{!1}
 
-; CHECK:      !0 = distinct !DISubprogram({{.*}})
-!0 = distinct !DISubprogram(name: "foo", isDefinition: true, unit: !1)
+; CHECK:      !0 = distinct !DISubprogram({{.*}}, type: !1{{.*}})
+!0 = distinct !DISubprogram(name: "foo", isDefinition: true, unit: !1, type: !8)
+!8 = !DISubroutineType(types: !9)
+!9 = !{null}
 
 !1 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang",
                              file: !2,
                              isOptimized: true, flags: "-O2",
                              splitDebugFilename: "abc.debug", emissionKind: 2)
 !2 = !DIFile(filename: "path/to/file", directory: "/path/to/dir")
-; CHECK: !3 = !DICompositeType({{.*}})
+; CHECK: !1 = !DISubroutineType(types: !2)
+; CHECK: !2 = !{null}
+; CHECK: !3 = distinct !DICompileUnit
+; CHECK: !4 = !DIFile
+; CHECK: !5 = !DICompositeType({{.*}})
 !3 = !DICompositeType(tag: DW_TAG_structure_type, name: "Class", size: 32, align: 32)
 
-; CHECK-NEXT: !4 = !DIImportedEntity(tag: DW_TAG_imported_module, name: "foo", scope: !0, entity: !1, file: !2, line: 7)
+; CHECK-NEXT: !6 = !DIImportedEntity(tag: DW_TAG_imported_module, name: "foo", scope: !0, entity: !3, file: !4, line: 7)
 !4 = !DIImportedEntity(tag: DW_TAG_imported_module, name: "foo", scope: !0,
                        entity: !1, file: !2, line: 7)
 
-; CHECK-NEXT: !5 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !0)
+; CHECK-NEXT: !7 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !0)
 !5 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !0)
 !6 = !DIImportedEntity(tag: DW_TAG_imported_module, name: "", scope: !0, entity: null,
                        line: 0)

diff  --git a/llvm/test/Assembler/dilexicalblock.ll b/llvm/test/Assembler/dilexicalblock.ll
index 77a8650830d4d..29cca5b9aa2b3 100644
--- a/llvm/test/Assembler/dilexicalblock.ll
+++ b/llvm/test/Assembler/dilexicalblock.ll
@@ -1,7 +1,7 @@
 ; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s
 ; RUN: verify-uselistorder %s
 
-; CHECK: !named = !{!0, !1, !2, !3, !4, !4, !5, !6, !7, !7, !8}
+; CHECK: !named = !{!0, !1, !2, !5, !6, !6, !7, !8, !9, !9, !10}
 !named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9, !10}
 
 !llvm.module.flags = !{!11}
@@ -12,21 +12,23 @@
                              isOptimized: true, flags: "-O2",
                              splitDebugFilename: "abc.debug", emissionKind: 2)
 !1 = !DIFile(filename: "path/to/file", directory: "/path/to/dir")
-!2 = distinct !DISubprogram(name: "foo", scope: !1, unit: !0)
+!2 = distinct !DISubprogram(name: "foo", scope: !1, unit: !0, type: !12)
+!12 = !DISubroutineType(types: !13)
+!13 = !{null}
 
-; CHECK: !3 = !DILexicalBlock(scope: !2, file: !1, line: 7, column: 35)
+; CHECK: !5 = !DILexicalBlock(scope: !2, file: !1, line: 7, column: 35)
 !3 = !DILexicalBlock(scope: !2, file: !1, line: 7, column: 35)
 
-; CHECK: !4 = !DILexicalBlock(scope: !2)
+; CHECK: !6 = !DILexicalBlock(scope: !2)
 !4 = !DILexicalBlock(scope: !2)
 !5 = !DILexicalBlock(scope: !2, file: null, line: 0, column: 0)
 
-; CHECK: !5 = !DILexicalBlockFile(scope: !3, file: !1, discriminator: 0)
-; CHECK: !6 = !DILexicalBlockFile(scope: !3, file: !1, discriminator: 1)
+; CHECK: !7 = !DILexicalBlockFile(scope: !5, file: !1, discriminator: 0)
+; CHECK: !8 = !DILexicalBlockFile(scope: !5, file: !1, discriminator: 1)
 !6 = !DILexicalBlockFile(scope: !3, file: !1, discriminator: 0)
 !7 = !DILexicalBlockFile(scope: !3, file: !1, discriminator: 1)
 
-; CHECK: !7 = !DILexicalBlockFile(scope: !3, discriminator: 7)
+; CHECK: !9 = !DILexicalBlockFile(scope: !5, discriminator: 7)
 !8 = !DILexicalBlockFile(scope: !3, discriminator: 7)
 !9 = !DILexicalBlockFile(scope: !3, file: null, discriminator: 7)
 !10 = distinct !{}

diff  --git a/llvm/test/Assembler/dilocalvariable-arg-large.ll b/llvm/test/Assembler/dilocalvariable-arg-large.ll
index 91cf0e2c00e71..e4bbdb1c480b4 100644
--- a/llvm/test/Assembler/dilocalvariable-arg-large.ll
+++ b/llvm/test/Assembler/dilocalvariable-arg-large.ll
@@ -1,20 +1,22 @@
 ; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s
 ; RUN: verify-uselistorder %s
 
-; CHECK: !named = !{!0, !3}
+; CHECK: !named = !{!0, !5}
 !named = !{!0, !3}
 
 !llvm.module.flags = !{!4}
 !llvm.dbg.cu = !{!1}
 
-!0 = distinct !DISubprogram(unit: !1)
+!0 = distinct !DISubprogram(unit: !1, type: !5)
 !1 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang",
                              file: !2,
                              isOptimized: true, flags: "-O2",
                              splitDebugFilename: "abc.debug", emissionKind: 2)
 !2 = !DIFile(filename: "path/to/file", directory: "/path/to/dir")
 
-; CHECK: !3 = !DILocalVariable(name: "foo", arg: 65535, scope: !0)
+; CHECK: !5 = !DILocalVariable(name: "foo", arg: 65535, scope: !0)
 !3 = !DILocalVariable(name: "foo", arg: 65535, scope: !0)
 
 !4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !DISubroutineType(types: !6)
+!6 = !{null}

diff  --git a/llvm/test/Assembler/dilocalvariable.ll b/llvm/test/Assembler/dilocalvariable.ll
index 067afaa2f3005..de8f93363f7d9 100644
--- a/llvm/test/Assembler/dilocalvariable.ll
+++ b/llvm/test/Assembler/dilocalvariable.ll
@@ -3,13 +3,13 @@
 
 @foo = global i32 0
 
-; CHECK: !named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9}
+; CHECK: !named = !{!0, !3, !4, !5, !6, !7, !8, !9, !10, !11}
 !named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9}
 
 !llvm.module.flags = !{!10}
 !llvm.dbg.cu = !{!1}
 
-!0 = distinct !DISubprogram(unit: !1)
+!0 = distinct !DISubprogram(unit: !1, type: !11)
 !1 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang",
                              file: !2,
                              isOptimized: true, flags: "-O2",
@@ -18,18 +18,20 @@
 !3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
 !4 = !DILocation(scope: !0)
 
-; CHECK: !5 = !DILocalVariable(name: "foo", arg: 3, scope: !0, file: !2, line: 7, type: !3, flags: DIFlagArtificial, align: 32)
-; CHECK: !6 = !DILocalVariable(name: "foo", scope: !0, file: !2, line: 7, type: !3, flags: DIFlagArtificial)
+; CHECK: !7 = !DILocalVariable(name: "foo", arg: 3, scope: !0, file: !4, line: 7, type: !5, flags: DIFlagArtificial, align: 32)
+; CHECK: !8 = !DILocalVariable(name: "foo", scope: !0, file: !4, line: 7, type: !5, flags: DIFlagArtificial)
 !5 = !DILocalVariable(name: "foo", arg: 3,
                       scope: !0, file: !2, line: 7, type: !3,
                       flags: DIFlagArtificial, align: 32)
 !6 = !DILocalVariable(name: "foo", scope: !0,
                       file: !2, line: 7, type: !3, flags: DIFlagArtificial)
 
-; CHECK: !7 = !DILocalVariable(arg: 1, scope: !0)
-; CHECK: !8 = !DILocalVariable(scope: !0)
+; CHECK: !9 = !DILocalVariable(arg: 1, scope: !0)
+; CHECK: !10 = !DILocalVariable(scope: !0)
 !7 = !DILocalVariable(scope: !0, arg: 1)
 !8 = !DILocalVariable(scope: !0)
 !9 = distinct !{}
 
 !10 = !{i32 2, !"Debug Info Version", i32 3}
+!11 = !DISubroutineType(types: !12)
+!12 = !{null}

diff  --git a/llvm/test/Assembler/dilocation.ll b/llvm/test/Assembler/dilocation.ll
index 4eb46e50597a7..5251366b09c76 100644
--- a/llvm/test/Assembler/dilocation.ll
+++ b/llvm/test/Assembler/dilocation.ll
@@ -1,40 +1,44 @@
 ; RUN: llvm-as < %s | llvm-dis | FileCheck %s
 ; RUN: verify-uselistorder %s
 
-; CHECK: !named = !{!0, !2, !3, !3, !4, !4, !5, !5, !6, !7, !8}
+; CHECK: !named = !{!0, !4, !5, !5, !6, !6, !7, !7, !8, !9, !10}
 !named = !{!0, !2, !3, !4, !5, !6, !7, !8, !9, !10, !11}
 
 !llvm.module.flags = !{!12}
 !llvm.dbg.cu = !{!1}
 
-; CHECK: !0 = distinct !DISubprogram(
-!0 = distinct !DISubprogram(unit: !1)
-; CHECK: !1 = distinct !DICompileUnit
+; CHECK: !0 = distinct !DISubprogram(scope: null, type: !1, spFlags: DISPFlagDefinition, unit: !3)
+!0 = distinct !DISubprogram(unit: !1, type: !13)
+; CHECK: !1 = !DISubroutineType(types: !2)
+; CHECK: !2 = !{null}
+; CHECK: !3 = distinct !DICompileUnit
 !1 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang",
                              file: !2,
                              isOptimized: true, flags: "-O2",
                              splitDebugFilename: "abc.debug", emissionKind: 2)
-; CHECK: !2 = !DIFile
+; CHECK: !4 = !DIFile
 !2 = !DIFile(filename: "path/to/file", directory: "/path/to/dir")
 
-; CHECK-NEXT: !3 = !DILocation(line: 3, column: 7, scope: !0)
+; CHECK: !5 = !DILocation(line: 3, column: 7, scope: !0)
 !3 = !DILocation(line: 3, column: 7, scope: !0)
 !4 = !DILocation(scope: !0, column: 7, line: 3)
 
-; CHECK-NEXT: !4 = !DILocation(line: 3, column: 7, scope: !0, inlinedAt: !3)
+; CHECK: !6 = !DILocation(line: 3, column: 7, scope: !0, inlinedAt: !5)
 !5 = !DILocation(scope: !0, inlinedAt: !3, column: 7, line: 3)
 !6 = !DILocation(column: 7, line: 3, scope: !0, inlinedAt: !3)
 
-; CHECK-NEXT: !5 = !DILocation(line: 0, scope: !0)
+; CHECK: !7 = !DILocation(line: 0, scope: !0)
 !7 = !DILocation(scope: !0)
 !8 = !DILocation(scope: !0, column: 0, line: 0)
 
-; CHECK-NEXT: !6 = !DILocation(line: 4294967295, column: 65535, scope: !0)
+; CHECK: !8 = !DILocation(line: 4294967295, column: 65535, scope: !0)
 !9 = !DILocation(line: 4294967295, column: 65535, scope: !0)
 
 !10 = !DILocation(scope: !0, column: 0, line: 0, isImplicitCode: true)
 !11 = !DILocation(scope: !0, column: 0, line: 1, isImplicitCode: false)
-; CHECK-NEXT: !7 = !DILocation(line: 0, scope: !0, isImplicitCode: true)
-; CHECK-NEXT: !8 = !DILocation(line: 1, scope: !0)
+; CHECK: !9 = !DILocation(line: 0, scope: !0, isImplicitCode: true)
+; CHECK: !10 = !DILocation(line: 1, scope: !0)
 
 !12 = !{i32 2, !"Debug Info Version", i32 3}
+!13 = !DISubroutineType(types: !14)
+!14 = !{null}

diff  --git a/llvm/test/Assembler/disubprogram.ll b/llvm/test/Assembler/disubprogram.ll
index 99a747d15e7dd..aa2ec67050d64 100644
--- a/llvm/test/Assembler/disubprogram.ll
+++ b/llvm/test/Assembler/disubprogram.ll
@@ -17,16 +17,16 @@ define void @_Z3foov() !dbg !9 {
 !5 = distinct !{}
 !6 = distinct !{}
 
-; CHECK: !7 = distinct !DISubprogram(scope: null, spFlags: DISPFlagDefinition, unit: !8)
-!7 = distinct !DISubprogram(unit: !8)
+; CHECK: !7 = distinct !DISubprogram(scope: null, type: !3, spFlags: DISPFlagDefinition, unit: !8)
+!7 = distinct !DISubprogram(unit: !8, type: !3)
 
 !8 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang",
                              file: !2,
                              isOptimized: true, flags: "-O2",
                              splitDebugFilename: "abc.debug", emissionKind: 2)
 
-; CHECK: !9 = distinct !DISubprogram(scope: null, spFlags: 0)
-!9 = distinct !DISubprogram(isDefinition: false)
+; CHECK: !9 = distinct !DISubprogram(scope: null, type: !3, spFlags: 0)
+!9 = distinct !DISubprogram(isDefinition: false, type: !3)
 
 ; CHECK: !10 = distinct !DISubprogram(name: "foo", linkageName: "_Zfoov", scope: !1, file: !2, line: 7, type: !3, scopeLine: 8, containingType: !4, virtualIndex: 10, thisAdjustment: 3, flags: DIFlagPrototyped | DIFlagNoReturn, spFlags: DISPFlagPureVirtual | DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !8, templateParams: !5, declaration: !9, retainedNodes: !6)
 !10 = distinct !DISubprogram(name: "foo", linkageName: "_Zfoov", scope: !1,

diff  --git a/llvm/test/Assembler/metadata.ll b/llvm/test/Assembler/metadata.ll
index b1fb720eb31f9..6ad78c21c33ac 100644
--- a/llvm/test/Assembler/metadata.ll
+++ b/llvm/test/Assembler/metadata.ll
@@ -47,10 +47,12 @@ define void @test_attachment_name() {
 ; CHECK: [[M1]] = distinct !DISubprogram
 ; CHECK: [[M4]] = distinct !{}
 
+!8 = !{null}
+!9 = !DISubroutineType(types: !8)
 !llvm.module.flags = !{!7}
 !llvm.dbg.cu = !{!5}
 !0 = !DILocation(line: 662302, column: 26, scope: !1)
-!1 = distinct !DISubprogram(name: "foo", isDefinition: true, unit: !5)
+!1 = distinct !DISubprogram(name: "foo", isDefinition: true, type: !9, unit: !5)
 !2 = distinct !{}
 !3 = distinct !{}
 !4 = distinct !{}

diff  --git a/llvm/test/Bitcode/DILocalVariable-explicit-tags.ll b/llvm/test/Bitcode/DILocalVariable-explicit-tags.ll
index a42884cc42728..20dc66cd8349b 100644
--- a/llvm/test/Bitcode/DILocalVariable-explicit-tags.ll
+++ b/llvm/test/Bitcode/DILocalVariable-explicit-tags.ll
@@ -1,9 +1,11 @@
-; Bitcode compiled with 3.7_rc2.  3.7 had redundant (but mandatory) tag fields
-; on DILocalVariable.
+; Bitcode originally compiled with 3.7_rc2.  3.7 had redundant (but
+; mandatory) tag fields on DILocalVariable.
 ;
 ; RUN: llvm-dis < %s.bc -o - | llvm-as | llvm-dis | FileCheck %s
 
-; CHECK: ![[SP:[0-9]+]] = distinct !DISubprogram(name: "foo",{{.*}} retainedNodes: ![[VARS:[0-9]+]]
+; CHECK: ![[SP:[0-9]+]] = distinct !DISubprogram(name: "foo",{{.*}} type: ![[TYPE:[0-9]+]],{{.*}} retainedNodes: ![[VARS:[0-9]+]]
+; CHECK: ![[TYPE]] = !DISubroutineType(types: ![[ARGS:[0-9]+]])
+; CHECK: ![[ARGS]] = !{null}
 ; CHECK: ![[VARS]] = !{![[PARAM:[0-9]+]], ![[AUTO:[0-9]+]]}
 ; CHECK: ![[PARAM]] = !DILocalVariable(name: "param", arg: 1, scope: ![[SP]])
 ; CHECK: ![[AUTO]]  = !DILocalVariable(name: "auto", scope: ![[SP]])
@@ -13,10 +15,12 @@
 !llvm.module.flags = !{!6}
 !llvm.dbg.cu = !{!4}
 
-!0 = distinct !DISubprogram(name: "foo", scope: null, isLocal: false, isDefinition: true, isOptimized: false, retainedNodes: !1)
+!0 = distinct !DISubprogram(name: "foo", scope: null, type: !7, isLocal: false, isDefinition: true, isOptimized: false, unit: !4, retainedNodes: !1)
 !1 = !{!2, !3}
-!2 = !DILocalVariable(tag: DW_TAG_arg_variable, name: "param", arg: 1, scope: !0)
-!3 = !DILocalVariable(tag: DW_TAG_auto_variable, name: "auto", scope: !0)
-!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !5, subprograms: !{!0})
+!2 = !DILocalVariable(name: "param", arg: 1, scope: !0)
+!3 = !DILocalVariable(name: "auto", scope: !0)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !5)
 !5 = !DIFile(filename: "source.c", directory: "/dir")
 !6 = !{i32 1, !"Debug Info Version", i32 3}
+!7 = !DISubroutineType(types: !8)
+!8 = !{null}

diff  --git a/llvm/test/Bitcode/DILocalVariable-explicit-tags.ll.bc b/llvm/test/Bitcode/DILocalVariable-explicit-tags.ll.bc
index b134f60a12915..99d1044ae43f1 100644
Binary files a/llvm/test/Bitcode/DILocalVariable-explicit-tags.ll.bc and b/llvm/test/Bitcode/DILocalVariable-explicit-tags.ll.bc 
diff er

diff  --git a/llvm/test/Bitcode/DISubprogram-distinct-definitions.ll b/llvm/test/Bitcode/DISubprogram-distinct-definitions.ll
index 9d141d52de1c8..8c8d09cf95b53 100644
--- a/llvm/test/Bitcode/DISubprogram-distinct-definitions.ll
+++ b/llvm/test/Bitcode/DISubprogram-distinct-definitions.ll
@@ -1,14 +1,17 @@
 ; RUN: llvm-dis < %s.bc | FileCheck %s
-; Check that subprogram definitions are correctly upgraded to 'distinct'.
-; Bitcode compiled with llvm-as version 3.7.
+; Check that subprogram definitions are encoded as 'distinct'.
 
 define void @f() !dbg !3 { ret void }
 
 !llvm.module.flags = !{!4}
 !llvm.dbg.cu = !{!0}
-!0 = distinct !DICompileUnit(language: 12, file: !1, subprograms: !{!3})
+!0 = distinct !DICompileUnit(language: 12, file: !1)
 !1 = !DIFile(filename: "path/to/file", directory: "/path/to/dir")
 
-; CHECK: = distinct !DISubprogram({{.*}} DISPFlagDefinition
-!3 = !DISubprogram(name: "foo", isDefinition: true)
+; CHECK: = distinct !DISubprogram({{.*}} type: ![[TYPE:[0-9]+]],{{.*}} DISPFlagDefinition
+; CHECK: ![[TYPE]] = !DISubroutineType(types: ![[ARGS:[0-9]+]])
+; CHECK: ![[ARGS]] = !{null}
+!3 = distinct !DISubprogram(name: "foo", type: !5, isDefinition: true, unit: !0)
 !4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !DISubroutineType(types: !6)
+!6 = !{null}

diff  --git a/llvm/test/Bitcode/DISubprogram-distinct-definitions.ll.bc b/llvm/test/Bitcode/DISubprogram-distinct-definitions.ll.bc
index edf31706dad72..3c59f67640895 100644
Binary files a/llvm/test/Bitcode/DISubprogram-distinct-definitions.ll.bc and b/llvm/test/Bitcode/DISubprogram-distinct-definitions.ll.bc 
diff er

diff  --git a/llvm/test/Bitcode/DISubprogram-v4.ll b/llvm/test/Bitcode/DISubprogram-v4.ll
index 9e5caecd7361a..79d8beb3575c4 100644
--- a/llvm/test/Bitcode/DISubprogram-v4.ll
+++ b/llvm/test/Bitcode/DISubprogram-v4.ll
@@ -18,14 +18,14 @@ define void @_Z3foov() !dbg !9 {
 !5 = distinct !{}
 !6 = distinct !{}
 
-; CHECK: !7 = distinct !DISubprogram(scope: null, spFlags: DISPFlagDefinition, unit: !8)
-!7 = distinct !DISubprogram(unit: !8)
+; CHECK: !7 = distinct !DISubprogram(scope: null, type: !3, spFlags: DISPFlagDefinition, unit: !8)
+!7 = distinct !DISubprogram(type: !3, unit: !8)
 
 !8 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang",
                              file: !2, isOptimized: true, flags: "-O2")
 
-; CHECK: !9 = distinct !DISubprogram(scope: null, spFlags: 0)
-!9 = distinct !DISubprogram(isDefinition: false)
+; CHECK: !9 = distinct !DISubprogram(scope: null, type: !3, spFlags: 0)
+!9 = distinct !DISubprogram(type: !3, isDefinition: false)
 
 ; CHECK: !10 = distinct !DISubprogram({{.*}}, spFlags: DISPFlagPureVirtual | DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized,
 !10 = distinct !DISubprogram(name: "foo", linkageName: "_Zfoov", scope: !1,

diff  --git a/llvm/test/Bitcode/DISubprogram-v4.ll.bc b/llvm/test/Bitcode/DISubprogram-v4.ll.bc
index 41bbcf874ac14..fc1dc770fbed5 100644
Binary files a/llvm/test/Bitcode/DISubprogram-v4.ll.bc and b/llvm/test/Bitcode/DISubprogram-v4.ll.bc 
diff er

diff  --git a/llvm/test/Bitcode/debug-loc-again.ll b/llvm/test/Bitcode/debug-loc-again.ll
index d92720caa9262..8cef5716830b4 100644
--- a/llvm/test/Bitcode/debug-loc-again.ll
+++ b/llvm/test/Bitcode/debug-loc-again.ll
@@ -31,6 +31,8 @@ entry:
 
 !0 = !{i32 2, !"Debug Info Version", i32 3}
 !1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !DIFile(filename: "f", directory: "/d"))
-!2 = distinct !DISubprogram(name: "foo", unit: !1)
+!2 = distinct !DISubprogram(name: "foo", type: !5, unit: !1)
 !3 = !DILocation(line: 1, scope: !2)
 !4 = !DILocation(line: 2, scope: !2)
+!5 = !DISubroutineType(types: !6)
+!6 = !{null}

diff  --git a/llvm/test/Bitcode/dityperefs-3.8.ll b/llvm/test/Bitcode/dityperefs-3.8.ll
index b14bcf7b04a78..7f413a06ddb3a 100644
--- a/llvm/test/Bitcode/dityperefs-3.8.ll
+++ b/llvm/test/Bitcode/dityperefs-3.8.ll
@@ -1,5 +1,4 @@
 ; RUN: llvm-dis < %s.bc | FileCheck %s
-; RUN: verify-uselistorder %s.bc
 
 ; Establish a stable order.
 !named = !{!0, !1, !2, !3, !4, !6, !7, !8, !9, !10, !11, !12, !13, !14, !15, !16}

diff  --git a/llvm/test/CodeGen/AArch64/addrsig-macho.ll b/llvm/test/CodeGen/AArch64/addrsig-macho.ll
index 910f635467bab..677e93a8c7301 100644
--- a/llvm/test/CodeGen/AArch64/addrsig-macho.ll
+++ b/llvm/test/CodeGen/AArch64/addrsig-macho.ll
@@ -145,10 +145,10 @@ attributes #0 = { noinline }
 !2 = !{i32 7, !"Dwarf Version", i32 4}
 !3 = !{i32 2, !"Debug Info Version", i32 3}
 
-!4 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0)
+!4 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, type: !10, unit: !0)
 !5 = !DILocation(line: 0, scope: !4)
 !6 = !DILocalVariable(scope: !7)
-!7 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0)
+!7 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, type: !10, unit: !0)
 !8 = !DILocation(line: 0, scope: !7, inlinedAt: !5)
 !9 = distinct !DISubprogram(scope: null, file: !1, line: 1, type: !10, unit: !0)
 !10 = !DISubroutineType(types: !{})

diff  --git a/llvm/test/CodeGen/AArch64/arm64-instruction-mix-remarks.ll b/llvm/test/CodeGen/AArch64/arm64-instruction-mix-remarks.ll
index 2816f91df44dd..e41c9af848484 100644
--- a/llvm/test/CodeGen/AArch64/arm64-instruction-mix-remarks.ll
+++ b/llvm/test/CodeGen/AArch64/arm64-instruction-mix-remarks.ll
@@ -60,12 +60,14 @@ else:
   ret i32 %res.2, !dbg !6
 }
 !llvm.dbg.cu = !{!0}
+!7 = !{null}
+!8 = !DISubroutineType(types: !7)
 !llvm.module.flags = !{!2}
 
 !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1)
 !1 = !DIFile(filename: "arm64-instruction-mix-remarks.ll", directory: "")
 !2 = !{i32 2, !"Debug Info Version", i32 3}
-!3 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 5, scopeLine: 5, unit: !0)
+!3 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 5, scopeLine: 5, type: !8, unit: !0)
 !4 = distinct !DILocation(line: 10, column: 10, scope: !3)
 !5 = distinct !DILocation(line: 20, column: 20, scope: !3)
 !6 = distinct !DILocation(line: 30, column: 30, scope: !3)

diff  --git a/llvm/test/CodeGen/AArch64/arm64-opt-remarks-lazy-bfi.ll b/llvm/test/CodeGen/AArch64/arm64-opt-remarks-lazy-bfi.ll
index 08c314e538734..6654b58d306eb 100644
--- a/llvm/test/CodeGen/AArch64/arm64-opt-remarks-lazy-bfi.ll
+++ b/llvm/test/CodeGen/AArch64/arm64-opt-remarks-lazy-bfi.ll
@@ -123,5 +123,7 @@ define void @empty_func() nounwind ssp !dbg !3 !prof !4 {
 !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1)
 !1 = !DIFile(filename: "arm64-summary-remarks.ll", directory: "")
 !2 = !{i32 2, !"Debug Info Version", i32 3}
-!3 = distinct !DISubprogram(name: "empty_func", scope: !1, file: !1, line: 5, scopeLine: 5, unit: !0)
+!3 = distinct !DISubprogram(name: "empty_func", scope: !1, file: !1, line: 5, scopeLine: 5, type: !5, unit: !0)
 !4 = !{!"function_entry_count", i64 33}
+!5 = !DISubroutineType(types: !6)
+!6 = !{null}

diff  --git a/llvm/test/CodeGen/AArch64/arm64-summary-remarks.ll b/llvm/test/CodeGen/AArch64/arm64-summary-remarks.ll
index 70e7fdffd63db..34b8f8db09913 100644
--- a/llvm/test/CodeGen/AArch64/arm64-summary-remarks.ll
+++ b/llvm/test/CodeGen/AArch64/arm64-summary-remarks.ll
@@ -7,9 +7,11 @@ define void @empty_func() nounwind ssp !dbg !3 {
 }
 
 !llvm.dbg.cu = !{!0}
+!4 = !{null}
+!5 = !DISubroutineType(types: !4)
 !llvm.module.flags = !{!2}
 
 !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1)
 !1 = !DIFile(filename: "arm64-summary-remarks.ll", directory: "")
 !2 = !{i32 2, !"Debug Info Version", i32 3}
-!3 = distinct !DISubprogram(name: "empty_func", scope: !1, file: !1, line: 5, scopeLine: 5, unit: !0)
+!3 = distinct !DISubprogram(name: "empty_func", scope: !1, file: !1, line: 5, scopeLine: 5, type: !5, unit: !0)

diff  --git a/llvm/test/CodeGen/AArch64/fast-isel-dbg.ll b/llvm/test/CodeGen/AArch64/fast-isel-dbg.ll
index ac6fa71e9a9e4..047d1ebc70b91 100644
--- a/llvm/test/CodeGen/AArch64/fast-isel-dbg.ll
+++ b/llvm/test/CodeGen/AArch64/fast-isel-dbg.ll
@@ -15,13 +15,15 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) #0
 attributes #0 = { nounwind readnone speculatable }
 
 !llvm.dbg.cu = !{!0}
+!8 = !{null}
+!9 = !DISubroutineType(types: !8)
 !llvm.module.flags = !{!2, !3}
 
 !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly)
 !1 = !DIFile(filename: "fast-isel-dbg.ll", directory: "/")
 !2 = !{i32 2, !"Dwarf Version", i32 4}
 !3 = !{i32 2, !"Debug Info Version", i32 3}
-!4 = distinct !DISubprogram(name: "func", scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0)
+!4 = distinct !DISubprogram(name: "func", scope: null, isLocal: false, isDefinition: true, isOptimized: false, type: !9, unit: !0)
 !5 = !DILocalVariable(name: "a", arg: 1, scope: !4, file: !1, line: 17, type: !6)
 !6 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
 !7 = !DILocation(line: 17, scope: !4)

diff  --git a/llvm/test/CodeGen/AArch64/instr-ref-ldv.ll b/llvm/test/CodeGen/AArch64/instr-ref-ldv.ll
index f12fe1f8c0c0d..7d9b495c89dc8 100644
--- a/llvm/test/CodeGen/AArch64/instr-ref-ldv.ll
+++ b/llvm/test/CodeGen/AArch64/instr-ref-ldv.ll
@@ -48,6 +48,8 @@ cleanup:                                          ; preds = %_ZNK4llvm3opt7ArgLi
   %2 = phi i1 [ %call13, %cleanup ], [ %Default, %_ZNK4llvm3opt7ArgList17getLastArgNoClaimIJNS0_12OptSpecifierES3_EEEPNS0_3ArgEDpT_.exit ], [ %Default, %_ZNK4llvm3opt7ArgList17getLastArgNoClaimIJNS0_12OptSpecifierES3_EEEPNS0_3ArgEDpT_.exit.thread ]
   ret i1 %2, !dbg !9480
 }
+!9531 = !{null}
+!9532 = !DISubroutineType(types: !9531)
 !llvm.module.flags = !{!2, !6}
 !llvm.dbg.cu = !{!7}
 !2 = !{i32 2, !"Debug Info Version", i32 3}
@@ -55,12 +57,12 @@ cleanup:                                          ; preds = %_ZNK4llvm3opt7ArgLi
 !7 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !8, emissionKind: FullDebug, sdk: "MacOSX15.3.sdk")
 !8 = !DIFile(filename: "/Users/shubhamrastogi/Development/llvm-project-instr-ref/llvm-project/llvm/lib/Option/ArgList.cpp", directory: "/Users/shubhamrastogi/Development/llvm-project-instr-ref/llvm-project/build-instr-ref-stage2", checksumkind: CSK_MD5, checksum: "a3198e8ace679c7b1581a26b5583c658")
 !3116 = distinct !DICompositeType(tag: DW_TAG_class_type, size: 32)
-!9383 = distinct !DISubprogram(unit: !7, flags: DIFlagArtificial | DIFlagObjectPointer)
+!9383 = distinct !DISubprogram(type: !9532, unit: !7, flags: DIFlagArtificial | DIFlagObjectPointer)
 !9391 = distinct !DILexicalBlock(scope: !9383, line: 80, column: 12)
 !9393 = !DILocation(scope: !9391)
 !9440 = distinct !DILexicalBlock(scope: !9441, line: 269, column: 5)
 !9441 = distinct !DILexicalBlock(scope: !9442, line: 269, column: 5)
-!9442 = distinct !DISubprogram(unit: !7, retainedNodes: !9450)
+!9442 = distinct !DISubprogram(type: !9532, unit: !7, retainedNodes: !9450)
 !9450 = !{}
 !9452 = !DILocalVariable(scope: !9442, type: !3116)
 !9478 = distinct !DILocation(scope: !9391)

diff  --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/trunc-brc.ll b/llvm/test/CodeGen/AMDGPU/GlobalISel/trunc-brc.ll
index 8e2ed63adb2a5..142cbe91a6e6e 100644
--- a/llvm/test/CodeGen/AMDGPU/GlobalISel/trunc-brc.ll
+++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/trunc-brc.ll
@@ -389,10 +389,12 @@ define void @v_trunc_i1024_to_i512(ptr addrspace(1) %src, ptr addrspace(1) %dst)
 }
 
 !llvm.dbg.cu = !{!0}
+!5 = !{null}
+!6 = !DISubroutineType(types: !5)
 !llvm.module.flags = !{!2}
 
 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1)
 !1 = !DIFile(filename: ".", directory: ".")
 !2 = !{i32 2, !"Debug Info Version", i32 3}
-!3 = distinct !DISubprogram(name: "trunc", scope: !1, file: !1, line: 1, unit: !0)
+!3 = distinct !DISubprogram(name: "trunc", scope: !1, file: !1, line: 1, type: !6, unit: !0)
 !4 = !DILocation(line: 1, scope: !3)

diff  --git a/llvm/test/CodeGen/AMDGPU/opencl-printf-unsupported.ll b/llvm/test/CodeGen/AMDGPU/opencl-printf-unsupported.ll
index 34e81e36aefd8..37ba7bc8f54f6 100644
--- a/llvm/test/CodeGen/AMDGPU/opencl-printf-unsupported.ll
+++ b/llvm/test/CodeGen/AMDGPU/opencl-printf-unsupported.ll
@@ -69,4 +69,6 @@ declare i32 @printf(ptr addrspace(4), ...)
 !2 = !{i32 2, !"Dwarf Version", i32 4}
 !3 = !{i32 2, !"Debug Info Version", i32 3}
 !4 = !DILocation(line: 1, column: 42, scope: !5)
-!5 = distinct !DISubprogram(name: "arst", scope: null, file: !1, line: 1, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: false, unit: !0)
+!5 = distinct !DISubprogram(name: "arst", scope: null, file: !1, line: 1, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: false, unit: !0, type: !6)
+!6 = !DISubroutineType(types: !7)
+!7 = !{null}

diff  --git a/llvm/test/CodeGen/AMDGPU/sched-crash-dbg-value.mir b/llvm/test/CodeGen/AMDGPU/sched-crash-dbg-value.mir
index eabbfca91ca55..89eb545cec023 100644
--- a/llvm/test/CodeGen/AMDGPU/sched-crash-dbg-value.mir
+++ b/llvm/test/CodeGen/AMDGPU/sched-crash-dbg-value.mir
@@ -165,15 +165,17 @@
   !3 = !{}
   !4 = !{i32 0, i32 256}
   !5 = !DILocalVariable(name: "bar", scope: !6, file: !1, line: 102, type: !7)
-  !6 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 81, isLocal: false, isDefinition: true, scopeLine: 86, flags: DIFlagPrototyped, isOptimized: true, unit: !0)
+  !6 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 81, isLocal: false, isDefinition: true, scopeLine: 86, flags: DIFlagPrototyped, isOptimized: true, type: !10, unit: !0)
   !7 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float)
   !8 = !DILocation(line: 102, column: 8, scope: !6)
+  !9 = !{null}
+  !10 = !DISubroutineType(types: !9)
 
 ...
 ---
 
 # CHECK: name: sched_dbg_value_crash
-# CHECK: DBG_VALUE %99, $noreg, !5, !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef), debug-location !8
+# CHECK: DBG_VALUE %99, $noreg, !5, !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef), debug-location !10
 
 name:            sched_dbg_value_crash
 alignment:       1

diff  --git a/llvm/test/CodeGen/AMDGPU/vi-removed-intrinsics.ll b/llvm/test/CodeGen/AMDGPU/vi-removed-intrinsics.ll
index f99c3f8306ac1..deadd358236bd 100644
--- a/llvm/test/CodeGen/AMDGPU/vi-removed-intrinsics.ll
+++ b/llvm/test/CodeGen/AMDGPU/vi-removed-intrinsics.ll
@@ -21,4 +21,6 @@ attributes #1 = { nounwind }
 !2 = !{i32 2, !"Dwarf Version", i32 4}
 !3 = !{i32 2, !"Debug Info Version", i32 3}
 !4 = !DILocation(line: 1, column: 42, scope: !5)
-!5 = distinct !DISubprogram(name: "rsq_legacy_f32", scope: null, file: !1, line: 1, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: false, unit: !0)
+!5 = distinct !DISubprogram(name: "rsq_legacy_f32", scope: null, file: !1, line: 1, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: false, unit: !0, type: !6)
+!6 = !DISubroutineType(types: !7)
+!7 = !{null}

diff  --git a/llvm/test/CodeGen/MIR/X86/stack-object-debug-info.mir b/llvm/test/CodeGen/MIR/X86/stack-object-debug-info.mir
index 9cc25d8882bf8..416f8cfbaed0a 100644
--- a/llvm/test/CodeGen/MIR/X86/stack-object-debug-info.mir
+++ b/llvm/test/CodeGen/MIR/X86/stack-object-debug-info.mir
@@ -36,12 +36,14 @@
   !2 = !{}
   !3 = !{i32 1, !"Debug Info Version", i32 3}
   !4 = !DILocalVariable(name: "x", scope: !5, file: !1, line: 16, type: !8)
-  !5 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0)
+  !5 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, type: !12, unit: !0)
   !6 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)
   !7 = !DILocation(line: 0, scope: !5)
   !8 = !DICompositeType(tag: DW_TAG_array_type, baseType: !6, size: 2048, align: 8, elements: !9)
   !9 = !{!10}
   !10 = !DISubrange(count: 256)
+  !11 = !{null}
+  !12 = !DISubroutineType(types: !11)
 ...
 ---
 name:            foo
@@ -53,7 +55,7 @@ frameInfo:
 # CHECK:  - { id: 0, name: y.i, type: default, offset: 0, size: 256, alignment: 16,
 # CHECK-NEXT: callee-saved-register: '', callee-saved-restored: true,
 # CHECK-NEXT: debug-info-variable: '!4', debug-info-expression: '!DIExpression()',
-# CHECK-NEXT: debug-info-location: '!10' }
+# CHECK-NEXT: debug-info-location: '!12' }
 stack:
   - { id: 0, name: y.i, offset: 0, size: 256, alignment: 16,
       debug-info-variable: '!4', debug-info-expression: '!DIExpression()',

diff  --git a/llvm/test/CodeGen/WebAssembly/lower-em-sjlj-debuginfo.ll b/llvm/test/CodeGen/WebAssembly/lower-em-sjlj-debuginfo.ll
index bab8403aa7b9e..f51edc0373220 100644
--- a/llvm/test/CodeGen/WebAssembly/lower-em-sjlj-debuginfo.ll
+++ b/llvm/test/CodeGen/WebAssembly/lower-em-sjlj-debuginfo.ll
@@ -45,12 +45,14 @@ declare void @foo()
 declare i32 @setjmp(ptr) #0
 
 !llvm.dbg.cu = !{!2}
+!9 = !{null}
+!10 = !DISubroutineType(types: !9)
 !llvm.module.flags = !{!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_info0", unit:!2, file: !1, line: 1)
+!3 = distinct !DISubprogram(name: "setjmp_debug_info0", type: !10, unit:!2, file: !1, line: 1)
 !4 = !DILocation(line:2, scope: !3)
 !5 = !DILocation(line:3, scope: !3)
 !6 = !DILocation(line:4, scope: !3)

diff  --git a/llvm/test/CodeGen/X86/basic-block-sections-clusters-error.ll b/llvm/test/CodeGen/X86/basic-block-sections-clusters-error.ll
index eb0a14b2820b4..f4992b7a00775 100644
--- a/llvm/test/CodeGen/X86/basic-block-sections-clusters-error.ll
+++ b/llvm/test/CodeGen/X86/basic-block-sections-clusters-error.ll
@@ -106,5 +106,6 @@ define i32 @dummy2(i32 %x, i32 %y, i32 %z) !dbg !4 {
 !1 = !DIFile(filename: "test_dir/test_file", directory: "test_dir")
 !2 = !{i32 7, !"Dwarf Version", i32 5}
 !3 = !{i32 2, !"Debug Info Version", i32 3}
-!4 = distinct !DISubprogram(name: "dummy1", scope: !1, unit: !0)
-
+!4 = distinct !DISubprogram(name: "dummy1", scope: !1, unit: !0, type: !5)
+!5 = !DISubroutineType(types: !6)
+!6 = !{null}

diff  --git a/llvm/test/CodeGen/X86/basic-block-sections-module1.ll b/llvm/test/CodeGen/X86/basic-block-sections-module1.ll
index c719b7732648b..b1750b780ab04 100644
--- a/llvm/test/CodeGen/X86/basic-block-sections-module1.ll
+++ b/llvm/test/CodeGen/X86/basic-block-sections-module1.ll
@@ -54,13 +54,15 @@ define dso_local i32 @test(i32 noundef %0) #0 !dbg !10 {
 }
 
 !llvm.dbg.cu = !{!0}
+!11 = !{null}
+!12 = !DISubroutineType(types: !11)
 !llvm.module.flags = !{!2, !3}
 
 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1)
 !1 = !DIFile(filename: "/path/to/dir/test_filename", directory: "/path/to/dir")
 !2 = !{i32 7, !"Dwarf Version", i32 5}
 !3 = !{i32 2, !"Debug Info Version", i32 3}
-!10 = distinct !DISubprogram(name: "test", scope: !1, unit: !0)
+!10 = distinct !DISubprogram(name: "test", scope: !1, type: !12, unit: !0)
 
 ;; Check that the split section is created when using the correct module name, or no module name.
 ;

diff  --git a/llvm/test/CodeGen/X86/basic-block-sections-module2.ll b/llvm/test/CodeGen/X86/basic-block-sections-module2.ll
index 44e7d2219170c..c218ff9bb23af 100644
--- a/llvm/test/CodeGen/X86/basic-block-sections-module2.ll
+++ b/llvm/test/CodeGen/X86/basic-block-sections-module2.ll
@@ -95,6 +95,8 @@ define dso_local i32 @test5(i32 noundef %0) #0 {
 }
 
 !llvm.dbg.cu = !{!0, !1, !2, !3}
+!14 = !{null}
+!15 = !DISubroutineType(types: !14)
 !llvm.module.flags = !{!8, !9}
 
 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !4)
@@ -107,10 +109,10 @@ define dso_local i32 @test5(i32 noundef %0) #0 {
 !7 = !DIFile(filename: "/test_dirname4/test_filename4", directory: "/test_dirname4")
 !8 = !{i32 7, !"Dwarf Version", i32 5}
 !9 = !{i32 2, !"Debug Info Version", i32 3}
-!10 = distinct !DISubprogram(name: "test1", scope: !4, unit: !0)
-!11 = distinct !DISubprogram(name: "test2", scope: !5, unit: !1)
-!12 = distinct !DISubprogram(name: "test3", scope: !6, unit: !2)
-!13 = distinct !DISubprogram(name: "test4", scope: !7, unit: !3)
+!10 = distinct !DISubprogram(name: "test1", scope: !4, type: !15, unit: !0)
+!11 = distinct !DISubprogram(name: "test2", scope: !5, type: !15, unit: !1)
+!12 = distinct !DISubprogram(name: "test3", scope: !6, type: !15, unit: !2)
+!13 = distinct !DISubprogram(name: "test4", scope: !7, type: !15, unit: !3)
 
 ;; Check that the split section is created when using the correct module name, or no module name.
 ;

diff  --git a/llvm/test/CodeGen/X86/fixed-stack-di-mir.ll b/llvm/test/CodeGen/X86/fixed-stack-di-mir.ll
index a2f6ef025da56..6c1d2bc34e5db 100644
--- a/llvm/test/CodeGen/X86/fixed-stack-di-mir.ll
+++ b/llvm/test/CodeGen/X86/fixed-stack-di-mir.ll
@@ -15,7 +15,7 @@ entry:
 ; CHECK: id: 0
 ; CHECK: debug-info-variable: '!3'
 ; CHECK: debug-info-expression: '!DIExpression()'
-; CHECK: debug-info-location: '!5'
+; CHECK: debug-info-location: '!7'
   unreachable
 }
 
@@ -28,5 +28,7 @@ attributes #0 = { nounwind readnone speculatable }
 !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: !6)
 !5 = !DILocation(line: 42, column: 85, scope: !4)
+!6 = !DISubroutineType(types: !7)
+!7 = !{null}

diff  --git a/llvm/test/CodeGen/X86/pr57673.ll b/llvm/test/CodeGen/X86/pr57673.ll
index 4cb8450e85c25..0071ada715afb 100644
--- a/llvm/test/CodeGen/X86/pr57673.ll
+++ b/llvm/test/CodeGen/X86/pr57673.ll
@@ -38,7 +38,7 @@ define void @foo() {
   ; NORMAL-NEXT: {{  $}}
   ; NORMAL-NEXT:   [[MOVUPSrm:%[0-9]+]]:vr128 = MOVUPSrm %stack.1.i, 1, $noreg, 40, $noreg :: (load (s128) from %ir.i4, align 8)
   ; NORMAL-NEXT:   MOVUPSmr $noreg, 1, $noreg, 0, $noreg, killed [[MOVUPSrm]] :: (store (s128) into `ptr null`, align 8)
-  ; NORMAL-NEXT:   DBG_VALUE_LIST !3, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_plus_uconst, 40, DW_OP_stack_value), %stack.1.i, %stack.1.i, debug-location !8
+  ; NORMAL-NEXT:   DBG_VALUE_LIST !3, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_plus_uconst, 40, DW_OP_stack_value), %stack.1.i, %stack.1.i, debug-location !10
   ; NORMAL-NEXT:   [[MOVUPSrm1:%[0-9]+]]:vr128 = MOVUPSrm %stack.1.i, 1, $noreg, 40, $noreg :: (load (s128) from %ir.i6, align 8)
   ; NORMAL-NEXT:   MOVUPSmr $noreg, 1, $noreg, 0, $noreg, killed [[MOVUPSrm1]] :: (store (s128) into `ptr null`, align 8)
   ; NORMAL-NEXT: {{  $}}
@@ -78,7 +78,7 @@ define void @foo() {
   ; INSTRREF-NEXT: {{  $}}
   ; INSTRREF-NEXT:   [[MOVUPSrm:%[0-9]+]]:vr128 = MOVUPSrm %stack.1.i, 1, $noreg, 40, $noreg :: (load (s128) from %ir.i4, align 8)
   ; INSTRREF-NEXT:   MOVUPSmr $noreg, 1, $noreg, 0, $noreg, killed [[MOVUPSrm]] :: (store (s128) into `ptr null`, align 8)
-  ; INSTRREF-NEXT:   DBG_VALUE_LIST !3, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_plus_uconst, 40, DW_OP_stack_value), %stack.1.i, %stack.1.i, debug-location !8
+  ; INSTRREF-NEXT:   DBG_VALUE_LIST !3, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_plus_uconst, 40, DW_OP_stack_value), %stack.1.i, %stack.1.i, debug-location !10
   ; INSTRREF-NEXT:   [[MOVUPSrm1:%[0-9]+]]:vr128 = MOVUPSrm %stack.1.i, 1, $noreg, 40, $noreg :: (load (s128) from %ir.i6, align 8)
   ; INSTRREF-NEXT:   MOVUPSmr $noreg, 1, $noreg, 0, $noreg, killed [[MOVUPSrm1]] :: (store (s128) into `ptr null`, align 8)
   ; INSTRREF-NEXT: {{  $}}
@@ -131,6 +131,8 @@ declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)
 declare void @llvm.dbg.value(metadata, metadata, metadata)
 
 !llvm.dbg.cu = !{!0}
+!10 = !{null}
+!11 = !DISubroutineType(types: !10)
 !llvm.module.flags = !{!2}
 
 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug)
@@ -138,7 +140,7 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
 !2 = !{i32 2, !"Debug Info Version", i32 3}
 !3 = !{!"function_entry_count", i64 2423}
 !4 = !DILocalVariable(name: "r", scope: !5, file: !6, line: 93)
-!5 = distinct !DISubprogram(name: "c", scope: !7, file: !6, line: 92, spFlags: DISPFlagDefinition, unit: !0)
+!5 = distinct !DISubprogram(name: "c", scope: !7, file: !6, line: 92, spFlags: DISPFlagDefinition, type: !11, unit: !0)
 !6 = !DIFile(filename: "a", directory: "/proc/self/cwd")
 !7 = !DINamespace(name: "u", scope: !8)
 !8 = !DINamespace(name: "s", scope: null)

diff  --git a/llvm/test/CodeGen/X86/select-optimize.ll b/llvm/test/CodeGen/X86/select-optimize.ll
index b8f7f7578a3d1..dd7e8a84de66c 100644
--- a/llvm/test/CodeGen/X86/select-optimize.ll
+++ b/llvm/test/CodeGen/X86/select-optimize.ll
@@ -534,6 +534,8 @@ declare void @llvm.lifetime.end.p0(ptr nocapture)
 
 declare void @free(ptr nocapture)
 
+!29 = !{null}
+!30 = !DISubroutineType(types: !29)
 !llvm.module.flags = !{!0, !26, !27}
 !0 = !{i32 1, !"ProfileSummary", !1}
 !1 = !{!2, !3, !4, !5, !6, !7, !8, !9}
@@ -558,7 +560,7 @@ declare void @free(ptr nocapture)
 !20 = !{}
 !21 = !DIFile(filename: "test.c", directory: "/test")
 !22 = distinct !DICompileUnit(language: DW_LANG_C99, file: !21, producer: "clang version 15.0.0", isOptimized: true, emissionKind: FullDebug, globals: !25, splitDebugInlining: false, nameTableKind: None)
-!23 = distinct !DISubprogram(name: "test", scope: !21, file: !21, line: 1, unit: !22)
+!23 = distinct !DISubprogram(name: "test", scope: !21, file: !21, line: 1, type: !30, unit: !22)
 !24 = !DILocalVariable(name: "x", scope: !23)
 !25 = !{}
 !26 = !{i32 2, !"Dwarf Version", i32 4}

diff  --git a/llvm/test/CodeGen/X86/tail-merge-debugloc.ll b/llvm/test/CodeGen/X86/tail-merge-debugloc.ll
index 367e86341fe00..45590903fce36 100644
--- a/llvm/test/CodeGen/X86/tail-merge-debugloc.ll
+++ b/llvm/test/CodeGen/X86/tail-merge-debugloc.ll
@@ -31,12 +31,14 @@ bb5:
 }
 
 !llvm.dbg.cu = !{!0}
+!7 = !{null}
+!8 = !DISubroutineType(types: !7)
 !llvm.module.flags = !{!2, !3}
 
 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1)
 !1 = !DIFile(filename: "foo.c", directory: "b/")
 !2 = !{i32 2, !"Dwarf Version", i32 4}
 !3 = !{i32 2, !"Debug Info Version", i32 3}
-!4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 3, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !0)
+!4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 3, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, type: !8, unit: !0)
 !5 = distinct !DILexicalBlock(scope: !4, file: !1, line: 1, column: 1)
 !6 = !DILocation(line: 2, column: 2, scope: !5)

diff  --git a/llvm/test/DebugInfo/AMDGPU/bitcast-store-combine-debugloc.ll b/llvm/test/DebugInfo/AMDGPU/bitcast-store-combine-debugloc.ll
index 17438f1a8a843..c5f7602d1e7fc 100644
--- a/llvm/test/DebugInfo/AMDGPU/bitcast-store-combine-debugloc.ll
+++ b/llvm/test/DebugInfo/AMDGPU/bitcast-store-combine-debugloc.ll
@@ -17,10 +17,12 @@ define void @test(ptr %p, ptr %q) !dbg !4 {
 }
 
 !llvm.dbg.cu = !{!0}
+!9 = !{null}
+!10 = !DISubroutineType(types: !9)
 !llvm.module.flags = !{!2}
 !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, emissionKind: LineTablesOnly)
 !1 = !DIFile(filename: "t.c", directory: "")
 !2 = !{i32 2, !"Debug Info Version", i32 3}
-!4 = distinct !DISubprogram(name: "test", file: !1, line: 1, spFlags: DISPFlagDefinition, unit: !0)
+!4 = distinct !DISubprogram(name: "test", file: !1, line: 1, spFlags: DISPFlagDefinition, type: !10, unit: !0)
 !7 = !DILocation(line: 2, scope: !4)
 !8 = !DILocation(line: 3, scope: !4)

diff  --git a/llvm/test/DebugInfo/ARM/move-dbg-value-after-value-list.mir b/llvm/test/DebugInfo/ARM/move-dbg-value-after-value-list.mir
index 23e43ccb046d7..836db83d1e3e7 100644
--- a/llvm/test/DebugInfo/ARM/move-dbg-value-after-value-list.mir
+++ b/llvm/test/DebugInfo/ARM/move-dbg-value-after-value-list.mir
@@ -1,13 +1,13 @@
 # RUN: llc %s -start-after=arm-mve-vpt-opts -stop-after=arm-prera-ldst-opt -o - | FileCheck %s
-# CHECK: %5:rgpr = t2MOVCCr %3, killed %4, 0 /* CC::eq */, $cpsr, debug-location !14
-# CHECK-NEXT: DBG_VALUE 0, $noreg, !10, !DIExpression(), debug-location !14
-# CHECK-NEXT: DBG_VALUE 1, $noreg, !10, !DIExpression(), debug-location !14
-# CHECK-NEXT: DBG_VALUE_LIST !10, !DIExpression(), $noreg, $noreg, debug-location !14
-# CHECK-NEXT: DBG_VALUE $noreg, $noreg, !10, !DIExpression(), debug-location !14
-# CHECK-NEXT: %0:rgpr = t2LDRi12 %5, 0, 14 /* CC::al */, $noreg, debug-location !14 :: (load (s32) from %ir..backtrace_user.ctl_default, align 8)
-# CHECK-NEXT: %6:rgpr = t2LDRi12 %5, 4, 14 /* CC::al */, $noreg, debug-location !14 :: (load (s32) from %ir.btc_user_copy)
-# CHECK-NEXT: %2:gpr = t2LDRi12 %5, 8, 14 /* CC::al */, $noreg, debug-location !14 :: (load (s32) from %ir.btc_user_copy_context, align 8)
-# CHECK-NEXT: DBG_VALUE %2, $noreg, !10, !DIExpression(), debug-location !14
+# CHECK: %5:rgpr = t2MOVCCr %3, killed %4, 0 /* CC::eq */, $cpsr, debug-location !16
+# CHECK-NEXT: DBG_VALUE 0, $noreg, !12, !DIExpression(), debug-location !16
+# CHECK-NEXT: DBG_VALUE 1, $noreg, !12, !DIExpression(), debug-location !16
+# CHECK-NEXT: DBG_VALUE_LIST !12, !DIExpression(), $noreg, $noreg, debug-location !16
+# CHECK-NEXT: DBG_VALUE $noreg, $noreg, !12, !DIExpression(), debug-location !16
+# CHECK-NEXT: %0:rgpr = t2LDRi12 %5, 0, 14 /* CC::al */, $noreg, debug-location !16 :: (load (s32) from %ir..backtrace_user.ctl_default, align 8)
+# CHECK-NEXT: %6:rgpr = t2LDRi12 %5, 4, 14 /* CC::al */, $noreg, debug-location !16 :: (load (s32) from %ir.btc_user_copy)
+# CHECK-NEXT: %2:gpr = t2LDRi12 %5, 8, 14 /* CC::al */, $noreg, debug-location !16 :: (load (s32) from %ir.btc_user_copy_context, align 8)
+# CHECK-NEXT: DBG_VALUE %2, $noreg, !12, !DIExpression(), debug-location !16
 # CHECK-NEXT: %7:rgpr = t2ANDrr %6, %0, 14 /* CC::al */, $noreg, def $cpsr
 # CHECK-NEXT: %8:rgpr = t2ANDrr %6, %0, 14 /* CC::al */, $noreg, def $cpsr
 # CHECK-NEXT: %9:rgpr = t2ANDrr %6, %0, 14 /* CC::al */, $noreg, def $cpsr
@@ -30,7 +30,7 @@
   !llvm.dbg.cu = !{!32}
   !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
   !1 = distinct !DIGlobalVariable(type: !11, isDefinition: true)
-  !2 = distinct !DISubprogram(unit: !32, retainedNodes: !38)
+  !2 = distinct !DISubprogram(type: !97, unit: !32, retainedNodes: !38)
   !3 = !DIFile(filename: "backtrace.pp.c", directory: "/Users/shubham/Development/Delta")
   !11 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !12)
   !12 = distinct !DICompositeType(tag: DW_TAG_member, offset: 32)
@@ -43,6 +43,8 @@
   !88 = !{i32 2, !"Debug Info Version", i32 3}
   !93 = !{i32 7, !"frame-pointer", i32 1}
   !95 = !DILocation(line: 5, column: 10, scope: !2)
+  !96 = !{null}
+  !97 = !DISubroutineType(types: !96)
 name:            backtrace_user
 registers:
   - {id: 0, class: rgpr, }

diff  --git a/llvm/test/DebugInfo/ARM/move-dbg-value-lists.mir b/llvm/test/DebugInfo/ARM/move-dbg-value-lists.mir
index 681d89b03936d..a93b9d69b3df7 100644
--- a/llvm/test/DebugInfo/ARM/move-dbg-value-lists.mir
+++ b/llvm/test/DebugInfo/ARM/move-dbg-value-lists.mir
@@ -1,15 +1,15 @@
 # RUN: llc %s -start-after=arm-mve-vpt-opts -stop-after=arm-prera-ldst-opt -o - | FileCheck %s
-# CHECK: %5:rgpr = t2MOVCCr %3, killed %4, 0 /* CC::eq */, $cpsr, debug-location !14
-# CHECK-NEXT: DBG_VALUE 0, $noreg, !10, !DIExpression(), debug-location !14
-# CHECK-NEXT: DBG_VALUE 1, $noreg, !10, !DIExpression(), debug-location !14
-# CHECK-NEXT: DBG_VALUE_LIST !10, !DIExpression(), $noreg, $noreg, debug-location !14
-# CHECK-NEXT: %0:rgpr = t2LDRi12 %5, 0, 14 /* CC::al */, $noreg, debug-location !14 :: (load (s32) from %ir..backtrace_user.ctl_default, align 8)
-# CHECK-NEXT: DBG_VALUE_LIST !10, !DIExpression(), $noreg, $noreg, debug-location !14
-# CHECK-NEXT: %6:rgpr = t2LDRi12 %5, 4, 14 /* CC::al */, $noreg, debug-location !14 :: (load (s32) from %ir.btc_user_copy)
-# CHECK-NEXT: DBG_VALUE_LIST !10, !DIExpression(), %6, %0, debug-location !14
-# CHECK-NEXT: %2:gpr = t2LDRi12 %5, 8, 14 /* CC::al */, $noreg, debug-location !14 :: (load (s32) from %ir.btc_user_copy_context, align 8)
+# CHECK: %5:rgpr = t2MOVCCr %3, killed %4, 0 /* CC::eq */, $cpsr, debug-location !16
+# CHECK-NEXT: DBG_VALUE 0, $noreg, !12, !DIExpression(), debug-location !16
+# CHECK-NEXT: DBG_VALUE 1, $noreg, !12, !DIExpression(), debug-location !16
+# CHECK-NEXT: DBG_VALUE_LIST !12, !DIExpression(), $noreg, $noreg, debug-location !16
+# CHECK-NEXT: %0:rgpr = t2LDRi12 %5, 0, 14 /* CC::al */, $noreg, debug-location !16 :: (load (s32) from %ir..backtrace_user.ctl_default, align 8)
+# CHECK-NEXT: DBG_VALUE_LIST !12, !DIExpression(), $noreg, $noreg, debug-location !16
+# CHECK-NEXT: %6:rgpr = t2LDRi12 %5, 4, 14 /* CC::al */, $noreg, debug-location !16 :: (load (s32) from %ir.btc_user_copy)
+# CHECK-NEXT: DBG_VALUE_LIST !12, !DIExpression(), %6, %0, debug-location !16
+# CHECK-NEXT: %2:gpr = t2LDRi12 %5, 8, 14 /* CC::al */, $noreg, debug-location !16 :: (load (s32) from %ir.btc_user_copy_context, align 8)
 # CHECK-NEXT: %7:rgpr = t2ANDrr %6, %0, 14 /* CC::al */, $noreg, def $cpsr
-# CHECK-NEXT: DBG_VALUE %2, $noreg, !10, !DIExpression(), debug-location !14
+# CHECK-NEXT: DBG_VALUE %2, $noreg, !12, !DIExpression(), debug-location !16
 --- |
   target triple = "thumbv7k-apple-watchos8.0.0"
   %struct.backtrace_control = type {}
@@ -25,7 +25,7 @@
   !llvm.dbg.cu = !{!32}
   !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
   !1 = distinct !DIGlobalVariable(type: !11, isDefinition: true)
-  !2 = distinct !DISubprogram(unit: !32, retainedNodes: !38)
+  !2 = distinct !DISubprogram(type: !97, unit: !32, retainedNodes: !38)
   !3 = !DIFile(filename: "backtrace.pp.c", directory: "/Users/shubham/Development/Delta")
   !11 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !12)
   !12 = distinct !DICompositeType(tag: DW_TAG_member, offset: 32)
@@ -38,6 +38,8 @@
   !88 = !{i32 2, !"Debug Info Version", i32 3}
   !93 = !{i32 7, !"frame-pointer", i32 1}
   !95 = !DILocation(line: 5, column: 10, scope: !2)
+  !96 = !{null}
+  !97 = !DISubroutineType(types: !96)
 name:            backtrace_user
 registers:
   - {id: 0, class: rgpr, }

diff  --git a/llvm/test/DebugInfo/ARM/move-dbg-value-same-reg.mir b/llvm/test/DebugInfo/ARM/move-dbg-value-same-reg.mir
index 7a5749d8a2495..7cbf6dd4b5c57 100644
--- a/llvm/test/DebugInfo/ARM/move-dbg-value-same-reg.mir
+++ b/llvm/test/DebugInfo/ARM/move-dbg-value-same-reg.mir
@@ -28,7 +28,7 @@
   !llvm.dbg.cu = !{!32}
   !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
   !1 = distinct !DIGlobalVariable(type: !11, isDefinition: true)
-  !2 = distinct !DISubprogram(unit: !32, retainedNodes: !38)
+  !2 = distinct !DISubprogram(type: !97, unit: !32, retainedNodes: !38)
   !3 = !DIFile(filename: "backtrace.pp.c", directory: "/Users/shubham/Development/Delta")
   !11 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !12)
   !12 = distinct !DICompositeType(tag: DW_TAG_member, offset: 32)
@@ -44,6 +44,8 @@
   !88 = !{i32 2, !"Debug Info Version", i32 3}
   !93 = !{i32 7, !"frame-pointer", i32 1}
   !95 = !DILocation(line: 5, column: 10, scope: !2)
+  !96 = !{null}
+  !97 = !DISubroutineType(types: !96)
 name:            backtrace_user
 registers:
   - {id: 0, class: rgpr, }

diff  --git a/llvm/test/DebugInfo/ARM/move-dbg-values.mir b/llvm/test/DebugInfo/ARM/move-dbg-values.mir
index 1d2f07d8b8d6b..f90eff1a6d752 100644
--- a/llvm/test/DebugInfo/ARM/move-dbg-values.mir
+++ b/llvm/test/DebugInfo/ARM/move-dbg-values.mir
@@ -1,14 +1,14 @@
 # RUN: llc %s -start-after=arm-mve-vpt-opts -stop-after=arm-prera-ldst-opt -o - | FileCheck %s
-# CHECK: %5:rgpr = t2MOVCCr %3, killed %4, 0 /* CC::eq */, $cpsr, debug-location !15
-# CHECK-NEXT: DBG_VALUE 0, $noreg, !10, !DIExpression(), debug-location !15
-# CHECK-NEXT: DBG_VALUE $noreg, $noreg, !10, !DIExpression(), debug-location !15
-# CHECK-NEXT: DBG_VALUE $noreg, $noreg, !10, !DIExpression(), debug-location !15
-# CHECK-NEXT: %0:rgpr = t2LDRi12 %5, 0, 14 /* CC::al */, $noreg, debug-location !15 :: (load (s32) from %ir..backtrace_user.ctl_default, align 8)
-# CHECK-NEXT: %6:rgpr = t2LDRi12 %5, 4, 14 /* CC::al */, $noreg, debug-location !15 :: (load (s32) from %ir.btc_user_copy)
-# CHECK-NEXT: DBG_VALUE %6, $noreg, !10, !DIExpression(), debug-location !15
-# CHECK-NEXT: %2:gpr = t2LDRi12 %5, 8, 14 /* CC::al */, $noreg, debug-location !15 :: (load (s32) from %ir.btc_user_copy_context, align 8)
+# CHECK: %5:rgpr = t2MOVCCr %3, killed %4, 0 /* CC::eq */, $cpsr, debug-location !17
+# CHECK-NEXT: DBG_VALUE 0, $noreg, !12, !DIExpression(), debug-location !17
+# CHECK-NEXT: DBG_VALUE $noreg, $noreg, !12, !DIExpression(), debug-location !17
+# CHECK-NEXT: DBG_VALUE $noreg, $noreg, !12, !DIExpression(), debug-location !17
+# CHECK-NEXT: %0:rgpr = t2LDRi12 %5, 0, 14 /* CC::al */, $noreg, debug-location !17 :: (load (s32) from %ir..backtrace_user.ctl_default, align 8)
+# CHECK-NEXT: %6:rgpr = t2LDRi12 %5, 4, 14 /* CC::al */, $noreg, debug-location !17 :: (load (s32) from %ir.btc_user_copy)
+# CHECK-NEXT: DBG_VALUE %6, $noreg, !12, !DIExpression(), debug-location !17
+# CHECK-NEXT: %2:gpr = t2LDRi12 %5, 8, 14 /* CC::al */, $noreg, debug-location !17 :: (load (s32) from %ir.btc_user_copy_context, align 8)
 # CHECK-NEXT: %7:rgpr = t2ANDrr %6, %0, 14 /* CC::al */, $noreg, def $cpsr
-# CHECK-NEXT: DBG_VALUE %2, $noreg, !10, !DIExpression(), debug-location !15
+# CHECK-NEXT: DBG_VALUE %2, $noreg, !12, !DIExpression(), debug-location !17
 --- |
   target triple = "thumbv7k-apple-watchos8.0.0"
   %struct.backtrace_control = type {}
@@ -25,7 +25,7 @@
   !llvm.dbg.cu = !{!32}
   !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
   !1 = distinct !DIGlobalVariable(type: !11, isDefinition: true)
-  !2 = distinct !DISubprogram(unit: !32, retainedNodes: !38)
+  !2 = distinct !DISubprogram(type: !97, unit: !32, retainedNodes: !38)
   !3 = !DIFile(filename: "backtrace.pp.c", directory: "/Users/shubham/Development/Delta")
   !8 = !DIDerivedType(tag: DW_TAG_typedef, baseType: !11, size: 32)
   !11 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !12)
@@ -40,6 +40,8 @@
   !88 = !{i32 2, !"Debug Info Version", i32 3}
   !93 = !{i32 7, !"frame-pointer", i32 1}
   !95 = !DILocation(line: 5, column: 10, scope: !2)
+  !96 = !{null}
+  !97 = !DISubroutineType(types: !96)
 name:            backtrace_user
 registers:
   - {id: 0, class: rgpr, }

diff  --git a/llvm/test/DebugInfo/Generic/2010-03-19-DbgDeclare.ll b/llvm/test/DebugInfo/Generic/2010-03-19-DbgDeclare.ll
index 3cff8d64c1e83..2ef71bc5b721a 100644
--- a/llvm/test/DebugInfo/Generic/2010-03-19-DbgDeclare.ll
+++ b/llvm/test/DebugInfo/Generic/2010-03-19-DbgDeclare.ll
@@ -8,13 +8,15 @@ entry:
   ret void
 }
 !llvm.dbg.cu = !{!2}
+!7 = !{null}
+!8 = !DISubroutineType(types: !7)
 !llvm.module.flags = !{!5}
 !2 = distinct !DICompileUnit(language: DW_LANG_Mips_Assembler, producer: "clang version 3.3 ", isOptimized: false, emissionKind: FullDebug, file: !4, enums: !3, retainedTypes: !3, globals: !3, imports:  !3)
 !3 = !{}
 !0 = !DILocation(line: 662302, column: 26, scope: !1)
 !1 = !DILocalVariable(name: "foo", scope: !6)
 !4 = !DIFile(filename: "scratch.cpp", directory: "/usr/local/google/home/blaikie/dev/scratch")
-!6 = distinct !DISubprogram(unit: !2)
+!6 = distinct !DISubprogram(type: !8, unit: !2)
 
 declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
 !5 = !{i32 1, !"Debug Info Version", i32 3}

diff  --git a/llvm/test/DebugInfo/Generic/dbg-value-lower-linenos.ll b/llvm/test/DebugInfo/Generic/dbg-value-lower-linenos.ll
index b6879e3f827a8..ab3e46720b014 100644
--- a/llvm/test/DebugInfo/Generic/dbg-value-lower-linenos.ll
+++ b/llvm/test/DebugInfo/Generic/dbg-value-lower-linenos.ll
@@ -85,13 +85,15 @@ declare i32 @lookup(...)
 ; CHECK: ![[MAPVAR]] = !DILocalVariable(name: "floogie",
 ; CHECK: ![[UNKNOWN2]] = !DILocation(line: 0
 
+!28 = !{null}
+!29 = !DISubroutineType(types: !28)
 !llvm.module.flags = !{!4}
 !llvm.dbg.cu = !{!2}
 !1 = !DILocalVariable(name: "bees", scope: !5, type: null)
 !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "beards", isOptimized: true, runtimeVersion: 4, emissionKind: FullDebug)
 !3 = !DIFile(filename: "bees.cpp", directory: "")
 !4 = !{i32 2, !"Debug Info Version", i32 3}
-!5 = distinct !DISubprogram(name: "nope", scope: !3, file: !3, line: 1, unit: !2)
+!5 = distinct !DISubprogram(name: "nope", scope: !3, file: !3, line: 1, type: !29, unit: !2)
 !6 = !DILocation(line: 1, scope: !5)
 !7 = !DILocalVariable(name: "flannel", scope: !5, type: null)
 !8 = !DILocation(line: 2, scope: !5)
@@ -101,9 +103,9 @@ declare i32 @lookup(...)
 !12 = !DILocation(line: 6, scope: !5)
 !13 = !DILocation(line: 7, scope: !5)
 !14 = !DILocation(line: 8, scope: !5)
-!15 = distinct !DISubprogram(name: "wat", scope: !2, file: !3, line: 10, unit: !2)
+!15 = distinct !DISubprogram(name: "wat", scope: !2, file: !3, line: 10, type: !29, unit: !2)
 !16 = !DILocation(line: 9, scope: !15, inlinedAt: !14)
-!20 = distinct !DISubprogram(name: "thin", scope: !3, file: !3, line: 20, unit: !2)
+!20 = distinct !DISubprogram(name: "thin", scope: !3, file: !3, line: 20, type: !29, unit: !2)
 !21 = !DILocalVariable(name: "floogie", scope: !20, type: null)
 !22 = !DILocation(line: 21, scope: !20)
 !23 = !DILocation(line: 22, scope: !20)

diff  --git a/llvm/test/DebugInfo/Generic/debuginfofinder-retained-nodes.ll b/llvm/test/DebugInfo/Generic/debuginfofinder-retained-nodes.ll
index a2038c7a6a4bf..3614c08c6cd3b 100644
--- a/llvm/test/DebugInfo/Generic/debuginfofinder-retained-nodes.ll
+++ b/llvm/test/DebugInfo/Generic/debuginfofinder-retained-nodes.ll
@@ -19,6 +19,8 @@ entry:
 }
 
 !llvm.dbg.cu = !{!0}
+!18 = !{null}
+!19 = !DISubroutineType(types: !18)
 !llvm.module.flags = !{!2, !3, !4, !5}
 !llvm.ident = !{!6}
 
@@ -29,14 +31,14 @@ entry:
 !4 = !{i32 1, !"wchar_size", i32 4}
 !5 = !{i32 8, !"PIC Level", i32 2}
 !6 = !{!"clang version 21.0.0git"}
-!7 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !1, file: !1, line: 1, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !8)
+!7 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !1, file: !1, line: 1, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, type: !19, unit: !0, retainedNodes: !8)
 !8 = !{!9, !15}
 !9 = !DILocalVariable(name: "v", scope: !7, file: !1, line: 8, type: !10)
 !10 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "T", scope: !7, file: !1, line: 2, size: 32, flags: DIFlagTypePassByValue, elements: !11)
 !11 = !{!12, !14}
 !12 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !10, file: !1, line: 3, baseType: !13, size: 32)
 !13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
-!14 = !DISubprogram(name: "bar", scope: !10, file: !1, line: 5, scopeLine: 5, flags: DIFlagPrototyped | DIFlagStaticMember, spFlags: DISPFlagLocalToUnit)
+!14 = !DISubprogram(name: "bar", scope: !10, file: !1, line: 5, type: !19, scopeLine: 5, flags: DIFlagPrototyped | DIFlagStaticMember, spFlags: DISPFlagLocalToUnit)
 !15 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !7, entity: !16, file: !1, line: 7)
-!16 = distinct !DISubprogram(name: "imported", scope: !17, file: !1, line: 3, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0)
+!16 = distinct !DISubprogram(name: "imported", scope: !17, file: !1, line: 3, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, type: !19, unit: !0)
 !17 = !DINamespace(name: "ns", scope: null)
\ No newline at end of file

diff  --git a/llvm/test/DebugInfo/Generic/invalid.ll b/llvm/test/DebugInfo/Generic/invalid.ll
index 2ff26c0860e4c..bea22ed9ec65a 100644
--- a/llvm/test/DebugInfo/Generic/invalid.ll
+++ b/llvm/test/DebugInfo/Generic/invalid.ll
@@ -3,16 +3,18 @@
 ; Make sure we emit this diagnostic only once (which means we don't visit the
 ; same DISubprogram twice.
 ; CHECK: subprogram definitions must have a compile unit
-; CHECK-NEXT: !3 = distinct !DISubprogram(name: "patatino", scope: null, spFlags: DISPFlagDefinition)
+; CHECK-NEXT: !3 = distinct !DISubprogram(name: "patatino", scope: null, type: !4, spFlags: DISPFlagDefinition)
 ; CHECK-NOT: subprogram definitions must have a compile unit
-; CHECK-NOT: !3 = distinct !DISubprogram(name: "patatino", scope: null, spFlags: DISPFlagDefinition)
+; CHECK-NOT: !3 = distinct !DISubprogram(name: "patatino", scope: null, type: !4, spFlags: DISPFlagDefinition)
 ; CHECK: warning: ignoring invalid debug info
 
 define void @tinkywinky() !dbg !3 { ret void }
 
-!llvm.module.flags = !{!4}
+!llvm.module.flags = !{!6}
 !llvm.dbg.cu = !{!0}
 !0 = distinct !DICompileUnit(language: 12, file: !1)
 !1 = !DIFile(filename: "/home/davide", directory: "/home/davide")
-!3 = distinct !DISubprogram(name: "patatino", isDefinition: true)
-!4 = !{i32 2, !"Debug Info Version", i32 3}
+!3 = distinct !DISubprogram(name: "patatino", isDefinition: true, type: !4)
+!4 = !DISubroutineType(types: !5)
+!5 = !{null}
+!6 = !{i32 2, !"Debug Info Version", i32 3}

diff  --git a/llvm/test/DebugInfo/Generic/sroa-extract-bits.ll b/llvm/test/DebugInfo/Generic/sroa-extract-bits.ll
index 6db453605cb57..817e9ee75b1bf 100644
--- a/llvm/test/DebugInfo/Generic/sroa-extract-bits.ll
+++ b/llvm/test/DebugInfo/Generic/sroa-extract-bits.ll
@@ -179,7 +179,7 @@ entry:
 !0 = !{i32 7, !"Dwarf Version", i32 5}
 !1 = !{i32 2, !"Debug Info Version", i32 3}
 !2 = !DILocalVariable(name: "x", scope: !3, type: !6)
-!3 = distinct !DISubprogram(name: "test", unit: !4)
+!3 = distinct !DISubprogram(name: "test", unit: !4, type: !13)
 !4 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !5, emissionKind: FullDebug)
 !5 = !DIFile(filename: "dbg-bit-piece.cpp", directory: "")
 !6 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
@@ -192,7 +192,7 @@ entry:
 
 ;.
 ; CHECK: [[META2]] = !DILocalVariable(name: "x", scope: [[META3:![0-9]+]], type: [[META6:![0-9]+]])
-; CHECK: [[META3]] = distinct !DISubprogram(name: "test", scope: null, spFlags: DISPFlagDefinition, unit: [[META4:![0-9]+]])
+; CHECK: [[META3]] = distinct !DISubprogram(name: "test", scope: null, type: [[TYPE:![0-9]+]], spFlags: DISPFlagDefinition, unit: [[META4:![0-9]+]])
 ; CHECK: [[META4]] = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: [[META5:![0-9]+]], isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
 ; CHECK: [[META5]] = !DIFile(filename: "dbg-bit-piece.cpp", directory: "")
 ; CHECK: [[META6]] = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
@@ -203,3 +203,5 @@ entry:
 ; CHECK: [[META11]] = !DILocalVariable(name: "x", scope: [[META3]], type: [[META12:![0-9]+]])
 ; CHECK: [[META12]] = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
 ;.
+!13 = !DISubroutineType(types: !14)
+!14 = !{null}

diff  --git a/llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll b/llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll
index 54ce1c56c6b30..0a15453951749 100644
--- a/llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll
+++ b/llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll
@@ -5,14 +5,16 @@
 !0 = distinct !DICompileUnit(language: 0, file: !1)
 !1 = !DIFile(filename: "-", directory: "")
 !2 = !{i32 2, !"Debug Info Version", i32 3}
+!20 = !{null}
+!21 = !DISubroutineType(types: !20)
 
 ; CHECK: invalid file
 define void @invalid_file() !dbg !3 { ret void }
-!3 = distinct !DISubprogram(file: !0)
+!3 = distinct !DISubprogram(type: !21, file: !0)
 
 ; CHECK: line specified with no file
 define void @line_specified_with_no_file() !dbg !4 { ret void }
-!4 = distinct !DISubprogram(line: 1)
+!4 = distinct !DISubprogram(type: !21, line: 1)
 
 ; CHECK: invalid subroutine type
 define void @invalid_subroutine_type() !dbg !5 { ret void }
@@ -20,60 +22,60 @@ define void @invalid_subroutine_type() !dbg !5 { ret void }
 
 ; CHECK: invalid containing type
 define void @invalid_containing_type() !dbg !6 { ret void }
-!6 = distinct !DISubprogram(containingType: !0)
+!6 = distinct !DISubprogram(type: !21, containingType: !0)
 
 ; CHECK: invalid template params
 define void @invalid_template_params() !dbg !7 { ret void }
-!7 = distinct !DISubprogram(templateParams: !0)
+!7 = distinct !DISubprogram(type: !21, templateParams: !0)
 
 ; CHECK: invalid template parameter
 define void @invalid_template_parameter() !dbg !8 { ret void }
-!8 = distinct !DISubprogram(templateParams: !{!0})
+!8 = distinct !DISubprogram(type: !21, templateParams: !{!0})
 
 ; CHECK: invalid subprogram declaration
 define void @invalid_subprogram_declaration() !dbg !9 { ret void }
-!9 = distinct !DISubprogram(declaration: !0)
+!9 = distinct !DISubprogram(type: !21, declaration: !0)
 
 ; CHECK: invalid retained nodes list
 define void @invalid_retained_nodes_list() !dbg !10 { ret void }
-!10 = distinct !DISubprogram(retainedNodes: !0)
+!10 = distinct !DISubprogram(type: !21, retainedNodes: !0)
 
 ; CHECK: invalid retained nodes, expected DILocalVariable, DILabel, DIImportedEntity or DIType
 define void @invalid_retained_nodes_expected() !dbg !11 { ret void }
-!11 = distinct !DISubprogram(retainedNodes: !{!0})
+!11 = distinct !DISubprogram(type: !21, retainedNodes: !{!0})
 
 ; CHECK: invalid reference flags
 define void @invalid_reference_flags_reference() !dbg !12 { ret void }
-!12 = distinct !DISubprogram(flags: DIFlagLValueReference | DIFlagRValueReference)
+!12 = distinct !DISubprogram(type: !21, flags: DIFlagLValueReference | DIFlagRValueReference)
 
 ; CHECK: invalid reference flags
 define void @invalid_reference_flags_pass_by() !dbg !13 { ret void }
-!13 = distinct !DISubprogram(flags: DIFlagTypePassByValue | DIFlagTypePassByReference)
+!13 = distinct !DISubprogram(type: !21, flags: DIFlagTypePassByValue | DIFlagTypePassByReference)
 
 ; CHECK: subprogram definitions must have a compile unit
 define void @subprogram_definitions_must_have_a_compile_unit() !dbg !14 { ret void }
-!14 = distinct !DISubprogram()
+!14 = distinct !DISubprogram(type: !21)
 
 ; CHECK: invalid unit type
 define void @invalid_unit_type() !dbg !15 { ret void }
-!15 = distinct !DISubprogram(unit: !{})
+!15 = distinct !DISubprogram(type: !21, unit: !{})
 
 ; FIXME: should something verify `isDefinition` is not a lie? is it meaningful
 ; to mistmatch it with respect to the LLVM IR function?
 ; CHECK: subprogram declarations must not have a compile unit
 define void @subprogram_declarations_must_not_have_a_compile_unit() !dbg !16 { ret void }
-!16 = distinct !DISubprogram(isDefinition: false, unit: !0)
+!16 = distinct !DISubprogram(type: !21, isDefinition: false, unit: !0)
 
 ; CHECK: invalid thrown types list
 define void @invalid_thrown_types_list() !dbg !17 { ret void }
-!17 = distinct !DISubprogram(isDefinition: false, thrownTypes: !0)
+!17 = distinct !DISubprogram(type: !21, isDefinition: false, thrownTypes: !0)
 
 ; CHECK: invalid thrown type
 define void @invalid_thrown_type() !dbg !18 { ret void }
-!18 = distinct !DISubprogram(isDefinition: false, thrownTypes: !{!0})
+!18 = distinct !DISubprogram(type: !21, isDefinition: false, thrownTypes: !{!0})
 
 ; CHECK: DIFlagAllCallsDescribed must be attached to a definition
 define void @DIFlagAllCallsDescribed_must_be_attached_to_a_definition() !dbg !19 { ret void }
-!19 = distinct !DISubprogram(isDefinition: false, flags: DIFlagAllCallsDescribed)
+!19 = distinct !DISubprogram(type: !21, isDefinition: false, flags: DIFlagAllCallsDescribed)
 
 ; CHECK: warning: ignoring invalid debug info{{.*}}

diff  --git a/llvm/test/DebugInfo/MIR/X86/dbgcall-site-interpretation.mir b/llvm/test/DebugInfo/MIR/X86/dbgcall-site-interpretation.mir
index 2035d8fc317d4..2a4787b14c923 100644
--- a/llvm/test/DebugInfo/MIR/X86/dbgcall-site-interpretation.mir
+++ b/llvm/test/DebugInfo/MIR/X86/dbgcall-site-interpretation.mir
@@ -95,7 +95,7 @@
   !1 = !DIFile(filename: "dbgcall-site-interpretation.c", directory: "/dir")
   !2 = !{}
   !3 = !{!4}
-  !4 = !DISubprogram(name: "foo", scope: !1, file: !1, line: 9, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
+  !4 = !DISubprogram(name: "foo", scope: !1, file: !1, line: 9, flags: DIFlagPrototyped, type: !10, spFlags: DISPFlagOptimized, retainedNodes: !2)
   !5 = !{i32 2, !"Dwarf Version", i32 4}
   !6 = !{i32 2, !"Debug Info Version", i32 3}
   !7 = !{i32 1, !"wchar_size", i32 4}

diff  --git a/llvm/test/DebugInfo/MIR/X86/dbgcall-site-lea-interpretation.mir b/llvm/test/DebugInfo/MIR/X86/dbgcall-site-lea-interpretation.mir
index 44b45e67a8f4c..00e5d503d7b5e 100644
--- a/llvm/test/DebugInfo/MIR/X86/dbgcall-site-lea-interpretation.mir
+++ b/llvm/test/DebugInfo/MIR/X86/dbgcall-site-lea-interpretation.mir
@@ -72,8 +72,8 @@
   !1 = !DIFile(filename: "dbgcall-site-lea-interpretation.c", directory: "/dir")
   !2 = !{}
   !3 = !{!4, !5}
-  !4 = !DISubprogram(name: "foo", scope: !1, file: !1, line: 8, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
-  !5 = !DISubprogram(name: "foo2", scope: !1, file: !1, line: 9, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
+  !4 = !DISubprogram(name: "foo", scope: !1, file: !1, line: 8, flags: DIFlagPrototyped, type: !11, spFlags: DISPFlagOptimized, retainedNodes: !2)
+  !5 = !DISubprogram(name: "foo2", scope: !1, file: !1, line: 9, flags: DIFlagPrototyped, type: !11, spFlags: DISPFlagOptimized, retainedNodes: !2)
   !6 = !{i32 2, !"Dwarf Version", i32 4}
   !7 = !{i32 2, !"Debug Info Version", i32 3}
   !8 = !{i32 1, !"wchar_size", i32 4}

diff  --git a/llvm/test/DebugInfo/MIR/X86/dbginfo-entryvals.mir b/llvm/test/DebugInfo/MIR/X86/dbginfo-entryvals.mir
index 2e858d4d87456..8192ff387a07c 100644
--- a/llvm/test/DebugInfo/MIR/X86/dbginfo-entryvals.mir
+++ b/llvm/test/DebugInfo/MIR/X86/dbginfo-entryvals.mir
@@ -47,7 +47,7 @@
   !1 = !DIFile(filename: "test.c", directory: "/dir")
   !2 = !{}
   !3 = !{!4}
-  !4 = !DISubprogram(name: "fn2", scope: !1, file: !1, line: 11, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
+  !4 = !DISubprogram(name: "fn2", scope: !1, file: !1, line: 11, flags: DIFlagPrototyped, type: !10, spFlags: DISPFlagOptimized, retainedNodes: !2)
   !5 = !{i32 2, !"Dwarf Version", i32 4}
   !6 = !{i32 2, !"Debug Info Version", i32 3}
   !7 = !{i32 1, !"wchar_size", i32 4}

diff  --git a/llvm/test/DebugInfo/MIR/X86/debug-call-site-param.mir b/llvm/test/DebugInfo/MIR/X86/debug-call-site-param.mir
index 26e66ae13ce5c..5825469ab680f 100644
--- a/llvm/test/DebugInfo/MIR/X86/debug-call-site-param.mir
+++ b/llvm/test/DebugInfo/MIR/X86/debug-call-site-param.mir
@@ -108,8 +108,8 @@
   !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 9.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
   !1 = !DIFile(filename: "test.c", directory: "/dir")
   !2 = !{}
-  !4 = !DISubprogram(name: "getVal", scope: !1, file: !1, line: 2, spFlags: DISPFlagOptimized, retainedNodes: !2)
-  !5 = !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
+  !4 = !DISubprogram(name: "getVal", scope: !1, file: !1, line: 2, type: !11, spFlags: DISPFlagOptimized, retainedNodes: !2)
+  !5 = !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, flags: DIFlagPrototyped, type: !11, spFlags: DISPFlagOptimized, retainedNodes: !2)
   !6 = !{i32 2, !"Dwarf Version", i32 4}
   !7 = !{i32 2, !"Debug Info Version", i32 3}
   !8 = !{i32 1, !"wchar_size", i32 4}

diff  --git a/llvm/test/DebugInfo/MIR/X86/machine-cse.mir b/llvm/test/DebugInfo/MIR/X86/machine-cse.mir
index 19dcddd1d4fee..45d0ab3e78df9 100644
--- a/llvm/test/DebugInfo/MIR/X86/machine-cse.mir
+++ b/llvm/test/DebugInfo/MIR/X86/machine-cse.mir
@@ -73,14 +73,16 @@
   !0 = !{i32 2, !"Debug Info Version", i32 3}
   !1 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !2, producer: "beards", isOptimized: true, runtimeVersion: 4, emissionKind: FullDebug)
   !2 = !DIFile(filename: "bees.cpp", directory: "")
-  !3 = distinct !DISubprogram(name: "nope", scope: !1, file: !2, line: 1, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !9)
-  !33 = distinct !DISubprogram(name: "alsonope", scope: !1, file: !2, line: 1, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !9)
+  !3 = distinct !DISubprogram(name: "nope", type: !35, scope: !1, file: !2, line: 1, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !9)
+  !33 = distinct !DISubprogram(name: "alsonope", type: !35, scope: !1, file: !2, line: 1, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !9)
   !4 = !DILocalVariable(name: "bees", scope: !3, type: !5)
   !5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6, size: 64)
   !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
   !7 = !DILocation(line: 0, scope: !3)
   !8 = !{!4}
   !9 = !{}
+  !34 = !{null}
+  !35 = !DISubroutineType(types: !34)
 
 
   ; CHECK: ![[METAVAR:[0-9]+]] = !DILocalVariable(name: "bees",

diff  --git a/llvm/test/DebugInfo/X86/instr-ref-opt-bisect2.ll b/llvm/test/DebugInfo/X86/instr-ref-opt-bisect2.ll
index 92aedfea9449a..12d992775b834 100644
--- a/llvm/test/DebugInfo/X86/instr-ref-opt-bisect2.ll
+++ b/llvm/test/DebugInfo/X86/instr-ref-opt-bisect2.ll
@@ -26,11 +26,13 @@ bb:
 }
 
 !llvm.dbg.cu = !{!0}
+!6 = !{null}
+!7 = !DISubroutineType(types: !6)
 !llvm.module.flags = !{!2}
 
 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1)
 !1 = !DIFile(filename: "instr-ref-opt-bisect2.ll", directory: ".")
 !2 = !{i32 2, !"Debug Info Version", i32 3}
-!3 = distinct !DISubprogram(name: "instr-ref-opt-bisect2", file: !1, unit: !0)
+!3 = distinct !DISubprogram(name: "instr-ref-opt-bisect2", file: !1, type: !7, unit: !0)
 !4 = !DILocalVariable(name: "arg", arg: 2, scope: !3)
 !5 = !DILocation(line: 0, scope: !3)

diff  --git a/llvm/test/DebugInfo/X86/pr40427.ll b/llvm/test/DebugInfo/X86/pr40427.ll
index 264076b2569dd..a0a3e92c0bf21 100644
--- a/llvm/test/DebugInfo/X86/pr40427.ll
+++ b/llvm/test/DebugInfo/X86/pr40427.ll
@@ -45,12 +45,14 @@ bb1:
 
 declare void @llvm.dbg.value(metadata, metadata, metadata)
 
+!8 = !{null}
+!9 = !DISubroutineType(types: !8)
 !llvm.module.flags = !{!4}
 !llvm.dbg.cu = !{!2}
 !1 = !DILocalVariable(name: "bees", scope: !5, type: null)
 !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "beards", isOptimized: true, runtimeVersion: 4, emissionKind: FullDebug)
 !3 = !DIFile(filename: "bees.cpp", directory: "")
 !4 = !{i32 2, !"Debug Info Version", i32 3}
-!5 = distinct !DISubprogram(name: "nope", scope: !2, file: !3, line: 1, unit: !2)
+!5 = distinct !DISubprogram(name: "nope", scope: !2, file: !3, line: 1, type: !9, unit: !2)
 !6 = !DILocation(line: 0, scope: !5)
 !7 = !DILocalVariable(name: "flannel", scope: !5, type: null)

diff  --git a/llvm/test/DebugInfo/X86/sunk-compare.ll b/llvm/test/DebugInfo/X86/sunk-compare.ll
index 5ca164ccb26ec..d537b6d0b3184 100644
--- a/llvm/test/DebugInfo/X86/sunk-compare.ll
+++ b/llvm/test/DebugInfo/X86/sunk-compare.ll
@@ -32,6 +32,8 @@ exit2.bb:
 }
 
 !llvm.dbg.cu = !{!0}
+!10 = !{null}
+!11 = !DISubroutineType(types: !10)
 !llvm.module.flags = !{!3, !4}
 
 !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !2)
@@ -39,7 +41,7 @@ exit2.bb:
 !2 = !{}
 !3 = !{i32 2, !"Dwarf Version", i32 4}
 !4 = !{i32 2, !"Debug Info Version", i32 3}
-!5 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !1, file: !1, line: 1, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
+!5 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !1, file: !1, line: 1, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, type: !11, unit: !0, retainedNodes: !2)
 !6 = !DILocation(line: 2, column: 0, scope: !5)
 !7 = !DILocation(line: 3, column: 0, scope: !5)
 !8 = !DILocation(line: 4, column: 0, scope: !5)

diff  --git a/llvm/test/DebugInfo/sroa-handle-dbg-value.ll b/llvm/test/DebugInfo/sroa-handle-dbg-value.ll
index dc9abde884b37..5a877372fa462 100644
--- a/llvm/test/DebugInfo/sroa-handle-dbg-value.ll
+++ b/llvm/test/DebugInfo/sroa-handle-dbg-value.ll
@@ -93,7 +93,7 @@ entry:
 !49 = !DISubroutineType(types: !50)
 !50 = !{ !51}
 !51 = !DICompositeType(tag: DW_TAG_structure_type, identifier: "$s4main1TV13TangentVectorVXMtD")
-!52 = !DISubprogram(spFlags: DISPFlagOptimized)
+!52 = !DISubprogram(type: !49, spFlags: DISPFlagOptimized)
 !53 = !{!54, !56, !57}
 !54 = !DILocalVariable(name: "a", scope: !44, flags: DIFlagArtificial)
 !55 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !46)
@@ -102,7 +102,7 @@ entry:
 !58 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !51)
 !61 = !DILocation(scope: !44)
 !62 = !DILocalVariable(name: "d", scope: !63, type: !72, flags: DIFlagArtificial)
-!63 = distinct !DISubprogram(unit: !16, retainedNodes: !70)
+!63 = distinct !DISubprogram(type: !49, unit: !16, retainedNodes: !70)
 !64 = !DICompositeType(tag: DW_TAG_structure_type, size: 200, identifier: "$s4main1UV13TangentVectorVD")
 !70 = !{}
 !72 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !64)

diff  --git a/llvm/test/Instrumentation/AddressSanitizer/stack_layout.ll b/llvm/test/Instrumentation/AddressSanitizer/stack_layout.ll
index afbfbd6c7a96a..2d1b824822ca2 100644
--- a/llvm/test/Instrumentation/AddressSanitizer/stack_layout.ll
+++ b/llvm/test/Instrumentation/AddressSanitizer/stack_layout.ll
@@ -94,12 +94,14 @@ define void @Func5() sanitize_address #0 !dbg !11 {
 
 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1)
 !1 = !DIFile(filename: "../file1.c", directory: "/")
-!11 = distinct !DISubprogram(name: "Func5", scope: !1, file: !1, line: 6, unit: !0)
+!11 = distinct !DISubprogram(name: "Func5", scope: !1, file: !1, line: 6, type: !19, unit: !0)
 !12 = !DILocation(line: 7, column: 3, scope: !11)
 !18 = !DILocation(line: 10, column: 1, scope: !11)
+!19 = !DISubroutineType(types: !20)
+!20 = !{null}
 
 !21 = !DIFile(filename: "../file2.c", directory: "/")
-!6 = distinct !DISubprogram(name: "Func4", scope: !1, file: !21, line: 2, unit: !0)
+!6 = distinct !DISubprogram(name: "Func4", scope: !1, file: !21, line: 2, type: !19, unit: !0)
 !15 = distinct !DILocation(line: 8, column: 3, scope: !11)
 !14 = !DILocation(line: 3, column: 3, scope: !6, inlinedAt: !15)
 !17 = !DILocation(line: 4, column: 1, scope: !6, inlinedAt: !15)

diff  --git a/llvm/test/Transforms/AggressiveInstCombine/AArch64/combine_ignore_debug.ll b/llvm/test/Transforms/AggressiveInstCombine/AArch64/combine_ignore_debug.ll
index d09d43c936257..cc5714861aeb1 100644
--- a/llvm/test/Transforms/AggressiveInstCombine/AArch64/combine_ignore_debug.ll
+++ b/llvm/test/Transforms/AggressiveInstCombine/AArch64/combine_ignore_debug.ll
@@ -41,11 +41,13 @@ entry:
 declare void @llvm.dbg.value(metadata, metadata, metadata)
 
 !llvm.dbg.cu = !{!0}
+!6 = !{null}
+!7 = !DISubroutineType(types: !6)
 !llvm.module.flags = !{!2}
 
 !0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1)
 !1 = !DIFile(filename: "foo.c", directory: "/")
 !2 = !{i32 2, !"Debug Info Version", i32 3}
 !3 = !DILocalVariable(scope: !4)
-!4 = distinct !DISubprogram(unit: !0)
+!4 = distinct !DISubprogram(type: !7, unit: !0)
 !5 = !DILocation(scope: !4)

diff  --git a/llvm/test/Transforms/ArgumentPromotion/pr33641_remove_arg_dbgvalue.ll b/llvm/test/Transforms/ArgumentPromotion/pr33641_remove_arg_dbgvalue.ll
index ef362f986182f..c04d6174cd8f2 100644
--- a/llvm/test/Transforms/ArgumentPromotion/pr33641_remove_arg_dbgvalue.ll
+++ b/llvm/test/Transforms/ArgumentPromotion/pr33641_remove_arg_dbgvalue.ll
@@ -15,7 +15,7 @@ define void @foo() {
 
 define internal void @bar(ptr %p) {
 ; CHECK-LABEL: define {{.*}}void @bar()
-; CHECK-NEXT:    #dbg_value(ptr poison, !3, !DIExpression(), !5
+; CHECK-NEXT:    #dbg_value(ptr poison, !3, !DIExpression(), !7
   call void @llvm.dbg.value(metadata ptr %p, metadata !3, metadata !DIExpression()), !dbg !5
   ret void
 }
@@ -31,5 +31,7 @@ attributes #0 = { nofree nosync nounwind readnone speculatable willreturn }
 !1 = !DIFile(filename: "test.c", directory: "")
 !2 = !{i32 2, !"Debug Info Version", i32 3}
 !3 = !DILocalVariable(name: "p", scope: !4)
-!4 = distinct !DISubprogram(name: "bar", scope: null, spFlags: DISPFlagDefinition, unit: !0)
+!4 = distinct !DISubprogram(name: "bar", scope: null, spFlags: DISPFlagDefinition, unit: !0, type: !6)
 !5 = !DILocation(line: 1, column: 1, scope: !4)
+!6 = !DISubroutineType(types: !7)
+!7 = !{null}

diff  --git a/llvm/test/Transforms/Attributor/ArgumentPromotion/dbg.ll b/llvm/test/Transforms/Attributor/ArgumentPromotion/dbg.ll
index c6f377c87f881..f2f242f427708 100644
--- a/llvm/test/Transforms/Attributor/ArgumentPromotion/dbg.ll
+++ b/llvm/test/Transforms/Attributor/ArgumentPromotion/dbg.ll
@@ -51,12 +51,14 @@ define void @caller(ptr %Y, ptr %P) {
 }
 
 
+!7 = !{null}
+!8 = !DISubroutineType(types: !7)
 !llvm.module.flags = !{!0}
 !llvm.dbg.cu = !{!3}
 
 !0 = !{i32 2, !"Debug Info Version", i32 3}
 !1 = !DILocation(line: 8, scope: !2)
-!2 = distinct !DISubprogram(name: "test", file: !5, line: 3, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !3, scopeLine: 3, scope: null)
+!2 = distinct !DISubprogram(name: "test", file: !5, line: 3, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, type: !8, unit: !3, scopeLine: 3, scope: null)
 !3 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 ", isOptimized: false, emissionKind: LineTablesOnly, file: !5)
 !5 = !DIFile(filename: "test.c", directory: "")
 !6 = !DILocation(line: 9, scope: !2)
@@ -68,14 +70,14 @@ define void @caller(ptr %Y, ptr %P) {
 ; TUNIT: [[META0:![0-9]+]] = !{i32 2, !"Debug Info Version", i32 3}
 ; TUNIT: [[META1:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: [[META2:![0-9]+]], producer: "{{.*}}clang version {{.*}} ", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly)
 ; TUNIT: [[META2]] = !DIFile(filename: "test.c", directory: "")
-; TUNIT: [[DBG3]] = distinct !DISubprogram(name: "test", scope: null, file: [[META2]], line: 3, scopeLine: 3, virtualIndex: 6, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: [[META1]])
+; TUNIT: [[DBG3]] = distinct !DISubprogram(name: "test", scope: null, file: [[META2]], line: 3, type: [[META4:![0-9]+]], scopeLine: 3, virtualIndex: 6, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: [[META1]])
 ; TUNIT: [[DBG4]] = !DILocation(line: 8, scope: [[DBG3]])
 ; TUNIT: [[DBG5]] = !DILocation(line: 9, scope: [[DBG3]])
 ;.
 ; CGSCC: [[META0:![0-9]+]] = !{i32 2, !"Debug Info Version", i32 3}
 ; CGSCC: [[META1:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: [[META2:![0-9]+]], producer: "{{.*}}clang version {{.*}} ", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly)
 ; CGSCC: [[META2]] = !DIFile(filename: "test.c", directory: "")
-; CGSCC: [[DBG3]] = distinct !DISubprogram(name: "test", scope: null, file: [[META2]], line: 3, scopeLine: 3, virtualIndex: 6, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: [[META1]])
+; CGSCC: [[DBG3]] = distinct !DISubprogram(name: "test", scope: null, file: [[META2]], line: 3, type: [[META4:![0-9]+]], scopeLine: 3, virtualIndex: 6, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: [[META1]])
 ; CGSCC: [[DBG4]] = !DILocation(line: 8, scope: [[DBG3]])
 ; CGSCC: [[DBG5]] = !DILocation(line: 9, scope: [[DBG3]])
 ;.

diff  --git a/llvm/test/Transforms/Attributor/ArgumentPromotion/pr33641_remove_arg_dbgvalue.ll b/llvm/test/Transforms/Attributor/ArgumentPromotion/pr33641_remove_arg_dbgvalue.ll
index f095fbde578a6..483d99c481117 100644
--- a/llvm/test/Transforms/Attributor/ArgumentPromotion/pr33641_remove_arg_dbgvalue.ll
+++ b/llvm/test/Transforms/Attributor/ArgumentPromotion/pr33641_remove_arg_dbgvalue.ll
@@ -38,12 +38,14 @@ define internal void @bar(%p_t %p)  {
 declare void @llvm.dbg.value(metadata, metadata, metadata)
 
 !llvm.dbg.cu = !{!0}
+!7 = !{null}
+!8 = !DISubroutineType(types: !7)
 !llvm.module.flags = !{!2}
 
 !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1)
 !1 = !DIFile(filename: "test.c", directory: "")
 !2 = !{i32 2, !"Debug Info Version", i32 3}
-!3 = distinct !DISubprogram(name: "bar", unit: !0)
+!3 = distinct !DISubprogram(name: "bar", type: !8, unit: !0)
 !4 = !DILocalVariable(name: "p", scope: !3)
 !5 = !DIExpression()
 !6 = !DILocation(line: 1, column: 1, scope: !3)
@@ -60,7 +62,7 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
 ; CGSCC: [[META1]] = !DIFile(filename: "test.c", directory: "")
 ; CGSCC: [[META2:![0-9]+]] = !{i32 2, !"Debug Info Version", i32 3}
 ; CGSCC: [[META3]] = !DILocalVariable(name: "p", scope: [[META4:![0-9]+]])
-; CGSCC: [[META4]] = distinct !DISubprogram(name: "bar", scope: null, spFlags: DISPFlagDefinition, unit: [[META0]])
+; CGSCC: [[META4]] = distinct !DISubprogram(name: "bar", scope: null, type: [[TYPE:![0-9]+]], spFlags: DISPFlagDefinition, unit: [[META0]])
 ; CGSCC: [[META5]] = !DILocation(line: 1, column: 1, scope: [[META4]])
 ;.
 ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:

diff  --git a/llvm/test/Transforms/CallSiteSplitting/callsite-split-debug.ll b/llvm/test/Transforms/CallSiteSplitting/callsite-split-debug.ll
index d6d99e672ed17..17254bd2c7d04 100644
--- a/llvm/test/Transforms/CallSiteSplitting/callsite-split-debug.ll
+++ b/llvm/test/Transforms/CallSiteSplitting/callsite-split-debug.ll
@@ -42,6 +42,8 @@ declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata,
 attributes #0 = { nounwind readnone speculatable }
 
 !llvm.dbg.cu = !{!0}
+!14 = !{null}
+!15 = !DISubroutineType(types: !14)
 !llvm.module.flags = !{!2, !3}
 !llvm.ident = !{!4}
 
@@ -51,7 +53,7 @@ attributes #0 = { nounwind readnone speculatable }
 !3 = !{i32 2, !"Debug Info Version", i32 3}
 !4 = !{!"My Compiler"}
 !5 = !DIBasicType(name: "int", size: 16, encoding: DW_ATE_signed)
-!6 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 4, unit: !0)
+!6 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 4, type: !15, unit: !0)
 !7 = !DILocalVariable(name: "c", scope: !6, line: 5, type: !5)
 !8 = !DILocation(line: 5, column: 7, scope: !6)
 !11 = !DILocalVariable(name: "a", scope: !6, line: 6, type: !5)

diff  --git a/llvm/test/Transforms/CodeGenPrepare/X86/cast-debuginfo-salvage.ll b/llvm/test/Transforms/CodeGenPrepare/X86/cast-debuginfo-salvage.ll
index 51e75c1fc8486..736451df57af4 100644
--- a/llvm/test/Transforms/CodeGenPrepare/X86/cast-debuginfo-salvage.ll
+++ b/llvm/test/Transforms/CodeGenPrepare/X86/cast-debuginfo-salvage.ll
@@ -21,13 +21,15 @@ define void @test(i64 %arg) {
 !2 = !{}
 !3 = !{i32 2, !"Debug Info Version", i32 3}
 !4 = !DILocalVariable(name: "c", scope: !5, file: !1, line: 26)
-!5 = distinct !DISubprogram(name: "n<(lambda at test.cpp:39:14)>", linkageName: "_ZN1m1nIZN1o1pEvEUl1kE_EE5arrayT_i", scope: null, file: !1, line: 25, spFlags: DISPFlagDefinition, unit: !0)
+!5 = distinct !DISubprogram(name: "n<(lambda at test.cpp:39:14)>", linkageName: "_ZN1m1nIZN1o1pEvEUl1kE_EE5arrayT_i", scope: null, file: !1, line: 25, spFlags: DISPFlagDefinition, unit: !0, type: !7)
 !6 = !DILocation(line: 26, column: 11, scope: !5)
 ;.
 ; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: [[META1:![0-9]+]], producer: "{{.*}}clang version {{.*}}", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, retainedTypes: [[META2:![0-9]+]], globals: [[META2]], splitDebugInlining: false, nameTableKind: None)
 ; CHECK: [[META1]] = !DIFile(filename: "test.cpp", directory: {{.*}})
 ; CHECK: [[META2]] = !{}
 ; CHECK: [[META4]] = !DILocalVariable(name: "c", scope: [[META5:![0-9]+]], file: [[META1]], line: 26)
-; CHECK: [[META5]] = distinct !DISubprogram(name: "n<(lambda at test.cpp:39:14)>", linkageName: "_ZN1m1nIZN1o1pEvEUl1kE_EE5arrayT_i", scope: null, file: [[META1]], line: 25, spFlags: DISPFlagDefinition, unit: [[META0]])
+; CHECK: [[META5]] = distinct !DISubprogram(name: "n<(lambda at test.cpp:39:14)>", linkageName: "_ZN1m1nIZN1o1pEvEUl1kE_EE5arrayT_i", scope: null, file: [[META1]], line: 25, type: [[TYPE:![0-9]+]], spFlags: DISPFlagDefinition, unit: [[META0]])
 ; CHECK: [[META6]] = !DILocation(line: 26, column: 11, scope: [[META5]])
 ;.
+!7 = !DISubroutineType(types: !8)
+!8 = !{null}

diff  --git a/llvm/test/Transforms/Coroutines/declare-value.ll b/llvm/test/Transforms/Coroutines/declare-value.ll
index 58f9f10a6c076..bbf19f3753c98 100644
--- a/llvm/test/Transforms/Coroutines/declare-value.ll
+++ b/llvm/test/Transforms/Coroutines/declare-value.ll
@@ -56,17 +56,19 @@ attributes #0 = { presplitcoroutine }
 attributes #1 = { nomerge nounwind }
 attributes #2 = { nounwind }
 
+!12 = !{null}
+!13 = !DISubroutineType(types: !12)
 !llvm.module.flags = !{!0}
 
 !0 = !{i32 2, !"Debug Info Version", i32 3}
-!1 = distinct !DISubprogram(scope: null, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !4)
+!1 = distinct !DISubprogram(scope: null, spFlags: DISPFlagDefinition, type: !13, unit: !2, retainedNodes: !4)
 !2 = distinct !DICompileUnit(language: DW_LANG_Swift, file: !3, isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
 !3 = !DIFile(filename: "blah", directory: "")
 !4 = !{}
 !5 = !DILocalVariable(scope: !1, type: !6)
 !6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Klass")
 !7 = !DILocation(line: 0, scope: !1)
-!8 = distinct !DISubprogram(scope: null, spFlags: DISPFlagDefinition, unit: !2)
+!8 = distinct !DISubprogram(scope: null, spFlags: DISPFlagDefinition, type: !13, unit: !2)
 !9 = !DILocation(line: 0, scope: !8)
-!10 = distinct !DISubprogram(scope: null, spFlags: DISPFlagDefinition, unit: !2)
+!10 = distinct !DISubprogram(scope: null, spFlags: DISPFlagDefinition, type: !13, unit: !2)
 !11 = !DILocation(line: 0, scope: !10)
\ No newline at end of file

diff  --git a/llvm/test/Transforms/Inline/debug-invoke.ll b/llvm/test/Transforms/Inline/debug-invoke.ll
index 444363667fa2b..45897fcaa70b8 100644
--- a/llvm/test/Transforms/Inline/debug-invoke.ll
+++ b/llvm/test/Transforms/Inline/debug-invoke.ll
@@ -30,11 +30,13 @@ lpad:
   ret void
 }
 
+!7 = !{null}
+!8 = !DISubroutineType(types: !7)
 !llvm.module.flags = !{!1}
 !llvm.dbg.cu = !{!5}
 
 !1 = !{i32 2, !"Debug Info Version", i32 3}
-!2 = distinct !DISubprogram(unit: !5)
+!2 = distinct !DISubprogram(type: !8, unit: !5)
 !3 = !DILocation(line: 1, scope: !2)
 !4 = !DILocation(line: 2, scope: !2)
 !5 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang",

diff  --git a/llvm/test/Transforms/InstCombine/assume.ll b/llvm/test/Transforms/InstCombine/assume.ll
index 197d680babe11..67ee6f5303999 100644
--- a/llvm/test/Transforms/InstCombine/assume.ll
+++ b/llvm/test/Transforms/InstCombine/assume.ll
@@ -1058,7 +1058,7 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
 
 !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "Me", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: null, retainedTypes: null, imports: null)
 !1 = !DILocalVariable(name: "", arg: 1, scope: !2, file: null, line: 1, type: null)
-!2 = distinct !DISubprogram(name: "debug", linkageName: "debug", scope: null, file: null, line: 0, type: null, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0)
+!2 = distinct !DISubprogram(name: "debug", linkageName: "debug", scope: null, file: null, line: 0, type: !10, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0)
 !3 = !DIFile(filename: "consecutive-fences.ll", directory: "")
 !5 = !{i32 2, !"Dwarf Version", i32 4}
 !6 = !{i32 2, !"Debug Info Version", i32 3}
@@ -1069,3 +1069,5 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
 
 attributes #0 = { nounwind uwtable }
 attributes #1 = { nounwind }
+!10 = !DISubroutineType(types: !11)
+!11 = !{null}

diff  --git a/llvm/test/Transforms/InstCombine/consecutive-fences.ll b/llvm/test/Transforms/InstCombine/consecutive-fences.ll
index b79a50b3ef2c7..84d7ff3cdd115 100644
--- a/llvm/test/Transforms/InstCombine/consecutive-fences.ll
+++ b/llvm/test/Transforms/InstCombine/consecutive-fences.ll
@@ -113,10 +113,12 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
 
 !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "Me", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: null, retainedTypes: null, imports: null)
 !1 = !DILocalVariable(name: "", arg: 1, scope: !2, file: null, line: 1, type: null)
-!2 = distinct !DISubprogram(name: "debug", linkageName: "debug", scope: null, file: null, line: 0, type: null, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0)
+!2 = distinct !DISubprogram(name: "debug", linkageName: "debug", scope: null, file: null, line: 0, type: !10, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0)
 !3 = !DIFile(filename: "consecutive-fences.ll", directory: "")
 !5 = !{i32 2, !"Dwarf Version", i32 4}
 !6 = !{i32 2, !"Debug Info Version", i32 3}
 !7 = !{i32 1, !"wchar_size", i32 4}
 !8 = !{i32 7, !"PIC Level", i32 2}
 !9 = !DILocation(line: 0, column: 0, scope: !2)
+!10 = !DISubroutineType(types: !11)
+!11 = !{null}

diff  --git a/llvm/test/Transforms/LICM/hoist-phi-metadata.ll b/llvm/test/Transforms/LICM/hoist-phi-metadata.ll
index 6f64bf7d7c875..9b7387495df29 100644
--- a/llvm/test/Transforms/LICM/hoist-phi-metadata.ll
+++ b/llvm/test/Transforms/LICM/hoist-phi-metadata.ll
@@ -51,7 +51,7 @@ end:
 !1 = !DIFile(filename: "t", directory: "/")
 !2 = !{i32 7, !"Dwarf Version", i32 5}
 !3 = !{i32 2, !"Debug Info Version", i32 3}
-!4 = distinct !DISubprogram(name: "triangle_phi", linkageName: "triangle_phi", scope: !1, file: !1, line: 1, unit: !0)
+!4 = distinct !DISubprogram(name: "triangle_phi", linkageName: "triangle_phi", scope: !1, file: !1, line: 1, unit: !0, type: !10)
 !5 = !DILocation(line: 1, column: 22, scope: !4)
 !6 = !DILocation(line: 2, column: 22, scope: !4)
 !7 = !DILocation(line: 3, column: 22, scope: !4)
@@ -62,9 +62,11 @@ end:
 ; CHECK: [[META1:![0-9]+]] = !{i32 2, !"Debug Info Version", i32 3}
 ; CHECK: [[PROF2]] = !{!"branch_weights", i32 5, i32 7}
 ; CHECK: [[DBG3]] = !DILocation(line: 2, column: 22, scope: [[META4:![0-9]+]])
-; CHECK: [[META4]] = distinct !DISubprogram(name: "triangle_phi", linkageName: "triangle_phi", scope: [[META5:![0-9]+]], file: [[META5]], line: 1, spFlags: DISPFlagDefinition, unit: [[META6:![0-9]+]])
+; CHECK: [[META4]] = distinct !DISubprogram(name: "triangle_phi", linkageName: "triangle_phi", scope: [[META5:![0-9]+]], file: [[META5]], line: 1, type: [[TYPE:![0-9]+]], spFlags: DISPFlagDefinition, unit: [[META6:![0-9]+]])
 ; CHECK: [[META5]] = !DIFile(filename: "{{.*}}t", directory: {{.*}})
 ; CHECK: [[META6]] = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: [[META5]], isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug)
 ; CHECK: [[DBG7]] = !DILocation(line: 3, column: 22, scope: [[META4]])
 ; CHECK: [[PROF8]] = !{!"branch_weights", i32 13, i32 11}
 ;.
+!10 = !DISubroutineType(types: !11)
+!11 = !{null}

diff  --git a/llvm/test/Transforms/LoopDistribute/debug-loc.ll b/llvm/test/Transforms/LoopDistribute/debug-loc.ll
index 6456c3452b966..c71b6a853d47a 100644
--- a/llvm/test/Transforms/LoopDistribute/debug-loc.ll
+++ b/llvm/test/Transforms/LoopDistribute/debug-loc.ll
@@ -35,9 +35,11 @@ exit:                                             ; preds = %for.body
 !llvm.module.flags = !{!5, !6, !7}
 
 !0 = !DIFile(filename: "f.c", directory: "/")
-!1 = distinct !DISubprogram(name: "f", scope: !0, file: !0, unit: !4)
+!1 = distinct !DISubprogram(name: "f", scope: !0, file: !0, type: !8, unit: !4)
 !2 = !DILocation(line: 5, column: 2, scope: !1)
 !4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !0, producer: "clang")
 !5 = !{i32 1, !"Debug Info Version", i32 3}
 !6 = !{i32 2, !"Dwarf Version", i32 2}
 !7 = !{i32 1, !"PIC Level", i32 2}
+!8 = !DISubroutineType(types: !9)
+!9 = !{null}

diff  --git a/llvm/test/Transforms/LoopVectorize/debugloc.ll b/llvm/test/Transforms/LoopVectorize/debugloc.ll
index 1917f4ac536f3..fd8f023d8b6ce 100644
--- a/llvm/test/Transforms/LoopVectorize/debugloc.ll
+++ b/llvm/test/Transforms/LoopVectorize/debugloc.ll
@@ -243,8 +243,8 @@ exit:
 !27 = !{i32 1, !"Debug Info Version", i32 3}
 !28 = !DILocation(line: 137, column: 44, scope: !29)
 !29 = distinct !DILexicalBlock(scope: !30, file: !5, line: 137, column: 2)
-!30 = distinct !DISubprogram(name: "Place", scope: !5, file: !5, line: 135, scopeLine: 135, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)
-!31 = distinct !DISubprogram(name: "Place", scope: !5, file: !5, line: 135, scopeLine: 135, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)
+!30 = distinct !DISubprogram(name: "Place", scope: !5, file: !5, line: 135, scopeLine: 135, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, type: !7, unit: !0)
+!31 = distinct !DISubprogram(name: "Place", scope: !5, file: !5, line: 135, scopeLine: 135, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, type: !7, unit: !0)
 !32 = distinct !DILexicalBlock(scope: !31, file: !5, line: 137, column: 2)
 !33 = !DILocation(line: 210, column: 44, scope: !32)
 !34 = !DILocation(line: 320, column: 44, scope: !32)

diff  --git a/llvm/test/Transforms/LoopVectorize/discriminator.ll b/llvm/test/Transforms/LoopVectorize/discriminator.ll
index 9084ba98c5a19..a2beb1992be94 100644
--- a/llvm/test/Transforms/LoopVectorize/discriminator.ll
+++ b/llvm/test/Transforms/LoopVectorize/discriminator.ll
@@ -57,13 +57,15 @@ define void @_Z3foov() #0 !dbg !6 {
 ;PSEUDO_PROBE: ![[#PROBE]] = !DILocation(line: 6, column: 13, scope: ![[TOP]])
 
 !llvm.dbg.cu = !{!0}
+!23 = !{null}
+!24 = !DISubroutineType(types: !23)
 !llvm.module.flags = !{!3, !4}
 
 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, debugInfoForProfiling: true)
 !1 = !DIFile(filename: "a.cc", directory: "/")
 !3 = !{i32 2, !"Dwarf Version", i32 4}
 !4 = !{i32 2, !"Debug Info Version", i32 3}
-!6 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 4, unit: !0)
+!6 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 4, type: !24, unit: !0)
 !8 = !DILocation(line: 6, column: 13, scope: !6)
 !9 = !{!10, !10, i64 0}
 !10 = !{!"any pointer", !11, i64 0}

diff  --git a/llvm/test/Transforms/Mem2Reg/dbg_declare_to_value_conversions.ll b/llvm/test/Transforms/Mem2Reg/dbg_declare_to_value_conversions.ll
index 6b58a2860ac31..0dc09ce64082f 100644
--- a/llvm/test/Transforms/Mem2Reg/dbg_declare_to_value_conversions.ll
+++ b/llvm/test/Transforms/Mem2Reg/dbg_declare_to_value_conversions.ll
@@ -39,6 +39,8 @@ define i32 @foo2(ptr %arg) {
 
 declare void @llvm.dbg.declare(metadata, metadata, metadata)
 
+!41 = !{null}
+!42 = !DISubroutineType(types: !41)
 !llvm.module.flags = !{!1, !2}
 !llvm.dbg.cu = !{!7}
 
@@ -48,7 +50,7 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata)
 !4 = !DIBasicType(name: "ptr sized type", size: 64)
 !7 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !8, producer: "clang", emissionKind: FullDebug)
 !8 = !DIFile(filename: "test.ll", directory: "")
-!10 = distinct !DISubprogram(name: "blah", linkageName: "blah", scope: !8, file: !8, line: 7, unit: !7)
+!10 = distinct !DISubprogram(name: "blah", linkageName: "blah", scope: !8, file: !8, line: 7, type: !42, unit: !7)
 !25 = !DILocalVariable(name: "blah", arg: 1, scope: !10, file: !8, line: 7, type:!3)
 !26 = !DILocalVariable(name: "ptr sized var", arg: 1, scope: !10, file: !8, line: 7, type:!4)
 !40 = !DILocation(line: 7, column: 35, scope: !10)

diff  --git a/llvm/test/Transforms/PGOProfile/memprof_annotate_indirect_call.test b/llvm/test/Transforms/PGOProfile/memprof_annotate_indirect_call.test
index 4677eebff3cfe..e5cfb8db18c4c 100644
--- a/llvm/test/Transforms/PGOProfile/memprof_annotate_indirect_call.test
+++ b/llvm/test/Transforms/PGOProfile/memprof_annotate_indirect_call.test
@@ -61,13 +61,15 @@ entry:
 ;; to the GUID of _Z3xyzv, see comments in the profile above.
 ; CHECK-ENABLE: ![[VP2]] = !{!"VP", i32 0, i64 1, i64 -3079258800046378528, i64 1}
 
+!20 = !{null}
+!21 = !DISubroutineType(types: !20)
 !llvm.module.flags = !{!2, !3}
 
 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1)
 !1 = !DIFile(filename: "t", directory: "/")
 !2 = !{i32 7, !"Dwarf Version", i32 5}
 !3 = !{i32 2, !"Debug Info Version", i32 3}
-!4 = distinct !DISubprogram(name: "bar", linkageName: "_Z3barv", scope: !1, file: !1, line: 1, unit: !0)
+!4 = distinct !DISubprogram(name: "bar", linkageName: "_Z3barv", scope: !1, file: !1, line: 1, type: !21, unit: !0)
 !5 = !DILocation(line: 4, column: 5, scope: !4)
 !6 = !DILocation(line: 5, column: 10, scope: !4)
 
@@ -127,7 +129,9 @@ entry:
 !11 = !DIFile(filename: "t", directory: "/")
 !12 = !{i32 7, !"Dwarf Version", i32 5}
 !13 = !{i32 2, !"Debug Info Version", i32 3}
-!14 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !11, file: !11, line: 1, unit: !10)
+!14 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !11, file: !11, line: 1, type: !21, unit: !10)
 !15 = !DILocation(line: 4, column: 5, scope: !14)
 !17 = !DILocation(line: 6, column: 5, scope: !14)
 !18 = !DILocation(line: 7, column: 5, scope: !14)
+!20 = !{null}
+!21 = !DISubroutineType(types: !20)

diff  --git a/llvm/test/Transforms/PGOProfile/memprof_annotate_yaml.test b/llvm/test/Transforms/PGOProfile/memprof_annotate_yaml.test
index 1ef963dec9e23..0b59b5248f220 100644
--- a/llvm/test/Transforms/PGOProfile/memprof_annotate_yaml.test
+++ b/llvm/test/Transforms/PGOProfile/memprof_annotate_yaml.test
@@ -43,5 +43,7 @@ attributes #0 = { builtin allocsize(0) }
 !1 = !DIFile(filename: "t", directory: "/")
 !2 = !{i32 7, !"Dwarf Version", i32 5}
 !3 = !{i32 2, !"Debug Info Version", i32 3}
-!4 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !1, file: !1, line: 1, unit: !0)
+!4 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !1, file: !1, line: 1, type: !6, unit: !0)
 !5 = !DILocation(line: 1, column: 22, scope: !4)
+!6 = !DISubroutineType(types: !7)
+!7 = !{null}

diff  --git a/llvm/test/Transforms/PGOProfile/memprof_max_cold_threshold.test b/llvm/test/Transforms/PGOProfile/memprof_max_cold_threshold.test
index 8f1cabf9a4e87..63290a9f7bf83 100644
--- a/llvm/test/Transforms/PGOProfile/memprof_max_cold_threshold.test
+++ b/llvm/test/Transforms/PGOProfile/memprof_max_cold_threshold.test
@@ -158,8 +158,10 @@ attributes #0 = { builtin allocsize(0) }
 !1 = !DIFile(filename: "t", directory: "/")
 !2 = !{i32 7, !"Dwarf Version", i32 5}
 !3 = !{i32 2, !"Debug Info Version", i32 3}
-!4 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !1, file: !1, line: 1, unit: !0)
+!4 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !1, file: !1, line: 1, type: !9, unit: !0)
 !5 = !DILocation(line: 1, column: 22, scope: !4)
 !6 = !DILocation(line: 2, column: 22, scope: !4)
 !7 = !DILocation(line: 3, column: 22, scope: !4)
 !8 = !DILocation(line: 4, column: 22, scope: !4)
+!9 = !DISubroutineType(types: !10)
+!10 = !{null}

diff  --git a/llvm/test/Transforms/SLPVectorizer/X86/debug-info-salvage.ll b/llvm/test/Transforms/SLPVectorizer/X86/debug-info-salvage.ll
index 01702a4c31334..70ed8d43ec5f0 100644
--- a/llvm/test/Transforms/SLPVectorizer/X86/debug-info-salvage.ll
+++ b/llvm/test/Transforms/SLPVectorizer/X86/debug-info-salvage.ll
@@ -59,12 +59,14 @@ cond.end.i:
 !1 = !DIFile(filename: "q.cpp", directory: "/tmp")
 !7 = !{i32 2, !"Debug Info Version", i32 3}
 !8 = !DILocalVariable(name: "sb", arg: 4, scope: !9)
-!9 = distinct !DISubprogram(name: "color_rgba", unit: !0)
+!9 = distinct !DISubprogram(name: "color_rgba", unit: !0, type: !17)
 !16 = !DILocation(scope: !9)
 ;.
 ; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: [[META1:![0-9]+]], isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug)
 ; CHECK: [[META1]] = !DIFile(filename: "q.cpp", directory: {{.*}})
 ; CHECK: [[META3]] = !DILocalVariable(name: "sb", arg: 4, scope: [[META4:![0-9]+]])
-; CHECK: [[META4]] = distinct !DISubprogram(name: "color_rgba", scope: null, spFlags: DISPFlagDefinition, unit: [[META0]])
+; CHECK: [[META4]] = distinct !DISubprogram(name: "color_rgba", scope: null, type: [[TYPE:![0-9]+]], spFlags: DISPFlagDefinition, unit: [[META0]])
 ; CHECK: [[META5]] = !DILocation(line: 0, scope: [[META4]])
 ;.
+!17 = !DISubroutineType(types: !18)
+!18 = !{null}

diff  --git a/llvm/test/Transforms/SLPVectorizer/X86/phi-node-deletion.ll b/llvm/test/Transforms/SLPVectorizer/X86/phi-node-deletion.ll
index db1d498393043..69dbedf6e0b51 100644
--- a/llvm/test/Transforms/SLPVectorizer/X86/phi-node-deletion.ll
+++ b/llvm/test/Transforms/SLPVectorizer/X86/phi-node-deletion.ll
@@ -29,12 +29,14 @@ for.body:
 !1 = !DIFile(filename: "repro.c", directory: "/")
 !2 = !{i32 2, !"Debug Info Version", i32 3}
 !3 = !DILocalVariable(name: "s0", scope: !4)
-!4 = distinct !DISubprogram(name: "foo", scope: !1, unit: !0)
+!4 = distinct !DISubprogram(name: "foo", scope: !1, unit: !0, type: !6)
 !5 = !DILocation(line: 0, scope: !4)
 ;.
 ; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C11, file: [[META1:![0-9]+]], isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug)
 ; CHECK: [[META1]] = !DIFile(filename: "repro.c", directory: {{.*}})
 ; CHECK: [[META3]] = !DILocalVariable(name: "s0", scope: [[META4:![0-9]+]])
-; CHECK: [[META4]] = distinct !DISubprogram(name: "foo", scope: [[META1]], spFlags: DISPFlagDefinition, unit: [[META0]])
+; CHECK: [[META4]] = distinct !DISubprogram(name: "foo", scope: [[META1]], type: [[TYPE:![0-9]+]], spFlags: DISPFlagDefinition, unit: [[META0]])
 ; CHECK: [[META5]] = !DILocation(line: 0, scope: [[META4]])
 ;.
+!6 = !DISubroutineType(types: !7)
+!7 = !{null}

diff  --git a/llvm/test/Transforms/SLPVectorizer/X86/schedule_budget_debug_info.ll b/llvm/test/Transforms/SLPVectorizer/X86/schedule_budget_debug_info.ll
index 207b2d45c335e..031cf87863e00 100644
--- a/llvm/test/Transforms/SLPVectorizer/X86/schedule_budget_debug_info.ll
+++ b/llvm/test/Transforms/SLPVectorizer/X86/schedule_budget_debug_info.ll
@@ -189,11 +189,13 @@ entry:
 declare void @llvm.dbg.value(metadata, metadata, metadata)
 
 !llvm.dbg.cu = !{!0}
+!6 = !{null}
+!7 = !DISubroutineType(types: !6)
 !llvm.module.flags = !{!2}
 
 !0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1)
 !1 = !DIFile(filename: "foo.c", directory: "/")
 !2 = !{i32 2, !"Debug Info Version", i32 3}
 !3 = !DILocalVariable(scope: !4)
-!4 = distinct !DISubprogram(unit: !0)
+!4 = distinct !DISubprogram(type: !7, unit: !0)
 !5 = !DILocation(scope: !4)

diff  --git a/llvm/test/Transforms/SROA/dbg-single-piece.ll b/llvm/test/Transforms/SROA/dbg-single-piece.ll
index 4a4b809456201..b1a6406d1611d 100644
--- a/llvm/test/Transforms/SROA/dbg-single-piece.ll
+++ b/llvm/test/Transforms/SROA/dbg-single-piece.ll
@@ -26,11 +26,13 @@ entry:
 attributes #0 = { nounwind readnone }
 
 !llvm.dbg.cu = !{!9}
+!10 = !{null}
+!11 = !DISubroutineType(types: !10)
 !llvm.module.flags = !{!0}
 
 !0 = !{i32 2, !"Debug Info Version", i32 3}
 !1 = !DILocalVariable(name: "I", scope: !2, file: !3, line: 947, type: !4)
-!2 = distinct !DISubprogram(name: "findInsertLocation", linkageName: "_ZL18findInsertLocationPN4llvm17MachineBasicBlockENS_9SlotIndexERNS_13LiveIntervalsE", scope: !3, file: !3, line: 937, isLocal: true, isDefinition: true, scopeLine: 938, flags: DIFlagPrototyped, isOptimized: true, unit: !9)
+!2 = distinct !DISubprogram(name: "findInsertLocation", linkageName: "_ZL18findInsertLocationPN4llvm17MachineBasicBlockENS_9SlotIndexERNS_13LiveIntervalsE", scope: !3, file: !3, line: 937, isLocal: true, isDefinition: true, scopeLine: 938, flags: DIFlagPrototyped, isOptimized: true, type: !11, unit: !9)
 !3 = !DIFile(filename: "none", directory: ".")
 !4 = !DICompositeType(tag: DW_TAG_class_type, name: "bundle_iterator<llvm::MachineInstr, llvm::ilist_iterator<llvm::MachineInstr> >", scope: !5, file: !3, line: 163, size: 128, align: 64, elements: !6, templateParams: !6, identifier: "_ZTSN4llvm17MachineBasicBlock15bundle_iteratorINS_12MachineInstrENS_14ilist_iteratorIS2_EEEE")
 !5 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "MachineBasicBlock", file: !3, line: 68, size: 1408, align: 64, identifier: "_ZTSN4llvm17MachineBasicBlockE")

diff  --git a/llvm/test/Transforms/SampleProfile/cold-indirect-call.ll b/llvm/test/Transforms/SampleProfile/cold-indirect-call.ll
index bffc775b64394..a535d41ffbc89 100644
--- a/llvm/test/Transforms/SampleProfile/cold-indirect-call.ll
+++ b/llvm/test/Transforms/SampleProfile/cold-indirect-call.ll
@@ -18,14 +18,16 @@ define i32 @baz() #0 !dbg !7 {
 attributes #0 = {"use-sample-profile"}
 
 !llvm.dbg.cu = !{!0}
+!9 = !{null}
+!10 = !DISubroutineType(types: !9)
 !llvm.module.flags = !{!2}
 
 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1)
 !1 = !DIFile(filename: "foo.cc", directory: "/")
 !2 = !{i32 2, !"Debug Info Version", i32 3}
-!3 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 4, unit: !0)
+!3 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 4, type: !10, unit: !0)
 !4 = !DILocation(line: 5, scope: !3)
-!5 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 8, unit: !0)
+!5 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 8, type: !10, unit: !0)
 !6 = !DILocation(line: 9, scope: !5)
-!7 = distinct !DISubprogram(name: "baz", scope: !1, file: !1, line: 12, unit: !0)
+!7 = distinct !DISubprogram(name: "baz", scope: !1, file: !1, line: 12, type: !10, unit: !0)
 !8 = !DILocation(line: 13, scope: !7)

diff  --git a/llvm/test/Transforms/SampleProfile/csspgo-inline-icall.ll b/llvm/test/Transforms/SampleProfile/csspgo-inline-icall.ll
index 32b47bcfc6d84..0c7dbd94c5b32 100644
--- a/llvm/test/Transforms/SampleProfile/csspgo-inline-icall.ll
+++ b/llvm/test/Transforms/SampleProfile/csspgo-inline-icall.ll
@@ -39,20 +39,22 @@ define void @_Z3zoov() #0 !dbg !11 {
 attributes #0 = {"use-sample-profile"}
 
 !llvm.dbg.cu = !{!0}
+!12 = !{null}
+!13 = !DISubroutineType(types: !12)
 !llvm.module.flags = !{!2}
 
 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1)
 !1 = !DIFile(filename: "test.cc", directory: "/")
 !2 = !{i32 2, !"Debug Info Version", i32 3}
-!3 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 3, unit: !0)
+!3 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 3, type: !13, unit: !0)
 !4 = !DILocation(line: 4, scope: !3)
 !5 = !DILocation(line: 5, scope: !3)
 !6 = !DILocation(line: 6, scope: !3)
 !7 = !DILocation(line: 7, scope: !3)
-!8 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !1, file: !1, line: 29, unit: !0)
-!9 = distinct !DISubprogram(name: "bar", linkageName: "_Z3barv", scope: !1, file: !1, line: 32, unit: !0)
-!10 = distinct !DISubprogram(name: "baz", linkageName: "_Z3bazv", scope: !1, file: !1, line: 24, unit: !0)
-!11 = distinct !DISubprogram(name: "zoo", linkageName: "_Z3zoov", scope: !1, file: !1, line: 24, unit: !0)
+!8 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !1, file: !1, line: 29, type: !13, unit: !0)
+!9 = distinct !DISubprogram(name: "bar", linkageName: "_Z3barv", scope: !1, file: !1, line: 32, type: !13, unit: !0)
+!10 = distinct !DISubprogram(name: "baz", linkageName: "_Z3bazv", scope: !1, file: !1, line: 24, type: !13, unit: !0)
+!11 = distinct !DISubprogram(name: "zoo", linkageName: "_Z3zoov", scope: !1, file: !1, line: 24, type: !13, unit: !0)
 
 
 ; ICP-ALL:      remark: test.cc:4:0: '_Z3foov' inlined into 'test'

diff  --git a/llvm/test/Transforms/SampleProfile/early-inline.ll b/llvm/test/Transforms/SampleProfile/early-inline.ll
index 884353ae76cdd..1c463e6a584eb 100644
--- a/llvm/test/Transforms/SampleProfile/early-inline.ll
+++ b/llvm/test/Transforms/SampleProfile/early-inline.ll
@@ -58,19 +58,21 @@ attributes #0 = {"target-features"="+sse4.1" "use-sample-profile"}
 attributes #1 = {"target-features"="+sse4.2" "use-sample-profile"}
 
 !llvm.dbg.cu = !{!0}
+!18 = !{null}
+!19 = !DISubroutineType(types: !18)
 !llvm.module.flags = !{!3, !4}
 
 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1)
 !1 = !DIFile(filename: "a", directory: "b/")
 !3 = !{i32 2, !"Dwarf Version", i32 4}
 !4 = !{i32 2, !"Debug Info Version", i32 3}
-!6 = distinct !DISubprogram(linkageName: "_Z3foov", scope: !1, file: !1, line: 5, scopeLine: 5, unit: !0)
+!6 = distinct !DISubprogram(linkageName: "_Z3foov", scope: !1, file: !1, line: 5, scopeLine: 5, type: !19, unit: !0)
 !9 = !DILocation(line: 6, column: 3, scope: !6)
 !10 = !DILocation(line: 8, column: 5, scope: !11)
 !11 = distinct !DILexicalBlock(scope: !6, file: !1, line: 7, column: 7)
-!12 = distinct !DISubprogram(linkageName: "_ZL3barv", scope: !1, file: !1, line: 20, scopeLine: 20, unit: !0)
-!13 = distinct !DISubprogram(linkageName: "recursive", scope: !1, file: !1, line: 20, scopeLine: 20, unit: !0)
+!12 = distinct !DISubprogram(linkageName: "_ZL3barv", scope: !1, file: !1, line: 20, scopeLine: 20, type: !19, unit: !0)
+!13 = distinct !DISubprogram(linkageName: "recursive", scope: !1, file: !1, line: 20, scopeLine: 20, type: !19, unit: !0)
 !14 = !DILocation(line: 21, column: 3, scope: !13)
 !15 = !DILocation(line: 22, column: 3, scope: !13)
 !16 = !DILocation(line: 7, column: 3, scope: !6)
-!17 = distinct !DISubprogram(linkageName: "no_inline", scope: !1, file: !1, line: 20, scopeLine: 20, unit: !0)
+!17 = distinct !DISubprogram(linkageName: "no_inline", scope: !1, file: !1, line: 20, scopeLine: 20, type: !19, unit: !0)

diff  --git a/llvm/test/Transforms/SampleProfile/function_metadata.ll b/llvm/test/Transforms/SampleProfile/function_metadata.ll
index 00f61e9f4ed5d..fa17115d0170f 100644
--- a/llvm/test/Transforms/SampleProfile/function_metadata.ll
+++ b/llvm/test/Transforms/SampleProfile/function_metadata.ll
@@ -76,7 +76,7 @@ attributes #0 = {"use-sample-profile"}
 !9 = !{i32 1, !"Debug Info Version", i32 3}
 !10 = !{!"clang version 3.5 "}
 !12 = distinct !DISubprogram(name: "test_liveness", line: 7, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 7, file: !1, scope: !1, type: !6, retainedNodes: !2)
-!13 = !DISubprogram(name: "bar_dbg", scope: !1, file: !1, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)
+!13 = !DISubprogram(name: "bar_dbg", scope: !1, file: !1, flags: DIFlagPrototyped, type: !6, spFlags: DISPFlagOptimized)
 !14 = distinct !DISubprogram(name: "bar_available", line: 7, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 7, file: !1, scope: !1, type: !6, retainedNodes: !2)
 !15 = !DILexicalBlockFile(discriminator: 1, file: !1, scope: !7)
 !17 = distinct !DILexicalBlock(line: 10, column: 0, file: !1, scope: !7)

diff  --git a/llvm/test/Transforms/SampleProfile/indirect-call-gcc.ll b/llvm/test/Transforms/SampleProfile/indirect-call-gcc.ll
index 5aabd82c33065..b59741aa5e99a 100644
--- a/llvm/test/Transforms/SampleProfile/indirect-call-gcc.ll
+++ b/llvm/test/Transforms/SampleProfile/indirect-call-gcc.ll
@@ -17,11 +17,13 @@ define void @test(ptr) #0 !dbg !3 {
 attributes #0 = {"use-sample-profile"}
 
 !llvm.dbg.cu = !{!0}
+!5 = !{null}
+!6 = !DISubroutineType(types: !5)
 !llvm.module.flags = !{!2}
 
 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1)
 !1 = !DIFile(filename: "test.cc", directory: "/")
 !2 = !{i32 2, !"Debug Info Version", i32 3}
-!3 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 1, unit: !0)
+!3 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 1, type: !6, unit: !0)
 !4 = !DILocation(line: 5, scope: !3)
 ; CHECK: ![[PROF]] = !{!"VP", i32 0, i64 3457, i64 9191153033785521275, i64 2059, i64 -1069303473483922844, i64 1398}

diff  --git a/llvm/test/Transforms/SampleProfile/indirect-call.ll b/llvm/test/Transforms/SampleProfile/indirect-call.ll
index 089474c7c149a..1d0a920e3f154 100644
--- a/llvm/test/Transforms/SampleProfile/indirect-call.ll
+++ b/llvm/test/Transforms/SampleProfile/indirect-call.ll
@@ -191,12 +191,14 @@ define void @test_direct() #0 !dbg !22 {
 attributes #0 = {"use-sample-profile"}
 
 !llvm.dbg.cu = !{!0}
+!36 = !{null}
+!37 = !DISubroutineType(types: !36)
 !llvm.module.flags = !{!2}
 
 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1)
 !1 = !DIFile(filename: "test.cc", directory: "/")
 !2 = !{i32 2, !"Debug Info Version", i32 3}
-!3 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 3, unit: !0)
+!3 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 3, type: !37, unit: !0)
 !4 = !DILocation(line: 4, scope: !3)
 !5 = !DILocation(line: 6, scope: !3)
 ; CHECK: ![[PROF]] = !{!"VP", i32 0, i64 3457, i64 9191153033785521275, i64 2059, i64 -1069303473483922844, i64 1398}
@@ -204,33 +206,33 @@ attributes #0 = {"use-sample-profile"}
 ; CHECK: ![[BR2]] = !{!"branch_weights", i32 3000, i32 1000}
 ; CHECK: ![[VP]] = !{!"VP", i32 0, i64 8000, i64 7476224446746900038, i64 -1, i64 925324185419832389, i64 -1, i64 -6391416044382067764, i64 1000}
 ; CHECK: ![[BR3]] = !{!"branch_weights", i32 1, i32 0}
-!6 = distinct !DISubprogram(name: "test_inline", scope: !1, file: !1, line: 6, unit: !0)
+!6 = distinct !DISubprogram(name: "test_inline", scope: !1, file: !1, line: 6, type: !37, unit: !0)
 !7 = !DILocation(line: 7, scope: !6)
-!8 = distinct !DISubprogram(name: "test_inline_strip", scope: !1, file: !1, line: 8, unit: !0)
+!8 = distinct !DISubprogram(name: "test_inline_strip", scope: !1, file: !1, line: 8, type: !37, unit: !0)
 !9 = !DILocation(line: 9, scope: !8)
-!10 = distinct !DISubprogram(name: "test_inline_strip_conflict", scope: !1, file: !1, line: 10, unit: !0)
+!10 = distinct !DISubprogram(name: "test_inline_strip_conflict", scope: !1, file: !1, line: 10, type: !37, unit: !0)
 !11 = !DILocation(line: 11, scope: !10)
-!12 = distinct !DISubprogram(name: "test_noinline", scope: !1, file: !1, line: 12, unit: !0)
+!12 = distinct !DISubprogram(name: "test_noinline", scope: !1, file: !1, line: 12, type: !37, unit: !0)
 !13 = !DILocation(line: 13, scope: !12)
-!14 = distinct !DISubprogram(name: "foo_inline1", scope: !1, file: !1, line: 11, unit: !0)
-!15 = distinct !DISubprogram(name: "foo_inline_strip.suffix", scope: !1, file: !1, line: 1, unit: !0)
-!16 = distinct !DISubprogram(name: "foo_inline_strip_conflict.suffix1", scope: !1, file: !1, line: 1, unit: !0)
-!17 = distinct !DISubprogram(name: "foo_inline_strip_conflict.suffix2", scope: !1, file: !1, line: 1, unit: !0)
-!18 = distinct !DISubprogram(name: "foo_inline_strip_conflict.suffix3", scope: !1, file: !1, line: 1, unit: !0)
-!19 = distinct !DISubprogram(name: "foo_inline2", scope: !1, file: !1, line: 19, unit: !0)
-!20 = distinct !DISubprogram(name: "foo_noinline", scope: !1, file: !1, line: 20, unit: !0)
-!21 = distinct !DISubprogram(name: "foo_direct", scope: !1, file: !1, line: 21, unit: !0)
-!22 = distinct !DISubprogram(name: "test_direct", scope: !1, file: !1, line: 22, unit: !0)
+!14 = distinct !DISubprogram(name: "foo_inline1", scope: !1, file: !1, line: 11, type: !37, unit: !0)
+!15 = distinct !DISubprogram(name: "foo_inline_strip.suffix", scope: !1, file: !1, line: 1, type: !37, unit: !0)
+!16 = distinct !DISubprogram(name: "foo_inline_strip_conflict.suffix1", scope: !1, file: !1, line: 1, type: !37, unit: !0)
+!17 = distinct !DISubprogram(name: "foo_inline_strip_conflict.suffix2", scope: !1, file: !1, line: 1, type: !37, unit: !0)
+!18 = distinct !DISubprogram(name: "foo_inline_strip_conflict.suffix3", scope: !1, file: !1, line: 1, type: !37, unit: !0)
+!19 = distinct !DISubprogram(name: "foo_inline2", scope: !1, file: !1, line: 19, type: !37, unit: !0)
+!20 = distinct !DISubprogram(name: "foo_noinline", scope: !1, file: !1, line: 20, type: !37, unit: !0)
+!21 = distinct !DISubprogram(name: "foo_direct", scope: !1, file: !1, line: 21, type: !37, unit: !0)
+!22 = distinct !DISubprogram(name: "test_direct", scope: !1, file: !1, line: 22, type: !37, unit: !0)
 !23 = !DILocation(line: 23, scope: !22)
-!24 = distinct !DISubprogram(name: "test_norecursive_inline", scope: !1, file: !1, line: 12, unit: !0)
+!24 = distinct !DISubprogram(name: "test_norecursive_inline", scope: !1, file: !1, line: 12, type: !37, unit: !0)
 !25 = !DILocation(line: 13, scope: !24)
-!26 = distinct !DISubprogram(name: "test_noinline_bitcast", scope: !1, file: !1, line: 12, unit: !0)
+!26 = distinct !DISubprogram(name: "test_noinline_bitcast", scope: !1, file: !1, line: 12, type: !37, unit: !0)
 !27 = !DILocation(line: 13, scope: !26)
-!28 = distinct !DISubprogram(name: "foo_direct_i32", scope: !1, file: !1, line: 11, unit: !0)
-!29 = distinct !DISubprogram(name: "return_arg", scope: !1, file: !1, line: 11, unit: !0)
-!30 = distinct !DISubprogram(name: "return_arg_caller", scope: !1, file: !1, line: 11, unit: !0)
+!28 = distinct !DISubprogram(name: "foo_direct_i32", scope: !1, file: !1, line: 11, type: !37, unit: !0)
+!29 = distinct !DISubprogram(name: "return_arg", scope: !1, file: !1, line: 11, type: !37, unit: !0)
+!30 = distinct !DISubprogram(name: "return_arg_caller", scope: !1, file: !1, line: 11, type: !37, unit: !0)
 !31 = !DILocation(line: 12, scope: !30)
 !32 = !DILocation(line: 13, scope: !30)
-!33 = distinct !DISubprogram(name: "branch_prof_valid", scope: !1, file: !1, line: 25, unit: !0)
+!33 = distinct !DISubprogram(name: "branch_prof_valid", scope: !1, file: !1, line: 25, type: !37, unit: !0)
 !34 = !DILocation(line: 27, scope: !33)
-!35 = distinct !DISubprogram(name: "foo_inline3", scope: !1, file: !1, line: 29, unit: !0)
+!35 = distinct !DISubprogram(name: "foo_inline3", scope: !1, file: !1, line: 29, type: !37, unit: !0)

diff  --git a/llvm/test/Transforms/SampleProfile/inline-callee-update.ll b/llvm/test/Transforms/SampleProfile/inline-callee-update.ll
index 2f4734cb8c03c..28bfd8d0989a7 100644
--- a/llvm/test/Transforms/SampleProfile/inline-callee-update.ll
+++ b/llvm/test/Transforms/SampleProfile/inline-callee-update.ll
@@ -54,20 +54,22 @@ declare ptr @direct_leaf_func(ptr)
 attributes #0 = {"use-sample-profile"}
 
 !llvm.dbg.cu = !{!0}
+!13 = !{null}
+!14 = !DISubroutineType(types: !13)
 !llvm.module.flags = !{!2}
 
 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug)
 !1 = !DIFile(filename: "test.cc", directory: "/")
 !2 = !{i32 2, !"Debug Info Version", i32 3}
-!3 = distinct !DISubprogram(name: "sample_loader_inlinee", scope: !1, file: !1, line: 11, spFlags: DISPFlagDefinition, unit: !0)
+!3 = distinct !DISubprogram(name: "sample_loader_inlinee", scope: !1, file: !1, line: 11, spFlags: DISPFlagDefinition, type: !14, unit: !0)
 !4 = !DILocation(line: 12, scope: !3)
 !5 = !DILocation(line: 13, scope: !3)
-!6 = distinct !DISubprogram(name: "cgscc_inlinee", scope: !1, file: !1, line: 31, spFlags: DISPFlagDefinition, unit: !0)
+!6 = distinct !DISubprogram(name: "cgscc_inlinee", scope: !1, file: !1, line: 31, spFlags: DISPFlagDefinition, type: !14, unit: !0)
 !7 = !DILocation(line: 32, scope: !6)
 !8 = !DILocation(line: 33, scope: !6)
-!9 = distinct !DISubprogram(name: "test_sample_loader_inline", scope: !1, file: !1, line: 3, spFlags: DISPFlagDefinition, unit: !0)
+!9 = distinct !DISubprogram(name: "test_sample_loader_inline", scope: !1, file: !1, line: 3, spFlags: DISPFlagDefinition, type: !14, unit: !0)
 !10 = !DILocation(line: 4, scope: !9)
-!11 = distinct !DISubprogram(name: "test_cgscc_inline", scope: !1, file: !1, line: 20, spFlags: DISPFlagDefinition, unit: !0)
+!11 = distinct !DISubprogram(name: "test_cgscc_inline", scope: !1, file: !1, line: 20, spFlags: DISPFlagDefinition, type: !14, unit: !0)
 !12 = !DILocation(line: 21, scope: !11)
 
 ; Make sure the ImportGUID stays with entry count metadata for ThinLTO-PreLink

diff  --git a/llvm/test/Transforms/SimplifyCFG/X86/hoist-loads-stores-with-cf.ll b/llvm/test/Transforms/SimplifyCFG/X86/hoist-loads-stores-with-cf.ll
index 4eda91ffaa268..10bde11165534 100644
--- a/llvm/test/Transforms/SimplifyCFG/X86/hoist-loads-stores-with-cf.ll
+++ b/llvm/test/Transforms/SimplifyCFG/X86/hoist-loads-stores-with-cf.ll
@@ -1231,6 +1231,8 @@ if.end:                                           ; preds = %if.then1, %entry
 declare i32 @read_memory_only() readonly nounwind willreturn speculatable
 
 !llvm.dbg.cu = !{!0}
+!12 = !{null}
+!13 = !DISubroutineType(types: !12)
 !llvm.module.flags = !{!2, !3}
 !llvm.ident = !{!4}
 
@@ -1240,7 +1242,7 @@ declare i32 @read_memory_only() readonly nounwind willreturn speculatable
 !3 = !{i32 2, !"Debug Info Version", i32 3}
 !4 = !{!"clang"}
 !5 = !DIBasicType(name: "int", size: 16, encoding: DW_ATE_signed)
-!6 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 4, unit: !0)
+!6 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 4, type: !13, unit: !0)
 !7 = !DILocation(line: 5, column: 7, scope: !6)
 !8 = !DILocalVariable(name: "a", scope: !6, line: 6, type: !5)
 !9 = distinct !DIAssignID()

diff  --git a/llvm/test/Transforms/SimplifyCFG/X86/remove-debug.ll b/llvm/test/Transforms/SimplifyCFG/X86/remove-debug.ll
index 0bc0d4a92a23c..59f063a3f914c 100644
--- a/llvm/test/Transforms/SimplifyCFG/X86/remove-debug.ll
+++ b/llvm/test/Transforms/SimplifyCFG/X86/remove-debug.ll
@@ -69,7 +69,7 @@ declare void @_Z3bazv() #1
 !3 = !{i32 2, !"Dwarf Version", i32 4}
 !4 = !{i32 2, !"Debug Info Version", i32 3}
 !5 = !{}
-!6 = distinct !DISubprogram(unit: !0)
+!6 = distinct !DISubprogram(type: !7, unit: !0)
 !7 = !DISubroutineType(types: !2)
 !8 = !{!9, !9, i64 0}
 !9 = !{!"int", !10, i64 0}

diff  --git a/llvm/test/Transforms/SimplifyCFG/pr39807.ll b/llvm/test/Transforms/SimplifyCFG/pr39807.ll
index c150c1b54cb8d..e65339bdff606 100644
--- a/llvm/test/Transforms/SimplifyCFG/pr39807.ll
+++ b/llvm/test/Transforms/SimplifyCFG/pr39807.ll
@@ -29,15 +29,17 @@ define internal void @inlinable() !dbg !7 {
 }
 
 !llvm.dbg.cu = !{!0}
+!9 = !{null}
+!10 = !DISubroutineType(types: !9)
 !llvm.module.flags = !{!4, !5, !6}
 
 ; CHECK: ![[DBGLOC]] = !DILocation(line: 0
 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, runtimeVersion: 0, file: !3)
-!1 = distinct !DISubprogram(name: "test", unit: !0)
+!1 = distinct !DISubprogram(name: "test", type: !10, unit: !0)
 !2 = !DILocation(line: 2, scope: !1)
 !3 = !DIFile(filename: "foo", directory: ".")
 !4 = !{i32 2, !"Dwarf Version", i32 4}
 !5 = !{i32 2, !"Debug Info Version", i32 3}
 !6 = !{i32 1, !"wchar_size", i32 4}
-!7 = distinct !DISubprogram(name: "inlinable", unit: !0)
+!7 = distinct !DISubprogram(name: "inlinable", type: !10, unit: !0)
 !8 = !DILocation(line: 3, scope: !1)

diff  --git a/llvm/test/Transforms/SimplifyCFG/tail-merge-noreturn.ll b/llvm/test/Transforms/SimplifyCFG/tail-merge-noreturn.ll
index 77ce7300e6752..3527eb12b0135 100644
--- a/llvm/test/Transforms/SimplifyCFG/tail-merge-noreturn.ll
+++ b/llvm/test/Transforms/SimplifyCFG/tail-merge-noreturn.ll
@@ -531,6 +531,8 @@ sw.epilog:                                        ; preds = %entry
 }
 
 !llvm.dbg.cu = !{!0}
+!15 = !{null}
+!16 = !DISubroutineType(types: !15)
 !llvm.module.flags = !{!3, !4, !5}
 
 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, runtimeVersion: 0, emissionKind: FullDebug)
@@ -538,7 +540,7 @@ sw.epilog:                                        ; preds = %entry
 !3 = !{i32 2, !"Dwarf Version", i32 4}
 !4 = !{i32 2, !"Debug Info Version", i32 3}
 !5 = !{i32 1, !"PIC Level", i32 2}
-!7 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 2, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true, unit: !0)
+!7 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 2, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true, type: !16, unit: !0)
 !12 = !DILocalVariable(name: "c", scope: !7)
 !13 = !DIExpression()
 !14 = !DILocation(line: 2, column: 12, scope: !7)

diff  --git a/llvm/test/Transforms/StripSymbols/find-live-cu.ll b/llvm/test/Transforms/StripSymbols/find-live-cu.ll
index 285f47ade30c1..91b2f43998c8a 100644
--- a/llvm/test/Transforms/StripSymbols/find-live-cu.ll
+++ b/llvm/test/Transforms/StripSymbols/find-live-cu.ll
@@ -15,6 +15,8 @@ define void @func() {
 }
 
 !llvm.dbg.cu = !{!0, !1}
+!12 = !{null}
+!13 = !DISubroutineType(types: !12)
 !llvm.module.flags = !{!10}
 
 
@@ -23,13 +25,13 @@ define void @func() {
 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !11)
 !1 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !11)
 
-!2 = distinct !DISubprogram(name: "func", unit: !0)
+!2 = distinct !DISubprogram(name: "func", type: !13, unit: !0)
 !3 = distinct !DICompositeType(tag: DW_TAG_class_type, scope: !2)
 !4 = !DIDerivedType(tag: DW_TAG_member, scope: !3, baseType: !5)
 !5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6)
 !6 = !DIBasicType(tag: DW_TAG_base_type)
 !7 = !DILocalVariable(name: "a", type: !5, scope: !8)
-!8 = distinct !DISubprogram(name: "func", unit: !1)
+!8 = distinct !DISubprogram(name: "func", type: !13, unit: !1)
 !9 = !DILocation(scope: !8)
 
 !10 = !{i32 2, !"Debug Info Version", i32 3}

diff  --git a/llvm/test/Transforms/Util/trivial-auto-var-init-call.ll b/llvm/test/Transforms/Util/trivial-auto-var-init-call.ll
index f34aa3e9f6799..e652293911ce7 100644
--- a/llvm/test/Transforms/Util/trivial-auto-var-init-call.ll
+++ b/llvm/test/Transforms/Util/trivial-auto-var-init-call.ll
@@ -617,12 +617,14 @@ declare void @llvm.memmove.element.unordered.atomic.p0.p0.i64(ptr nocapture writ
 declare void @bzero(ptr nocapture, i64) nofree nounwind
 declare ptr @memset(ptr, i32, i64)
 
+!8 = !{null}
+!9 = !DISubroutineType(types: !8)
 !llvm.module.flags = !{!1}
 !0 = !{ !"auto-init" }
 !1 = !{i32 2, !"Debug Info Version", i32 3}
 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3)
 !3 = !DIFile(filename: "file", directory: "")
-!4 = distinct !DISubprogram(name: "function", scope: !3, file: !3, unit: !2)
+!4 = distinct !DISubprogram(name: "function", scope: !3, file: !3, type: !9, unit: !2)
 !5 = !DIBasicType(name: "byte", size: 8)
 !6 = !DILocalVariable(name: "destination", scope: !4, file: !3, type: !5)
 !7 = !DILocalVariable(name: "destination2", scope: !4, file: !3, type: !5)

diff  --git a/llvm/test/Transforms/Util/trivial-auto-var-init-store.ll b/llvm/test/Transforms/Util/trivial-auto-var-init-store.ll
index d3355efe2efcd..2d329b8293433 100644
--- a/llvm/test/Transforms/Util/trivial-auto-var-init-store.ll
+++ b/llvm/test/Transforms/Util/trivial-auto-var-init-store.ll
@@ -223,12 +223,14 @@ l2:
 ; Function Attrs: nounwind readnone speculatable willreturn
 declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone speculatable willreturn
 
+!8 = !{null}
+!9 = !DISubroutineType(types: !8)
 !llvm.module.flags = !{!1}
 !0 = !{ !"auto-init" }
 !1 = !{i32 2, !"Debug Info Version", i32 3}
 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3)
 !3 = !DIFile(filename: "file", directory: "")
-!4 = distinct !DISubprogram(name: "function", scope: !3, file: !3, unit: !2)
+!4 = distinct !DISubprogram(name: "function", scope: !3, file: !3, type: !9, unit: !2)
 !5 = !DIBasicType(name: "int", size: 32)
 !6 = !DILocalVariable(name: "destination", scope: !4, file: !3, type: !5)
 !7 = !DILocalVariable(name: "destination2", scope: !4, file: !3, type: !5)

diff  --git a/llvm/test/Transforms/Util/trivial-auto-var-init-unknown.ll b/llvm/test/Transforms/Util/trivial-auto-var-init-unknown.ll
index 58ee56edd2ea3..5fa3cc8529733 100644
--- a/llvm/test/Transforms/Util/trivial-auto-var-init-unknown.ll
+++ b/llvm/test/Transforms/Util/trivial-auto-var-init-unknown.ll
@@ -35,12 +35,14 @@ define void @unknown_intrinsic(ptr %dst) {
 
 declare ptr @llvm.returnaddress(i32) nounwind readnone
 
+!8 = !{null}
+!9 = !DISubroutineType(types: !8)
 !llvm.module.flags = !{!1}
 !0 = !{ !"auto-init" }
 !1 = !{i32 2, !"Debug Info Version", i32 3}
 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3)
 !3 = !DIFile(filename: "file", directory: "")
-!4 = distinct !DISubprogram(name: "function", scope: !3, file: !3, unit: !2)
+!4 = distinct !DISubprogram(name: "function", scope: !3, file: !3, type: !9, unit: !2)
 !5 = !DIBasicType(name: "byte", size: 8)
 !6 = !DILocalVariable(name: "destination", scope: !4, file: !3, type: !5)
 !7 = !DILocalVariable(name: "destination2", scope: !4, file: !3, type: !5)

diff  --git a/llvm/test/Transforms/WholeProgramDevirt/devirt-single-impl.ll b/llvm/test/Transforms/WholeProgramDevirt/devirt-single-impl.ll
index d7f33df594956..550484ab6dafc 100644
--- a/llvm/test/Transforms/WholeProgramDevirt/devirt-single-impl.ll
+++ b/llvm/test/Transforms/WholeProgramDevirt/devirt-single-impl.ll
@@ -77,18 +77,20 @@ declare void @llvm.assume(i1)
 !2 = !{i32 2, !"Dwarf Version", i32 4}
 !3 = !{i32 2, !"Debug Info Version", i32 3}
 !4 = !{!"clang version 4.0.0 (trunk 278098)"}
-!5 = distinct !DISubprogram(name: "call", linkageName: "_Z4callPv", scope: !1, file: !1, line: 29, isLocal: false, isDefinition: true, scopeLine: 9, flags: DIFlagPrototyped, isOptimized: false, unit: !0)
+!5 = distinct !DISubprogram(name: "call", linkageName: "_Z4callPv", scope: !1, file: !1, line: 29, type: !15, isLocal: false, isDefinition: true, scopeLine: 9, flags: DIFlagPrototyped, isOptimized: false, unit: !0)
 !6 = !DILocation(line: 30, column: 32, scope: !5)
-!7 = distinct !DISubprogram(name: "vf", linkageName: "_ZN3vt12vfEv", scope: !1, file: !1, line: 13, isLocal: false, isDefinition: true, scopeLine: 13, flags: DIFlagPrototyped, isOptimized: false, unit: !0)
+!7 = distinct !DISubprogram(name: "vf", linkageName: "_ZN3vt12vfEv", scope: !1, file: !1, line: 13, type: !15, isLocal: false, isDefinition: true, scopeLine: 13, flags: DIFlagPrototyped, isOptimized: false, unit: !0)
 !8 = !{i32 0, !"typeid"}
 
-!9 = distinct !DISubprogram(name: "call2", linkageName: "_Z5call2Pv", scope: !1, file: !1, line: 40, isLocal: false, isDefinition: true, scopeLine: 9, flags: DIFlagPrototyped, isOptimized: false, unit: !0)
+!9 = distinct !DISubprogram(name: "call2", linkageName: "_Z5call2Pv", scope: !1, file: !1, line: 40, type: !15, isLocal: false, isDefinition: true, scopeLine: 9, flags: DIFlagPrototyped, isOptimized: false, unit: !0)
 !10 = !DILocation(line: 41, column: 32, scope: !9)
 !11 = !{i32 0, !"typeid2"}
 
-!12 = distinct !DISubprogram(name: "call3", linkageName: "_Z5call3Pv", scope: !1, file: !1, line: 50, isLocal: false, isDefinition: true, scopeLine: 9, flags: DIFlagPrototyped, isOptimized: false, unit: !0)
+!12 = distinct !DISubprogram(name: "call3", linkageName: "_Z5call3Pv", scope: !1, file: !1, line: 50, type: !15, isLocal: false, isDefinition: true, scopeLine: 9, flags: DIFlagPrototyped, isOptimized: false, unit: !0)
 !13 = !DILocation(line: 51, column: 32, scope: !12)
 !14 = !{i32 0, !"typeid3"}
+!15 = !DISubroutineType(types: !16)
+!16 = !{null}
 
 ; CHECK: 1 wholeprogramdevirt - Number of whole program devirtualization targets
 ; CHECK: 3 wholeprogramdevirt - Number of single implementation devirtualizations

diff  --git a/llvm/test/Transforms/WholeProgramDevirt/devirt_single_after_filtering_unreachable_function.ll b/llvm/test/Transforms/WholeProgramDevirt/devirt_single_after_filtering_unreachable_function.ll
index 1e420f13ae938..0f4053d9a90e2 100644
--- a/llvm/test/Transforms/WholeProgramDevirt/devirt_single_after_filtering_unreachable_function.ll
+++ b/llvm/test/Transforms/WholeProgramDevirt/devirt_single_after_filtering_unreachable_function.ll
@@ -58,5 +58,7 @@ declare void @llvm.trap()
 !5 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !6)
 !6 = !DIFile(filename: "tmp.cc", directory: "")
 !7 = !{i32 2, !"Debug Info Version", i32 3}
-!10= distinct !DISubprogram(name: "func", scope: !6, file: !6, unit: !5)
+!10= distinct !DISubprogram(name: "func", scope: !6, file: !6, unit: !5, type: !12)
 !11 = !DILocation(line: 21, column: 3, scope: !10)
+!12 = !DISubroutineType(types: !13)
+!13 = !{null}

diff  --git a/llvm/test/Transforms/WholeProgramDevirt/speculative-devirt-single-impl.ll b/llvm/test/Transforms/WholeProgramDevirt/speculative-devirt-single-impl.ll
index 10566ae0dee8e..0d30d09ccbb74 100644
--- a/llvm/test/Transforms/WholeProgramDevirt/speculative-devirt-single-impl.ll
+++ b/llvm/test/Transforms/WholeProgramDevirt/speculative-devirt-single-impl.ll
@@ -108,23 +108,25 @@ declare void @llvm.assume(i1)
 !2 = !{i32 2, !"Dwarf Version", i32 4}
 !3 = !{i32 2, !"Debug Info Version", i32 3}
 !4 = !{!"clang version 4.0.0 (trunk 278098)"}
-!5 = distinct !DISubprogram(name: "call", linkageName: "_Z4callPv", scope: !1, file: !1, line: 29, isLocal: false, isDefinition: true, scopeLine: 9, flags: DIFlagPrototyped, isOptimized: false, unit: !0)
+!5 = distinct !DISubprogram(name: "call", linkageName: "_Z4callPv", scope: !1, file: !1, line: 29, type: !19, isLocal: false, isDefinition: true, scopeLine: 9, flags: DIFlagPrototyped, isOptimized: false, unit: !0)
 !6 = !DILocation(line: 30, column: 32, scope: !5)
-!7 = distinct !DISubprogram(name: "vf", linkageName: "_ZN3vt12vfEv", scope: !1, file: !1, line: 13, isLocal: false, isDefinition: true, scopeLine: 13, flags: DIFlagPrototyped, isOptimized: false, unit: !0)
+!7 = distinct !DISubprogram(name: "vf", linkageName: "_ZN3vt12vfEv", scope: !1, file: !1, line: 13, type: !19, isLocal: false, isDefinition: true, scopeLine: 13, flags: DIFlagPrototyped, isOptimized: false, unit: !0)
 !8 = !{i32 0, !"typeid"}
 
-!9 = distinct !DISubprogram(name: "call1", linkageName: "_Z5call1Pv", scope: !1, file: !1, line: 31, isLocal: false, isDefinition: true, scopeLine: 9, flags: DIFlagPrototyped, isOptimized: false, unit: !0)
+!9 = distinct !DISubprogram(name: "call1", linkageName: "_Z5call1Pv", scope: !1, file: !1, line: 31, type: !19, isLocal: false, isDefinition: true, scopeLine: 9, flags: DIFlagPrototyped, isOptimized: false, unit: !0)
 !10 = !DILocation(line: 35, column: 32, scope: !9)
-!11 = distinct !DISubprogram(name: "vf_empty", linkageName: "_ZN3vt18vf_emptyEv", scope: !1, file: !1, line: 23, isLocal: false, isDefinition: true, scopeLine: 23, flags: DIFlagPrototyped, isOptimized: false, unit: !0)
+!11 = distinct !DISubprogram(name: "vf_empty", linkageName: "_ZN3vt18vf_emptyEv", scope: !1, file: !1, line: 23, type: !19, isLocal: false, isDefinition: true, scopeLine: 23, flags: DIFlagPrototyped, isOptimized: false, unit: !0)
 !12 = !{i32 0, !"typeid1"}
 
-!13 = distinct !DISubprogram(name: "call2", linkageName: "_Z5call2Pv", scope: !1, file: !1, line: 40, isLocal: false, isDefinition: true, scopeLine: 9, flags: DIFlagPrototyped, isOptimized: false, unit: !0)
+!13 = distinct !DISubprogram(name: "call2", linkageName: "_Z5call2Pv", scope: !1, file: !1, line: 40, type: !19, isLocal: false, isDefinition: true, scopeLine: 9, flags: DIFlagPrototyped, isOptimized: false, unit: !0)
 !14 = !DILocation(line: 41, column: 32, scope: !13)
 !15 = !{i32 0, !"typeid2"}
 
-!16 = distinct !DISubprogram(name: "call3", linkageName: "_Z5call3Pv", scope: !1, file: !1, line: 50, isLocal: false, isDefinition: true, scopeLine: 9, flags: DIFlagPrototyped, isOptimized: false, unit: !0)
+!16 = distinct !DISubprogram(name: "call3", linkageName: "_Z5call3Pv", scope: !1, file: !1, line: 50, type: !19, isLocal: false, isDefinition: true, scopeLine: 9, flags: DIFlagPrototyped, isOptimized: false, unit: !0)
 !17 = !DILocation(line: 51, column: 32, scope: !16)
 !18 = !{i32 0, !"typeid3"}
+!19 = !DISubroutineType(types: !20)
+!20 = !{null}
 
 
 

diff  --git a/llvm/test/Verifier/DISubprogram-type.ll b/llvm/test/Verifier/DISubprogram-type.ll
new file mode 100644
index 0000000000000..55a2082d68cfa
--- /dev/null
+++ b/llvm/test/Verifier/DISubprogram-type.ll
@@ -0,0 +1,47 @@
+; Verify that DISubprogram requires a non-null DISubroutineType for its
+; `type:` field. See https://github.com/llvm/llvm-project/issues/186557.
+
+; RUN: llvm-as -disable-output < %s 2>&1 | FileCheck %s
+
+; CHECK: DISubprogram requires a non-null type
+; CHECK-NEXT: ![[MISSING:[0-9]+]] = distinct !DISubprogram(name: "missing_type"
+; CHECK: DISubprogram requires a non-null type
+; CHECK-NEXT: ![[NULL:[0-9]+]] = distinct !DISubprogram(name: "null_type"
+; CHECK: invalid subroutine type
+; CHECK-NEXT: ![[INVALID:[0-9]+]] = distinct !DISubprogram(name: "invalid_type"
+; CHECK-NEXT: !{{[0-9]+}} = !DIFile(filename: "x.c", directory: "/")
+; CHECK: warning: ignoring invalid debug info
+; CHECK-NOT: valid_void_type
+
+define void @missing_type() !dbg !4 {
+  ret void, !dbg !5
+}
+
+define void @null_type() !dbg !7 {
+  ret void, !dbg !8
+}
+
+define void @invalid_type() !dbg !9 {
+  ret void, !dbg !10
+}
+
+define void @valid_void_type() !dbg !11 {
+  ret void, !dbg !12
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!13}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", emissionKind: FullDebug)
+!1 = !DIFile(filename: "x.c", directory: "/")
+!2 = !{null}
+!3 = !DISubroutineType(types: !2)
+!4 = distinct !DISubprogram(name: "missing_type", scope: !1, file: !1, line: 1, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0)
+!5 = !DILocation(line: 1, column: 1, scope: !4)
+!7 = distinct !DISubprogram(name: "null_type", scope: !1, file: !1, line: 2, type: null, scopeLine: 2, spFlags: DISPFlagDefinition, unit: !0)
+!8 = !DILocation(line: 2, column: 1, scope: !7)
+!9 = distinct !DISubprogram(name: "invalid_type", scope: !1, file: !1, line: 3, type: !1, scopeLine: 3, spFlags: DISPFlagDefinition, unit: !0)
+!10 = !DILocation(line: 3, column: 1, scope: !9)
+!11 = distinct !DISubprogram(name: "valid_void_type", scope: !1, file: !1, line: 4, type: !3, scopeLine: 4, spFlags: DISPFlagDefinition, unit: !0)
+!12 = !DILocation(line: 4, column: 1, scope: !11)
+!13 = !{i32 1, !"Debug Info Version", i32 3}

diff  --git a/llvm/test/Verifier/verify-dwarf-no-operands.ll b/llvm/test/Verifier/verify-dwarf-no-operands.ll
index aaa5c4b6af040..44817eae6cf99 100644
--- a/llvm/test/Verifier/verify-dwarf-no-operands.ll
+++ b/llvm/test/Verifier/verify-dwarf-no-operands.ll
@@ -19,7 +19,8 @@ define linkonce_odr noundef i64 @_ZNK4llvm9StringRef4sizeEv() align 2 !dbg !340
 !6 = !{i32 7, !"frame-pointer", i32 1}
 !7 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !8, sdk: "MacOSX14.0.sdk")
 !8 = !DIFile(filename: "file.cpp", directory: "/Users/Dev", checksumkind: CSK_MD5, checksum: "ed7ae158f20f7914bc5fb843291e80da")
-!12 = distinct !DISubprogram(unit: !7, retainedNodes: !36)
+!12 = distinct !DISubprogram(unit: !7, retainedNodes: !36, type: !400)
 !36 = !{}
 !284 = distinct !{}
-!340 = distinct !DISubprogram(unit: !7, retainedNodes: !36)
+!340 = distinct !DISubprogram(unit: !7, retainedNodes: !36, type: !400)
+!400 = !DISubroutineType(types: !36)

diff  --git a/llvm/test/tools/llvm-dwarfdump/X86/stats-dbg-callsite-info.ll b/llvm/test/tools/llvm-dwarfdump/X86/stats-dbg-callsite-info.ll
index 86a8a84ee7e59..7ca458932c386 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/stats-dbg-callsite-info.ll
+++ b/llvm/test/tools/llvm-dwarfdump/X86/stats-dbg-callsite-info.ll
@@ -52,8 +52,8 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
 !1 = !DIFile(filename: "test.c", directory: "/dir")
 !2 = !{}
 !3 = !{!4, !5}
-!4 = !DISubprogram(name: "getVal", scope: !1, file: !1, line: 2, spFlags: DISPFlagOptimized, retainedNodes: !2)
-!5 = !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
+!4 = !DISubprogram(name: "getVal", scope: !1, file: !1, line: 2, type: !11, spFlags: DISPFlagOptimized, retainedNodes: !2)
+!5 = !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !11, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
 !6 = !{i32 2, !"Dwarf Version", i32 4}
 !7 = !{i32 2, !"Debug Info Version", i32 3}
 !8 = !{i32 1, !"wchar_size", i32 4}

diff  --git a/llvm/unittests/IR/DebugInfoTest.cpp b/llvm/unittests/IR/DebugInfoTest.cpp
index fbf5a09b1a299..aaaa6216fa250 100644
--- a/llvm/unittests/IR/DebugInfoTest.cpp
+++ b/llvm/unittests/IR/DebugInfoTest.cpp
@@ -1273,10 +1273,12 @@ TEST(MetadataTest, InlinedAtMethodsWithMultipleLevels) {
     !2 = !{i32 2, !"Debug Info Version", i32 3}
 
     ; Subprograms for each function in the call chain
-    !10 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 100, unit: !0)
-    !11 = distinct !DISubprogram(name: "inline1", scope: !1, file: !1, line: 200, unit: !0)
-    !12 = distinct !DISubprogram(name: "inline2", scope: !1, file: !1, line: 300, unit: !0)
-    !13 = distinct !DISubprogram(name: "inline3", scope: !1, file: !1, line: 400, unit: !0)
+    !10 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 100, type: !14, unit: !0)
+    !11 = distinct !DISubprogram(name: "inline1", scope: !1, file: !1, line: 200, type: !14, unit: !0)
+    !12 = distinct !DISubprogram(name: "inline2", scope: !1, file: !1, line: 300, type: !14, unit: !0)
+    !13 = distinct !DISubprogram(name: "inline3", scope: !1, file: !1, line: 400, type: !14, unit: !0)
+    !14 = !DISubroutineType(types: !15)
+    !15 = !{null}
 
     ; Location in inline3 (line 401), inlined at location !21
     !20 = !DILocation(line: 401, column: 5, scope: !13, inlinedAt: !21)

diff  --git a/llvm/unittests/IR/ModuleTest.cpp b/llvm/unittests/IR/ModuleTest.cpp
index 2012398530707..e8c2ecfb9f3a8 100644
--- a/llvm/unittests/IR/ModuleTest.cpp
+++ b/llvm/unittests/IR/ModuleTest.cpp
@@ -385,7 +385,9 @@ define void @Foo1() {
 !1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang1", isOptimized: true, flags: "-O2", runtimeVersion: 0, splitDebugFilename: "abc.debug", emissionKind: LineTablesOnly)
 !2 = !DIFile(filename: "path/to/file1", directory: "/path/to/dir1")
 !3 = !DILocation(line: 12, column: 34, scope: !4)
-!4 = distinct !DISubprogram(name: "foo1", scope: null, spFlags: DISPFlagDefinition, unit: !1)
+!4 = distinct !DISubprogram(name: "foo1", scope: null, type: !5, spFlags: DISPFlagDefinition, unit: !1)
+!5 = !DISubroutineType(types: !6)
+!6 = !{null}
 )",
                                                    Err, Context);
   ASSERT_TRUE(M1.get());
@@ -411,7 +413,9 @@ define void @Foo2() {
 !1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang2", isOptimized: true, flags: "-O2", runtimeVersion: 0, splitDebugFilename: "abc.debug", emissionKind: LineTablesOnly)
 !2 = !DIFile(filename: "path/to/file2", directory: "/path/to/dir2")
 !3 = !DILocation(line: 1234, column: 56, scope: !4)
-!4 = distinct !DISubprogram(name: "foo2", scope: null, spFlags: DISPFlagDefinition, unit: !1)
+!4 = distinct !DISubprogram(name: "foo2", scope: null, type: !5, spFlags: DISPFlagDefinition, unit: !1)
+!5 = !DISubroutineType(types: !6)
+!6 = !{null}
 )";
   {
     std::unique_ptr<Module> M2 = parseAssemblyString(M2Str, Err, Context);

diff  --git a/llvm/unittests/IR/VerifierTest.cpp b/llvm/unittests/IR/VerifierTest.cpp
index 28a792a373b84..e99d2ccd2e548 100644
--- a/llvm/unittests/IR/VerifierTest.cpp
+++ b/llvm/unittests/IR/VerifierTest.cpp
@@ -259,8 +259,9 @@ TEST(VerifierTest, DetectInvalidDebugInfo) {
                                Function::ExternalLinkage, "f", M);
     IRBuilder<> Builder(BasicBlock::Create(C, "", F));
     Builder.CreateUnreachable();
+    auto *SPType = DIB.createSubroutineType(DIB.getOrCreateTypeArray({}));
     F->setSubprogram(DIB.createFunction(
-        CU, "f", "f", DIB.createFile("broken.c", "/"), 1, nullptr, 1,
+        CU, "f", "f", DIB.createFile("broken.c", "/"), 1, SPType, 1,
         DINode::FlagZero,
         DISubprogram::SPFlagLocalToUnit | DISubprogram::SPFlagDefinition));
     DIB.finalize();

diff  --git a/llvm/unittests/Transforms/Utils/CloningTest.cpp b/llvm/unittests/Transforms/Utils/CloningTest.cpp
index 8c138be840ed7..38888cd9e3666 100644
--- a/llvm/unittests/Transforms/Utils/CloningTest.cpp
+++ b/llvm/unittests/Transforms/Utils/CloningTest.cpp
@@ -780,11 +780,13 @@ TEST(CloneFunction, CloneFunctionWithSubprograms) {
     !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1)
     !1 = !DIFile(filename: "test.cpp",  directory: "")
     !2 = !{i32 1, !"Debug Info Version", i32 3}
-    !3 = distinct !DISubprogram(name: "my_operator", scope: !1, unit: !0, retainedNodes: !{!4})
+    !3 = distinct !DISubprogram(name: "my_operator", scope: !1, type: !8, unit: !0, retainedNodes: !{!4})
     !4 = !DILocalVariable(name: "awaitables", scope: !3)
-    !5 = distinct !DISubprogram(name: "test", scope: !3, unit: !0)
+    !5 = distinct !DISubprogram(name: "test", scope: !3, type: !8, unit: !0)
     !6 = !DILocation(line: 55, column: 15, scope: !3, inlinedAt: !7)
     !7 = distinct !DILocation(line: 73, column: 14, scope: !5)
+    !8 = !DISubroutineType(types: !9)
+    !9 = !{null}
   )";
 
   LLVMContext Context;
@@ -827,8 +829,8 @@ TEST(CloneFunction, CloneFunctionWithRetainedNodes) {
     !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, enums: !{!14})
     !1 = !DIFile(filename: "test.cpp",  directory: "")
     !2 = !{i32 1, !"Debug Info Version", i32 3}
-    !3 = distinct !DISubprogram(name: "test", scope: !1, unit: !0, retainedNodes: !9)
-    !4 = distinct !DISubprogram(name: "inlined", scope: !1, unit: !0, retainedNodes: !{!5})
+    !3 = distinct !DISubprogram(name: "test", scope: !1, type: !31, unit: !0, retainedNodes: !9)
+    !4 = distinct !DISubprogram(name: "inlined", scope: !1, type: !31, unit: !0, retainedNodes: !{!5})
     !5 = !DILocalVariable(name: "awaitables", scope: !4, type: !23)
     !6 = distinct !DILexicalBlock(scope: !4, file: !1, line: 1)
     !7 = !DILocation(line: 1, scope: !6, inlinedAt: !8)
@@ -849,6 +851,8 @@ TEST(CloneFunction, CloneFunctionWithRetainedNodes) {
     !28 = !DILocalVariable(name: "ptr", scope: !3, type: !27)
     !29 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !27)
     !30 = !DILocalVariable(name: "const_ptr", scope: !3, type: !29)
+    !31 = !DISubroutineType(types: !32)
+    !32 = !{null}
   )";
 
   LLVMContext Context;
@@ -963,12 +967,14 @@ TEST(CloneFunction, CloneFunctionWithInlinedSubprograms) {
     !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1)
     !1 = !DIFile(filename: "test.cpp",  directory: "")
     !2 = !{i32 1, !"Debug Info Version", i32 3}
-    !3 = distinct !DISubprogram(name: "test", scope: !0, unit: !0)
-    !4 = distinct !DISubprogram(name: "inlined", scope: !0, unit: !0, retainedNodes: !{!5})
+    !3 = distinct !DISubprogram(name: "test", scope: !0, type: !9, unit: !0)
+    !4 = distinct !DISubprogram(name: "inlined", scope: !0, type: !9, unit: !0, retainedNodes: !{!5})
     !5 = !DILocalVariable(name: "awaitables", scope: !4)
     !6 = distinct !DILexicalBlock(scope: !4, file: !1, line: 1)
     !7 = !DILocation(line: 1, scope: !6, inlinedAt: !8)
     !8 = !DILocation(line: 10, scope: !3)
+    !9 = !DISubroutineType(types: !10)
+    !10 = !{null}
   )";
 
   LLVMContext Context;
@@ -1009,12 +1015,14 @@ TEST(CloneFunction, CloneFunctionToDifferentModule) {
     !llvm.module.flags = !{!0}
     !llvm.dbg.cu = !{!2, !6}
     !0 = !{i32 1, !"Debug Info Version", i32 3}
-    !1 = distinct !DISubprogram(unit: !2)
+    !1 = distinct !DISubprogram(type: !7, unit: !2)
     !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3)
     !3 = !DIFile(filename: "foo.c", directory: "/tmp")
-    !4 = distinct !DISubprogram(unit: !2)
+    !4 = distinct !DISubprogram(type: !7, unit: !2)
     !5 = !DILocation(line: 4, scope: !1)
     !6 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3)
+    !7 = !DISubroutineType(types: !8)
+    !8 = !{null}
   )";
   StringRef DeclAssembly = R"(
     declare void @foo()
@@ -1333,13 +1341,15 @@ TEST_F(CloneInstruction, cloneKeyInstructions) {
     !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1)
     !1 = !DIFile(filename: "test.cpp",  directory: "")
     !2 = !{i32 1, !"Debug Info Version", i32 3}
-    !3 = distinct !DISubprogram(name: "test", scope: !0, unit: !0, keyInstructions: true)
-    !4 = distinct !DISubprogram(name: "inlined", scope: !0, unit: !0, retainedNodes: !{!5}, keyInstructions: true)
+    !3 = distinct !DISubprogram(name: "test", scope: !0, type: !10, unit: !0, keyInstructions: true)
+    !4 = distinct !DISubprogram(name: "inlined", scope: !0, type: !10, unit: !0, retainedNodes: !{!5}, keyInstructions: true)
     !5 = !DILocalVariable(name: "awaitables", scope: !4)
     !6 = !DILocation(line: 1, scope: !4, inlinedAt: !8, atomGroup: 1, atomRank: 1)
     !7 = !DILocation(line: 2, scope: !3, atomGroup: 1, atomRank: 1)
     !8 = !DILocation(line: 3, scope: !3, atomGroup: 1, atomRank: 1)
     !9 = !DILocation(line: 4, scope: !3, atomGroup: 2, atomRank: 1)
+    !10 = !DISubroutineType(types: !11)
+    !11 = !{null}
   )");
 
   ASSERT_FALSE(verifyModule(*M, &errs()));

diff  --git a/mlir/test/Dialect/LLVMIR/di-expression-legalization.mlir b/mlir/test/Dialect/LLVMIR/di-expression-legalization.mlir
index 9280154ad557a..800c3548e5ad5 100644
--- a/mlir/test/Dialect/LLVMIR/di-expression-legalization.mlir
+++ b/mlir/test/Dialect/LLVMIR/di-expression-legalization.mlir
@@ -3,7 +3,9 @@
 
 #di_file = #llvm.di_file<"foo.c" in "/mlir/">
 #di_compile_unit = #llvm.di_compile_unit<id = distinct[0]<>, sourceLanguage = DW_LANG_C, file = #di_file, producer = "MLIR", isOptimized = true, emissionKind = Full>
-#di_subprogram = #llvm.di_subprogram<compileUnit = #di_compile_unit, scope = #di_file, name = "simplify", file = #di_file, subprogramFlags = Definition>
+#void_return = #llvm.di_null_type
+#void_type = #llvm.di_subroutine_type<types = #void_return>
+#di_subprogram = #llvm.di_subprogram<compileUnit = #di_compile_unit, scope = #di_file, name = "simplify", file = #di_file, subprogramFlags = Definition, type = #void_type>
 #i32_type = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "i32", sizeInBits = 32, encoding = DW_ATE_unsigned>
 #i8_type = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "i8", sizeInBits = 8, encoding = DW_ATE_unsigned>
 

diff  --git a/mlir/test/Target/LLVMIR/Import/debug-info.ll b/mlir/test/Target/LLVMIR/Import/debug-info.ll
index 0465f608a90cc..81efa2bb1f181 100644
--- a/mlir/test/Target/LLVMIR/Import/debug-info.ll
+++ b/mlir/test/Target/LLVMIR/Import/debug-info.ll
@@ -44,11 +44,13 @@ define i32 @instruction_loc(i32 %arg1) {
 !0 = !{i32 2, !"Debug Info Version", i32 3}
 !1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
 !2 = !DIFile(filename: "debug-info.ll", directory: "/")
-!3 = distinct !DISubprogram(name: "instruction_loc", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1)
-!4 = distinct !DISubprogram(name: "callee", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1)
+!3 = distinct !DISubprogram(name: "instruction_loc", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1, type: !999)
+!4 = distinct !DISubprogram(name: "callee", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1, type: !999)
 !5 = !DILocation(line: 1, column: 2, scope: !3)
 !6 = !DILocation(line: 2, column: 2, scope: !3)
 !7 = !DILocation(line: 7, column: 4, scope: !4, inlinedAt: !6)
+!999 = !DISubroutineType(types: !1000)
+!1000 = !{null}
 
 ; // -----
 
@@ -74,11 +76,13 @@ define i32 @lexical_block(i32 %arg1) {
 !0 = !{i32 2, !"Debug Info Version", i32 3}
 !1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
 !2 = !DIFile(filename: "debug-info.ll", directory: "/")
-!3 = distinct !DISubprogram(name: "lexical_block", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1)
+!3 = distinct !DISubprogram(name: "lexical_block", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1, type: !999)
 !4 = !DILexicalBlock(scope: !3)
 !5 = !DILexicalBlock(scope: !3, file: !2, line: 2, column: 2)
 !6 = !DILocation(line: 1, column: 2, scope: !4)
 !7 = !DILocation(line: 2, column: 2, scope: !5)
+!999 = !DISubroutineType(types: !1000)
+!1000 = !{null}
 
 ; // -----
 
@@ -104,11 +108,13 @@ define i32 @lexical_block_file(i32 %arg1) {
 !0 = !{i32 2, !"Debug Info Version", i32 3}
 !1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
 !2 = !DIFile(filename: "debug-info.ll", directory: "/")
-!3 = distinct !DISubprogram(name: "lexical_block_file", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1)
+!3 = distinct !DISubprogram(name: "lexical_block_file", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1, type: !999)
 !4 = !DILexicalBlockFile(scope: !3, discriminator: 0)
 !5 = !DILexicalBlockFile(scope: !3, file: !2, discriminator: 0)
 !6 = !DILocation(line: 1, column: 2, scope: !4)
 !7 = !DILocation(line: 2, column: 2, scope: !5)
+!999 = !DISubroutineType(types: !1000)
+!1000 = !{null}
 
 ; // -----
 
@@ -214,7 +220,6 @@ define void @composite_type() !dbg !3 {
 !28 = !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 32, DW_OP_deref)
 !29 = !{!25}
 
-
 ; // -----
 
 ; CHECK-DAG: #[[FILE:.+]] = #llvm.di_file<"debug-info.ll" in "/">
@@ -244,7 +249,7 @@ define void @func_loc() !dbg !3 {
   ret void
 }
 ; CHECK-DAG: #[[FILE_LOC:.+]] = loc("debug-info.ll":42:0)
-; CHECK-DAG: #[[SP:.+]] =  #llvm.di_subprogram<id = distinct[{{.*}}]<>, compileUnit = #{{.*}}, scope = #{{.*}}, name = "func_loc", file = #{{.*}}, line = 42, subprogramFlags = Definition>
+; CHECK-DAG: #[[SP:.+]] =  #llvm.di_subprogram<id = distinct[{{.*}}]<>, compileUnit = #{{.*}}, scope = #{{.*}}, name = "func_loc", file = #{{.*}}, line = 42, subprogramFlags = Definition, type = #{{.*}}>
 
 ; CHECK: loc(fused<#[[SP]]>[#[[FILE_LOC]]]
 
@@ -253,7 +258,9 @@ define void @func_loc() !dbg !3 {
 !0 = !{i32 2, !"Debug Info Version", i32 3}
 !1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
 !2 = !DIFile(filename: "debug-info.ll", directory: "/")
-!3 = distinct !DISubprogram(name: "func_loc", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1, line: 42)
+!3 = distinct !DISubprogram(name: "func_loc", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1, line: 42, type: !999)
+!999 = !DISubroutineType(types: !1000)
+!1000 = !{null}
 
 ; // -----
 
@@ -267,28 +274,28 @@ source_filename = "debug-info.ll"
 ;       preserving measures needed to import LLVM IR.
 
 ; CHECK: #[[FILE:.+]] = #llvm.di_file<
-; CHECK: #[[$SP:.+]] = #llvm.di_subprogram<
-; CHECK: #[[$LABEL:.+]] = #llvm.di_label<scope = #[[$SP]], name = "label", file = #[[FILE]], line = 42>
-; CHECK: #[[$VAR1:.+]] = #llvm.di_local_variable<scope = #[[$SP]], name = "arg">
-; CHECK: #[[$VAR0:.+]] = #llvm.di_local_variable<scope = #[[$SP]], name = "arg", file = #[[FILE]], line = 1, arg = 1, alignInBits = 32, type = #{{.*}}>
+; CHECK: #[[SP:.+]] = #llvm.di_subprogram<
+; CHECK: #[[LABEL:.+]] = #llvm.di_label<scope = #[[SP]], name = "label", file = #[[FILE]], line = 42>
+; CHECK: #[[VAR1:.+]] = #llvm.di_local_variable<scope = #[[SP]], name = "arg">
+; CHECK: #[[VAR0:.+]] = #llvm.di_local_variable<scope = #[[SP]], name = "arg", file = #[[FILE]], line = 1, arg = 1, alignInBits = 32, type = #{{.*}}>
 
 ; CHECK-LABEL: @intrinsic
 ; CHECK-SAME:  %[[ARG0:[a-zA-Z0-9]+]]
 ; CHECK-SAME:  %[[ARG1:[a-zA-Z0-9]+]]
 define void @intrinsic(i64 %0, ptr %1) {
-  ; CHECK: llvm.intr.dbg.declare #[[$VAR1]] = %[[ARG1]] : !llvm.ptr loc(#[[LOC1:.+]])
-  ; CHECK: llvm.intr.dbg.value #[[$VAR0]] #llvm.di_expression<[DW_OP_deref, DW_OP_constu(3), DW_OP_plus, DW_OP_LLVM_convert(4, DW_ATE_signed)]> = %[[ARG0]] : i64 loc(#[[LOC0:.+]])
-  ; CHECK: llvm.intr.dbg.value #[[$VAR0]] #llvm.di_expression<[DW_OP_deref, DW_OP_constu(3), DW_OP_plus, DW_OP_LLVM_fragment(3, 7)]> = %[[ARG0]] : i64 loc(#[[LOC0:.+]])
+  ; CHECK: llvm.intr.dbg.declare #di_local_variable{{[0-9]*}} = %[[ARG1]] : !llvm.ptr loc(#[[LOC1:.+]])
+  ; CHECK: llvm.intr.dbg.value #di_local_variable{{[0-9]*}} #llvm.di_expression<[DW_OP_deref, DW_OP_constu(3), DW_OP_plus, DW_OP_LLVM_convert(4, DW_ATE_signed)]> = %[[ARG0]] : i64 loc(#[[LOC0:.+]])
+  ; CHECK: llvm.intr.dbg.value #di_local_variable{{[0-9]*}} #llvm.di_expression<[DW_OP_deref, DW_OP_constu(3), DW_OP_plus, DW_OP_LLVM_fragment(3, 7)]> = %[[ARG0]] : i64 loc(#[[LOC0:.+]])
   call void @llvm.dbg.value(metadata i64 %0, metadata !5, metadata !DIExpression(DW_OP_deref, DW_OP_constu, 3, DW_OP_plus, DW_OP_LLVM_fragment, 3, 7)), !dbg !7
   call void @llvm.dbg.value(metadata i64 %0, metadata !5, metadata !DIExpression(DW_OP_deref, DW_OP_constu, 3, DW_OP_plus, DW_OP_LLVM_convert, 4, DW_ATE_signed)), !dbg !7
   call void @llvm.dbg.declare(metadata ptr %1, metadata !6, metadata !DIExpression()), !dbg !9
-  ; CHECK: llvm.intr.dbg.label #[[$LABEL]] loc(#[[LOC1:.+]])
+  ; CHECK: llvm.intr.dbg.label #di_label{{[0-9]*}} loc(#[[LOC1:.+]])
   call void @llvm.dbg.label(metadata !10), !dbg !9
   ret void
 }
 
-; CHECK: #[[LOC1]] = loc(fused<#[[$SP]]>[{{.*}}])
-; CHECK: #[[LOC0]] = loc(fused<#[[$SP]]>[{{.*}}])
+; CHECK: #[[LOC1]] = loc(fused<#di_subprogram>[{{.*}}])
+; CHECK: #[[LOC0]] = loc(fused<#di_subprogram>[{{.*}}])
 
 declare void @llvm.dbg.value(metadata, metadata, metadata)
 declare void @llvm.dbg.declare(metadata, metadata, metadata)
@@ -299,7 +306,7 @@ declare void @llvm.dbg.label(metadata)
 !0 = !{i32 2, !"Debug Info Version", i32 3}
 !1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
 !2 = !DIFile(filename: "debug-info.ll", directory: "/")
-!3 = distinct !DISubprogram(name: "intrinsic", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1)
+!3 = distinct !DISubprogram(name: "intrinsic", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1, type: !999)
 !4 = !DIBasicType(name: "int")
 !5 = !DILocalVariable(scope: !3, name: "arg", file: !2, line: 1, arg: 1, align: 32, type: !4);
 !6 = !DILocalVariable(scope: !3, name: "arg")
@@ -307,6 +314,8 @@ declare void @llvm.dbg.label(metadata)
 !8 = !DILocation(line: 2, column: 2, scope: !3)
 !9 = !DILocation(line: 3, column: 2, scope: !3)
 !10 = !DILabel(scope: !3, name: "label", file: !2, line: 42)
+!999 = !DISubroutineType(types: !1000)
+!1000 = !{null}
 
 ; // -----
 
@@ -367,8 +376,10 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
 !5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !3, flags: DIFlagArtificial | DIFlagObjectPointer)
 !6 = !DIDerivedType(tag: DW_TAG_member, name: "call_field", file: !2, baseType: !5)
 !7 = !DILocalVariable(scope: !8, name: "class_field", file: !2, type: !5);
-!8 = distinct !DISubprogram(name: "class_field", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1)
+!8 = distinct !DISubprogram(name: "class_field", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1, type: !999)
 !9 = !DILocation(line: 1, column: 2, scope: !8)
+!999 = !DISubroutineType(types: !1000)
+!1000 = !{null}
 
 ; // -----
 
@@ -408,8 +419,10 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
 !5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !3, flags: DIFlagArtificial | DIFlagObjectPointer)
 !6 = !DIDerivedType(tag: DW_TAG_member, name: "call_field", file: !2, baseType: !5)
 !7 = !DILocalVariable(scope: !8, name: "var", file: !2, type: !5);
-!8 = distinct !DISubprogram(name: "dbg_use_before_def", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1)
+!8 = distinct !DISubprogram(name: "dbg_use_before_def", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1, type: !999)
 !9 = !DILocation(line: 1, column: 2, scope: !8)
+!999 = !DISubroutineType(types: !1000)
+!1000 = !{null}
 
 ; // -----
 
@@ -442,8 +455,10 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
 !5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !3, flags: DIFlagArtificial | DIFlagObjectPointer)
 !6 = !DIDerivedType(tag: DW_TAG_member, name: "call_field", file: !2, baseType: !5)
 !7 = !DILocalVariable(scope: !8, name: "var", file: !2, type: !5);
-!8 = distinct !DISubprogram(name: "dbg_use_before_def", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1)
+!8 = distinct !DISubprogram(name: "dbg_use_before_def", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1, type: !999)
 !9 = !DILocation(line: 1, column: 2, scope: !8)
+!999 = !DISubroutineType(types: !1000)
+!1000 = !{null}
 
 ; // -----
 
@@ -472,8 +487,10 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
 !1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
 !2 = !DIFile(filename: "debug-info.ll", directory: "/")
 !7 = !DILocalVariable(scope: !8, name: "var", file: !2);
-!8 = distinct !DISubprogram(name: "dbg_broken_dominance_invoke", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1)
+!8 = distinct !DISubprogram(name: "dbg_broken_dominance_invoke", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1, type: !999)
 !9 = !DILocation(line: 1, column: 2, scope: !8)
+!999 = !DISubroutineType(types: !1000)
+!1000 = !{null}
 
 ; // -----
 
@@ -503,8 +520,10 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
 !1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
 !2 = !DIFile(filename: "debug-info.ll", directory: "/")
 !7 = !DILocalVariable(scope: !8, name: "var", file: !2);
-!8 = distinct !DISubprogram(name: "dbg_broken_dominance_invoke", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1)
+!8 = distinct !DISubprogram(name: "dbg_broken_dominance_invoke", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1, type: !999)
 !9 = !DILocation(line: 1, column: 2, scope: !8)
+!999 = !DISubroutineType(types: !1000)
+!1000 = !{null}
 
 ; // -----
 
@@ -524,9 +543,11 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
 !1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
 !2 = !DIFile(filename: "debug-info.ll", directory: "/")
 !7 = !DILocalVariable(scope: !8, name: "var")
-!8 = distinct !DISubprogram(name: "namespace", scope: !10, file: !2, unit: !1);
+!8 = distinct !DISubprogram(name: "namespace", scope: !10, file: !2, unit: !1, type: !999);
 !9 = !DILocation(line: 1, column: 2, scope: !8)
 !10 = !DINamespace(name: "std", scope: null)
+!999 = !DISubroutineType(types: !1000)
+!1000 = !{null}
 
 ; // -----
 
@@ -546,12 +567,14 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
 !1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
 !2 = !DIFile(filename: "debug-info.ll", directory: "/")
 !7 = !DILocalVariable(scope: !8)
-!8 = distinct !DISubprogram(name: "noname_variable", scope: !2, file: !2, unit: !1);
+!8 = distinct !DISubprogram(name: "noname_variable", scope: !2, file: !2, unit: !1, type: !999);
 !9 = !DILocation(line: 1, column: 2, scope: !8)
+!999 = !DISubroutineType(types: !1000)
+!1000 = !{null}
 
 ; // -----
 
-; CHECK: #[[SUBPROGRAM:.*]] = #llvm.di_subprogram<id = distinct[{{.*}}]<>, compileUnit = #{{.*}}, scope = #{{.*}}, file = #{{.*}}, subprogramFlags = Definition>
+; CHECK: #[[SUBPROGRAM:.*]] = #llvm.di_subprogram<id = distinct[{{.*}}]<>, compileUnit = #{{.*}}, scope = #{{.*}}, file = #{{.*}}, subprogramFlags = Definition, type = #{{.*}}>
 ; CHECK: #[[FUNC_LOC:.*]] = loc(fused<#[[SUBPROGRAM]]>[{{.*}}])
 define void @noname_subprogram(ptr %arg) !dbg !8 {
   ret void
@@ -562,7 +585,9 @@ define void @noname_subprogram(ptr %arg) !dbg !8 {
 !0 = !{i32 2, !"Debug Info Version", i32 3}
 !1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
 !2 = !DIFile(filename: "debug-info.ll", directory: "/")
-!8 = distinct !DISubprogram(scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1);
+!8 = distinct !DISubprogram(scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1, type: !999);
+!999 = !DISubroutineType(types: !1000)
+!1000 = !{null}
 
 ; // -----
 
@@ -582,8 +607,10 @@ define void @func_in_module(ptr %arg) !dbg !8 {
 !0 = !{i32 2, !"Debug Info Version", i32 3}
 !1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
 !2 = !DIFile(filename: "debug-info.ll", directory: "/")
-!8 = distinct !DISubprogram(name: "func_in_module", scope: !10, file: !2, unit: !1);
+!8 = distinct !DISubprogram(name: "func_in_module", scope: !10, file: !2, unit: !1, type: !999);
 !10 = !DIModule(scope: !2, name: "module", configMacros: "bar", includePath: "/", apinotes: "/", file: !2, line: 42, isDecl: true)
+!999 = !DISubroutineType(types: !1000)
+!1000 = !{null}
 
 ; // -----
 
@@ -606,9 +633,11 @@ define void @distinct_cu_func1() !dbg !5 {
 !1 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !2, producer: "clang")
 !2 = !DIFile(filename: "other.cpp", directory: "/")
 !3 = !{i32 2, !"Debug Info Version", i32 3}
-!4 = distinct !DISubprogram(name: "func", linkageName: "func", scope: !6, file: !6, line: 1, scopeLine: 1, flags: DIFlagArtificial, spFlags: DISPFlagDefinition, unit: !0)
-!5 = distinct !DISubprogram(name: "func", linkageName: "func", scope: !6, file: !6, line: 1, scopeLine: 1, flags: DIFlagArtificial, spFlags: DISPFlagDefinition, unit: !1)
+!4 = distinct !DISubprogram(name: "func", linkageName: "func", scope: !6, file: !6, line: 1, scopeLine: 1, flags: DIFlagArtificial, spFlags: DISPFlagDefinition, unit: !0, type: !999)
+!5 = distinct !DISubprogram(name: "func", linkageName: "func", scope: !6, file: !6, line: 1, scopeLine: 1, flags: DIFlagArtificial, spFlags: DISPFlagDefinition, unit: !1, type: !999)
 !6 = !DIFile(filename: "file.hpp", directory: "/")
+!999 = !DISubroutineType(types: !1000)
+!1000 = !{null}
 
 ; // -----
 
@@ -622,8 +651,10 @@ declare !dbg !1 void @declaration()
 
 !llvm.module.flags = !{!0}
 !0 = !{i32 2, !"Debug Info Version", i32 3}
-!1 = !DISubprogram(name: "declaration", scope: !2, file: !2, flags: DIFlagPrototyped, spFlags: 0)
+!1 = !DISubprogram(name: "declaration", scope: !2, file: !2, flags: DIFlagPrototyped, spFlags: 0, type: !999)
 !2 = !DIFile(filename: "debug-info.ll", directory: "/")
+!999 = !DISubroutineType(types: !1000)
+!1000 = !{null}
 
 ; // -----
 
@@ -668,7 +699,9 @@ define void @class_field(ptr %arg1) !dbg !18 {
 !8 = !DIDerivedType(tag: DW_TAG_member, name: "B:B2", file: !2, baseType: !5)
 !9 = !{!7, !8}
 
-!18 = distinct !DISubprogram(name: "A", scope: !3, file: !2, spFlags: DISPFlagDefinition, unit: !1)
+!18 = distinct !DISubprogram(name: "A", scope: !3, file: !2, spFlags: DISPFlagDefinition, unit: !1, type: !999)
+!999 = !DISubroutineType(types: !1000)
+!1000 = !{null}
 
 ; // -----
 
@@ -713,7 +746,9 @@ define void @class_field(ptr %arg1) !dbg !18 {
 !9 = !{!7}
 !10 = !{!8}
 
-!18 = distinct !DISubprogram(name: "SP", scope: !3, file: !2, spFlags: DISPFlagDefinition, unit: !1)
+!18 = distinct !DISubprogram(name: "SP", scope: !3, file: !2, spFlags: DISPFlagDefinition, unit: !1, type: !999)
+!999 = !DISubroutineType(types: !1000)
+!1000 = !{null}
 
 ; // -----
 
@@ -764,7 +799,9 @@ define void @class_field(ptr %arg1) !dbg !18 {
 !10 = !{!8} ; B -> C
 !11 = !{!6, !7, !8} ; C -> A, B, C
 
-!18 = distinct !DISubprogram(name: "SP", scope: !3, file: !2, spFlags: DISPFlagDefinition, unit: !1)
+!18 = distinct !DISubprogram(name: "SP", scope: !3, file: !2, spFlags: DISPFlagDefinition, unit: !1, type: !999)
+!999 = !DISubroutineType(types: !1000)
+!1000 = !{null}
 
 ; // -----
 
@@ -885,7 +922,7 @@ define void @test() !dbg !3 {
 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
 !1 = distinct !DIGlobalVariable(name: "alpha", scope: !2, file: !4, type: !9)
 !2 = !DICommonBlock(scope: !3, declaration: null, name: "block", file: !4, line: 3)
-!3 = distinct !DISubprogram(name: "test", scope: !4, file: !4, spFlags: DISPFlagDefinition, unit: !7)
+!3 = distinct !DISubprogram(name: "test", scope: !4, file: !4, spFlags: DISPFlagDefinition, unit: !7, type: !999)
 !4 = !DIFile(filename: "test.f90", directory: "")
 !7 = distinct !DICompileUnit(language: DW_LANG_Fortran95, file: !4)
 !9 = !DIBasicType(name: "integer", size: 32, encoding: DW_ATE_signed)
@@ -894,6 +931,8 @@ define void @test() !dbg !3 {
 ; CHECK: #[[FILE:.+]] = #llvm.di_file<"test.f90" in "">
 ; CHECK: #[[SP:.+]] = #llvm.di_subprogram<{{.*}}name = "test"{{.*}}>
 ; CHECK: #llvm.di_common_block<scope = #[[SP]], name = "block", file = #[[FILE]], line = 3>
+!999 = !DISubroutineType(types: !1000)
+!1000 = !{null}
 
 ; // -----
 

diff  --git a/mlir/test/Target/LLVMIR/Import/exception.ll b/mlir/test/Target/LLVMIR/Import/exception.ll
index 57c4bce5c6c72..6165032ae7c39 100644
--- a/mlir/test/Target/LLVMIR/Import/exception.ll
+++ b/mlir/test/Target/LLVMIR/Import/exception.ll
@@ -182,12 +182,14 @@ bb3:
 !0 = !{i32 2, !"Debug Info Version", i32 3}
 !1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
 !2 = !DIFile(filename: "landingpad.ll", directory: "/")
-!3 = distinct !DISubprogram(name: "instruction_loc", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1)
-!4 = distinct !DISubprogram(name: "callee", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1)
+!3 = distinct !DISubprogram(name: "instruction_loc", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1, type: !999)
+!4 = distinct !DISubprogram(name: "callee", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1, type: !999)
 !5 = !DILocation(line: 1, column: 2, scope: !3)
 !6 = !DILocation(line: 2, column: 2, scope: !3)
 !7 = !DILocation(line: 7, column: 4, scope: !4, inlinedAt: !6)
 !8 = !DILocalVariable(scope: !4, name: "size")
+!999 = !DISubroutineType(types: !1000)
+!1000 = !{null}
 
 ; // -----
 

diff  --git a/mlir/test/Target/LLVMIR/Import/import-failure.ll b/mlir/test/Target/LLVMIR/Import/import-failure.ll
index 32f730b545405..b468a3e95c907 100644
--- a/mlir/test/Target/LLVMIR/Import/import-failure.ll
+++ b/mlir/test/Target/LLVMIR/Import/import-failure.ll
@@ -18,9 +18,11 @@ define void @unsupported_argument(i64 %arg1) {
 !1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
 !2 = !DIFile(filename: "import-failure.ll", directory: "/")
 !3 = !DILocalVariable(scope: !4, name: "arg1", file: !2, line: 1, arg: 1, align: 64);
-!4 = distinct !DISubprogram(name: "intrinsic", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1)
+!4 = distinct !DISubprogram(name: "intrinsic", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1, type: !999)
 !5 = !DILocation(line: 1, column: 2, scope: !4)
 !6 = !{}
+!999 = !DISubroutineType(types: !1000)
+!1000 = !{null}
 
 ; // -----
 

diff  --git a/mlir/test/Target/LLVMIR/Import/metadata-loop.ll b/mlir/test/Target/LLVMIR/Import/metadata-loop.ll
index 20431a7412bd1..c09fe92dc9cdc 100644
--- a/mlir/test/Target/LLVMIR/Import/metadata-loop.ll
+++ b/mlir/test/Target/LLVMIR/Import/metadata-loop.ll
@@ -366,9 +366,11 @@ end:
 !0 = !{i32 2, !"Debug Info Version", i32 3}
 !1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
 !2 = !DIFile(filename: "metadata-loop.ll", directory: "/")
-!3 = distinct !DISubprogram(name: "loop_locs", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1)
+!3 = distinct !DISubprogram(name: "loop_locs", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1, type: !999)
 !4 = !DILocation(line: 1, column: 2, scope: !3)
 !5 = !DILocation(line: 2, column: 2, scope: !3)
 
 !6 = distinct !{!6, !4, !5, !7}
 !7 = !{!"llvm.loop.mustprogress"}
+!999 = !DISubroutineType(types: !1000)
+!1000 = !{null}

diff  --git a/mlir/test/Target/LLVMIR/llvmir-debug.mlir b/mlir/test/Target/LLVMIR/llvmir-debug.mlir
index 9b1dad2910dba..78a6ba3f14a8b 100644
--- a/mlir/test/Target/LLVMIR/llvmir-debug.mlir
+++ b/mlir/test/Target/LLVMIR/llvmir-debug.mlir
@@ -198,16 +198,20 @@ llvm.func @empty_types() {
 // -----
 
 #di_file = #llvm.di_file<"foo.mlir" in "/test/">
+#void_return = #llvm.di_null_type
+#void_type = #llvm.di_subroutine_type<types = #void_return>
 #di_subprogram = #llvm.di_subprogram<
-  scope = #di_file, name = "func_decl_with_subprogram", file = #di_file
+  scope = #di_file, name = "func_decl_with_subprogram", file = #di_file,
+  type = #void_type
 >
 
 // CHECK-LABEL: declare !dbg
 // CHECK-SAME: ![[SUBPROGRAM:.*]] i32 @func_decl_with_subprogram(
 llvm.func @func_decl_with_subprogram() -> (i32) loc(fused<#di_subprogram>["foo.mlir":2:1])
 
-// CHECK: ![[SUBPROGRAM]] = !DISubprogram(name: "func_decl_with_subprogram", scope: ![[FILE:.*]], file: ![[FILE]], spFlags: 0)
+// CHECK: ![[SUBPROGRAM]] = !DISubprogram(name: "func_decl_with_subprogram", scope: ![[FILE:.*]], file: ![[FILE]], type: ![[TYPE:.*]], spFlags: 0)
 // CHECK: ![[FILE]] = !DIFile(filename: "foo.mlir", directory: "/test/")
+// CHECK: ![[TYPE]] = !DISubroutineType
 
 // -----
 
@@ -217,13 +221,17 @@ llvm.func @func_decl_with_subprogram() -> (i32) loc(fused<#di_subprogram>["foo.m
   id = distinct[0]<>, sourceLanguage = DW_LANG_C, file = #di_file,
   producer = "MLIR", isOptimized = true, emissionKind = Full, isDebugInfoForProfiling = true
 >
+#void_return = #llvm.di_null_type
+#void_type = #llvm.di_subroutine_type<types = #void_return>
 #di_subprogram = #llvm.di_subprogram<
   compileUnit = #di_compile_unit, scope = #di_file, name = "outer_func",
-  file = #di_file, subprogramFlags = "Definition|Optimized"
+  file = #di_file, subprogramFlags = "Definition|Optimized",
+  type = #void_type
 >
 #di_subprogram1 = #llvm.di_subprogram<
   compileUnit = #di_compile_unit, scope = #di_file, name = "inner_func",
-  file = #di_file, subprogramFlags = "LocalToUnit|Definition|Optimized"
+  file = #di_file, subprogramFlags = "LocalToUnit|Definition|Optimized",
+  type = #void_type
 >
 #di_local_variable0 = #llvm.di_local_variable<scope = #di_subprogram, name = "a", file = #di_file, type = #di_basic_type>
 #di_lexical_block_file = #llvm.di_lexical_block_file<scope = #di_subprogram1, file = #di_file, discriminator = 0>
@@ -261,9 +269,11 @@ llvm.func @func_with_inlined_dbg_value(%arg0: i32) -> (i32) {
   id = distinct[0]<>, sourceLanguage = DW_LANG_C, file = #di_file,
   producer = "MLIR", isOptimized = true, emissionKind = Full, isDebugInfoForProfiling = true
 >
+#void_return = #llvm.di_null_type
+#void_type = #llvm.di_subroutine_type<types = #void_return>
 #di_subprogram = #llvm.di_subprogram<
   compileUnit = #di_compile_unit, scope = #di_file, name = "func",
-  file = #di_file, subprogramFlags = Definition>
+  file = #di_file, subprogramFlags = Definition, type = #void_type>
 #di_local_variable = #llvm.di_local_variable<scope = #di_subprogram, name = "a", file = #di_file, type = #di_basic_type>
 
 #loc = loc("foo.mlir":0:0)
@@ -279,7 +289,6 @@ llvm.func @func_without_subprogram(%0 : i32) {
 // CHECK: ![[FILE:.*]] = !DIFile(filename: "foo.mlir", directory: "/test/")
 // CHECK-DAG: ![[FUNC:.*]] = distinct !DISubprogram(name: "func", scope: ![[FILE]]
 // CHECK-DAG: ![[VAR_LOC]] = !DILocalVariable(name: "a", scope: ![[FUNC]], file: ![[FILE]]
-
 // -----
 
 // Ensures that debug intrinsics without a valid location are not exported to
@@ -290,9 +299,12 @@ llvm.func @func_without_subprogram(%0 : i32) {
   id = distinct[0]<>, sourceLanguage = DW_LANG_C, file = #di_file,
   producer = "MLIR", isOptimized = true, emissionKind = Full, isDebugInfoForProfiling = true
 >
+#void_return = #llvm.di_null_type
+#void_type = #llvm.di_subroutine_type<types = #void_return>
 #di_subprogram = #llvm.di_subprogram<
   compileUnit = #di_compile_unit, scope = #di_file, name = "outer_func",
-  file = #di_file, subprogramFlags = "Definition|Optimized"
+  file = #di_file, subprogramFlags = "Definition|Optimized",
+  type = #void_type
 >
 #di_local_variable = #llvm.di_local_variable<scope = #di_subprogram, name = "a">
 #declared_var = #llvm.di_local_variable<scope = #di_subprogram, name = "alloc">
@@ -310,7 +322,6 @@ llvm.func @dbg_intrinsics_with_no_location(%arg0: i32) -> (i32) {
   llvm.intr.dbg.label #di_label
   llvm.return %arg0 : i32
 }
-
 // -----
 
 // CHECK: @global_with_expr_1 = external global i64, !dbg {{.*}}
@@ -362,14 +373,15 @@ llvm.mlir.global external @module_global() {dbg_exprs = [#llvm.di_global_variabl
 
 #file = #llvm.di_file<"test.f90" in "existence">
 #cu = #llvm.di_compile_unit<id = distinct[0]<>, sourceLanguage = DW_LANG_Fortran95, file = #file, producer = "MLIR", isOptimized = true, emissionKind = Full, isDebugInfoForProfiling = true>
+#void_return = #llvm.di_null_type
+#void_type = #llvm.di_subroutine_type<types = #void_return>
 #ty1 = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "integer", sizeInBits = 64, encoding = DW_ATE_signed>
-#sp = #llvm.di_subprogram<compileUnit = #cu, scope = #file, name = "fn_with_gl", file = #file, subprogramFlags = "Definition|Optimized">
+#sp = #llvm.di_subprogram<compileUnit = #cu, scope = #file, name = "fn_with_gl", file = #file, subprogramFlags = "Definition|Optimized", type = #void_type>
 llvm.mlir.global @func_global() {dbg_exprs = [#llvm.di_global_variable_expression<var = <scope = #sp, name = "func_global", linkageName = "func_global", file = #file, line = 121, type = #ty1, isLocalToUnit = true, isDefined = true>, expr = <>>]} : i64
 
 llvm.func @fn_with_gl() {
   llvm.return
 } loc(fused<#sp>["foo1.mlir":0:0])
-
 // -----
 
 // Test that imported entries correctly generates 'retainedNodes' in the
@@ -433,8 +445,10 @@ llvm.mlir.global external constant @".str.1"() {addr_space = 0 : i32, dbg_exprs
 #di_compile_unit_1 = #llvm.di_compile_unit<id = distinct[0]<>, sourceLanguage = DW_LANG_C, file = #di_file_1, producer = "MLIR", isOptimized = true, emissionKind = LineTablesOnly, isDebugInfoForProfiling = true>
 // CHECK-DAG: ![[SCOPE1:.*]] = distinct !DICompileUnit(language: DW_LANG_C, file: ![[FILE1]], producer: "MLIR", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, debugInfoForProfiling: true)
 #di_compile_unit_2 = #llvm.di_compile_unit<id = distinct[1]<>, sourceLanguage = DW_LANG_C, file = #di_file_2, producer = "MLIR", isOptimized = true, emissionKind = DebugDirectivesOnly, isDebugInfoForProfiling = true>
-#di_subprogram_1 = #llvm.di_subprogram<compileUnit = #di_compile_unit_1, scope = #di_file_1, name = "func1", file = #di_file_1, subprogramFlags = "Definition|Optimized">
-#di_subprogram_2 = #llvm.di_subprogram<compileUnit = #di_compile_unit_2, scope = #di_file_2, name = "func2", file = #di_file_2, subprogramFlags = "Definition|Optimized">
+#void_return = #llvm.di_null_type
+#void_type = #llvm.di_subroutine_type<types = #void_return>
+#di_subprogram_1 = #llvm.di_subprogram<compileUnit = #di_compile_unit_1, scope = #di_file_1, name = "func1", file = #di_file_1, subprogramFlags = "Definition|Optimized", type = #void_type>
+#di_subprogram_2 = #llvm.di_subprogram<compileUnit = #di_compile_unit_2, scope = #di_file_2, name = "func2", file = #di_file_2, subprogramFlags = "Definition|Optimized", type = #void_type>
 
 llvm.func @func_line_tables() {
   llvm.return
@@ -661,10 +675,12 @@ llvm.func @subranges(%arg: !llvm.ptr) {
 
 #bt = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "int", sizeInBits = 32>
 #file = #llvm.di_file<"debug-info.ll" in "/">
+#void_return = #llvm.di_null_type
+#void_type = #llvm.di_subroutine_type<types = #void_return>
 #cu = #llvm.di_compile_unit<id = distinct[0]<>, sourceLanguage = DW_LANG_C,
  file = #file, isOptimized = false, emissionKind = Full, isDebugInfoForProfiling = false>
 #sp = #llvm.di_subprogram<compileUnit = #cu, scope = #file, name = "test",
- file = #file, subprogramFlags = Definition>
+ file = #file, subprogramFlags = Definition, type = #void_type>
 #var = #llvm.di_local_variable<scope = #sp, name = "string_size", type = #bt, flags = Artificial>
 #sty1 = #llvm.di_string_type<tag = DW_TAG_string_type, name = "character(*)",
  sizeInBits = 32, alignInBits = 8, stringLength = #var,
@@ -686,16 +702,17 @@ llvm.func @string_ty(%arg0: !llvm.ptr) {
 // CHECK-DAG: !DIStringType(name: "character(*)", stringLength: ![[VAR:[0-9]+]], stringLengthExpression: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 8), stringLocationExpression: !DIExpression(DW_OP_push_object_address, DW_OP_deref), size: 32, align: 8)
 // CHECK-DAG: ![[VAR]] = !DILocalVariable(name: "string_size"{{.*}} flags: DIFlagArtificial)
 // CHECK-DAG: !DIStringType()
-
 // -----
 
 // Test translation of DICommonBlockAttr.
 #bt = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "int", sizeInBits = 32>
 #file = #llvm.di_file<"test.f90" in "">
+#void_return = #llvm.di_null_type
+#void_type = #llvm.di_subroutine_type<types = #void_return>
 #cu = #llvm.di_compile_unit<id = distinct[0]<>, sourceLanguage = DW_LANG_C,
  file = #file, isOptimized = false, emissionKind = Full, isDebugInfoForProfiling = false>
 #sp = #llvm.di_subprogram<compileUnit = #cu, scope = #file, name = "test",
- file = #file, subprogramFlags = Definition>
+ file = #file, subprogramFlags = Definition, type = #void_type>
 #di_common_block = #llvm.di_common_block<scope = #sp, name = "block",
  file = #file, line = 3>
 #global_var = #llvm.di_global_variable<scope = #di_common_block, name = "a",
@@ -716,7 +733,6 @@ llvm.func @test() {
 // CHECK: !DICommonBlock(scope: ![[SCOPE:[0-9]+]], declaration: null, name: "block", file: ![[FILE:[0-9]+]], line: 3)
 // CHECK: ![[SCOPE]] = {{.*}}!DISubprogram(name: "test"{{.*}})
 // CHECK: ![[FILE]] = !DIFile(filename: "test.f90"{{.*}})
-
 // -----
 
 // Test multiple DIGlobalVariableExpression on a global.

diff  --git a/mlir/test/Target/LLVMIR/loop-metadata.mlir b/mlir/test/Target/LLVMIR/loop-metadata.mlir
index 2fe4a994aeb66..72f0cf06ed0fe 100644
--- a/mlir/test/Target/LLVMIR/loop-metadata.mlir
+++ b/mlir/test/Target/LLVMIR/loop-metadata.mlir
@@ -298,7 +298,9 @@ llvm.func @loopOptions(%arg1 : i32, %arg2 : i32) {
 #loc2 = loc("loop-metadata.mlir":52:4)
 
 #di_compile_unit = #llvm.di_compile_unit<id = distinct[0]<>, sourceLanguage = DW_LANG_C, file = #di_file, isOptimized = false, emissionKind = None>
-#di_subprogram = #llvm.di_subprogram<compileUnit = #di_compile_unit, scope = #di_file, name = "loop_locs", file = #di_file, subprogramFlags = Definition>
+#void_return = #llvm.di_null_type
+#void_type = #llvm.di_subroutine_type<types = #void_return>
+#di_subprogram = #llvm.di_subprogram<compileUnit = #di_compile_unit, scope = #di_file, name = "loop_locs", file = #di_file, subprogramFlags = Definition, type = #void_type>
 
 #start_loc_fused = loc(fused<#di_subprogram>[#loc1])
 #end_loc_fused= loc(fused<#di_subprogram>[#loc2])

diff  --git a/mlir/test/mlir-translate/import-diagnostics.ll b/mlir/test/mlir-translate/import-diagnostics.ll
index 6767d948e3bbd..a945621c6acba 100644
--- a/mlir/test/mlir-translate/import-diagnostics.ll
+++ b/mlir/test/mlir-translate/import-diagnostics.ll
@@ -49,5 +49,7 @@ define void @dropped_instruction(i64 %arg1) {
 !1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
 !2 = !DIFile(filename: "import-failure.ll", directory: "/")
 !3 = !DILocalVariable(scope: !4, name: "arg1", file: !2, line: 1, arg: 1, align: 64);
-!4 = distinct !DISubprogram(name: "intrinsic", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1)
+!4 = distinct !DISubprogram(name: "intrinsic", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1, type: !999)
 !5 = !DILocation(line: 1, column: 2, scope: !4)
+!999 = !DISubroutineType(types: !1000)
+!1000 = !{null}


        


More information about the Mlir-commits mailing list