1 ; RUN: opt -S %s -passes=loop-deletion | FileCheck %s
2 ; RUN: opt -S %s -passes=loop-deletion --try-experimental-debuginfo-iterators | FileCheck %s
4 ;; static int foo(int Param) __attribute__((always_inline));
5 ;; static int foo(int Param) { return Param * Param * 2; }
7 ;; static int zero() __attribute__((always_inline));
8 ;; static int zero() { return 0; }
12 ;; for (int Index = zero(); Index < 0; ++Index) {
19 ;; Check that a loop invariant value in a dbg.value inside the dead
22 ; CHECK-LABEL: for.end:
23 ; CHECK-NEXT: #dbg_value({{.+}} undef, ![[VAR1:[0-9]+]],{{.+}}, ![[DBG1:[0-9]+]]
24 ; CHECK-NEXT: #dbg_value({{.+}} 5, ![[VAR2:[0-9]+]],{{.+}}, ![[DBG2:[0-9]+]]
26 ; CHECK-DAG: ![[VAR1]] = !DILocalVariable(name: "Index"
27 ; CHECK-DAG: ![[VAR2]] = !DILocalVariable(name: "Constant"
29 ; CHECK-DAG: ![[DBG1]] = !DILocation(line: 0
30 ; CHECK-DAG: ![[DBG2]] = !DILocation(line: 0
32 define dso_local void @test() !dbg !9 {
34 call void @llvm.dbg.value(metadata i32 0, metadata !13, metadata !DIExpression()), !dbg !15
35 call void @llvm.dbg.value(metadata i32 0, metadata !16, metadata !DIExpression()), !dbg !18
36 br label %for.end, !dbg !19
38 for.end: ; preds = %entry
39 call void @llvm.dbg.value(metadata i32 undef, metadata !16, metadata !DIExpression()), !dbg !18
40 call void @llvm.dbg.value(metadata i32 5, metadata !13, metadata !DIExpression()), !dbg !15
44 declare void @llvm.dbg.value(metadata, metadata, metadata)
47 !llvm.module.flags = !{!2, !3, !4, !5, !6, !7}
50 !0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 17.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
51 !1 = !DIFile(filename: "test", directory: "", checksumkind: CSK_MD5, checksum: "53f7b620ca60e4fc7af4e6e4cdac8eea")
52 !2 = !{i32 2, !"CodeView", i32 1}
53 !3 = !{i32 2, !"Debug Info Version", i32 3}
54 !4 = !{i32 1, !"wchar_size", i32 2}
55 !5 = !{i32 8, !"PIC Level", i32 2}
56 !6 = !{i32 7, !"uwtable", i32 2}
57 !7 = !{i32 1, !"MaxTLSAlign", i32 65536}
58 !8 = !{!"clang version 17.0.0"}
59 !9 = distinct !DISubprogram(name: "test", scope: !1, file: !1, line: 7, type: !10, scopeLine: 7, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !12)
60 !10 = !DISubroutineType(types: !11)
63 !13 = !DILocalVariable(name: "Constant", scope: !9, file: !1, line: 8, type: !14)
64 !14 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
65 !15 = !DILocation(line: 0, scope: !9)
66 !16 = !DILocalVariable(name: "Index", scope: !17, file: !1, line: 9, type: !14)
67 !17 = distinct !DILexicalBlock(scope: !9, file: !1, line: 9)
68 !18 = !DILocation(line: 0, scope: !17)
69 !19 = !DILocation(line: 9, scope: !17)
70 !21 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 2, type: !22, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !0, retainedNodes: !12)
71 !22 = !DISubroutineType(types: !23)
73 !24 = !DILocation(line: 0, scope: !21, inlinedAt: !25)
74 !25 = distinct !DILocation(line: 10, scope: !26)
75 !26 = distinct !DILexicalBlock(scope: !27, file: !1, line: 9)
76 !27 = distinct !DILexicalBlock(scope: !17, file: !1, line: 9)
77 !28 = !DILocation(line: 0, scope: !21, inlinedAt: !29)
78 !29 = distinct !DILocation(line: 12, scope: !26)
79 !30 = !DILocation(line: 14, scope: !9)