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