1 ; Test that llvm-reduce can drop unneeded debug metadata nodes referenced by
2 ; DICompileUnit and DISuprogram.
4 ; RUN: llvm-reduce --delta-passes=di-metadata --abort-on-invalid-reduction --test FileCheck --test-arg --check-prefixes=CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t
5 ; RUN: FileCheck <%t --enable-var-scope %s --implicit-check-not=DIGlobalVariableExpression
7 ; CHECK-INTERESTINGNESS: define void @test() !dbg [[SUBPROG:![0-9]+]]
8 ; CHECK-INTERESTINGNESS: !llvm.module.flags = !{
10 ; CHECK-INTERESTINGNESS: !llvm.dbg.cu = !{[[CU:.+]]}
12 ; CHECK-INTERESTINGNESS-DAG: [[CU]] = distinct !DICompileUnit(language: DW_LANG_C99,{{.*}}, retainedTypes: [[TYPES:![0-9]+]]
13 ; CHECK-INTERESTINGNESS-DAG: [[TYPES]] = !{[[T0:![0-9]+]]
14 ; CHECK-INTERESTINGNESS-DAG: [[T0]] = !DIBasicType(name: "unsigned int",
15 ; CHECK-INTERESTINGNESS-DAG: [[SUBPROG]] = distinct !DISubprogram(name: "test",
19 ; CHECK: define void @test() !dbg [[SUBPROG:![0-9]+]]
20 ; CHECK: !llvm.module.flags = !{
22 ; CHECK: !llvm.dbg.cu = !{[[CU:.+]]}
24 ; CHECK-DAG: [[CU]] = distinct !DICompileUnit(language: DW_LANG_C99,{{.*}}, retainedTypes: [[TYPES:![0-9]+]], globals: [[EMPTY:![0-9]+]]
25 ; CHECK-DAG: [[EMPTY]] = !{}
26 ; CHECK-DAG: [[TYPES]] = !{[[T0:![0-9]+]]
27 ; CHECK-DAG: [[T0]] = !DIBasicType(name: "unsigned int",
28 ; CHECK-DAG: [[SUBPROG]] = distinct !DISubprogram(name: "test", {{.*}}retainedNodes: [[EMPTY]])
30 define void @test() !dbg !17 {
34 !llvm.module.flags = !{!0, !1}
37 !0 = !{i32 7, !"Dwarf Version", i32 4}
38 !1 = !{i32 2, !"Debug Info Version", i32 3}
39 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 16.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !12, globals: !14, splitDebugInlining: false, nameTableKind: None, sysroot: "/", sdk: "SDK")
40 !3 = !DIFile(filename: "test.c", directory: "/tmp")
42 !5 = !DICompositeType(tag: DW_TAG_enumeration_type, file: !6, line: 755, baseType: !7, size: 32, elements: !8)
43 !6 = !DIFile(filename: "foo.h", directory: "/tmp")
44 !7 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
46 !9 = !DIEnumerator(name: "flag_AUTO", value: 0)
47 !10 = !DIEnumerator(name: "flag_STDIN", value: 1)
48 !11 = !DIEnumerator(name: "flag_INTERACTIVE", value: 2)
50 !13 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_unsigned)
52 !15 = !DIGlobalVariableExpression(var: !16, expr: !DIExpression())
53 !16 = distinct !DIGlobalVariable(scope: null, file: !3, line: 726, type: !13, isLocal: true, isDefinition: true)
54 !17 = distinct !DISubprogram(name: "test", scope: !18, file: !18, line: 1839, type: !19, scopeLine: 1846, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !21)
55 !18 = !DIFile(filename: "bar.c", directory: "/tmp")
56 !19 = !DISubroutineType(types: !20)
58 !21 = !{!22, !23, !24}
59 !22 = !DILocalVariable(name: "A", arg: 1, scope: !17, file: !18, line: 1839, type: !7)
60 !23 = !DILocalVariable(name: "B", arg: 2, scope: !17, file: !18, line: 1839, type: !7)
61 !24 = !DILocalVariable(name: "C", scope: !17, file: !18, line: 1847, type: !7)