1 ; RUN: opt -S -passes=loop-rotate -verify-memoryssa < %s | FileCheck %s
5 ;CHECK-NEXT: #dbg_value(i32 %a
6 ;CHECK-NEXT: #dbg_value(i32 1, ![[I_VAR:[0-9]+]], !DIExpression(),
7 ;CHECK-LABEL: for.body:
8 ;CHECK-NEXT: [[I:%.*]] = phi i32 [ 1, %entry ], [ %inc, %for.body ]
9 ;CHECK-NEXT: #dbg_value(i32 [[I]], ![[I_VAR]], !DIExpression(),
11 ; CHECK: ![[I_VAR]] = !DILocalVariable(name: "i",{{.*}})
13 ; Function Attrs: noinline nounwind
14 define void @func(i32 %a) local_unnamed_addr #0 !dbg !6 {
16 tail call void @llvm.dbg.value(metadata i32 %a, metadata !10, metadata !11), !dbg !12
17 tail call void @llvm.dbg.value(metadata i32 1, metadata !13, metadata !11), !dbg !15
18 br label %for.cond, !dbg !16
20 for.cond: ; preds = %for.body, %entry
21 %i.0 = phi i32 [ 1, %entry ], [ %inc, %for.body ]
22 tail call void @llvm.dbg.value(metadata i32 %i.0, metadata !13, metadata !11), !dbg !15
23 %cmp = icmp slt i32 %i.0, 10, !dbg !17
24 br i1 %cmp, label %for.body, label %for.end, !dbg !20
26 for.body: ; preds = %for.cond
27 %add = add nsw i32 %i.0, %a, !dbg !22
28 %call = tail call i32 @func2(i32 %i.0, i32 %add) #3, !dbg !24
29 %inc = add nsw i32 %i.0, 1, !dbg !25
30 tail call void @llvm.dbg.value(metadata i32 %inc, metadata !13, metadata !11), !dbg !15
31 br label %for.cond, !dbg !27, !llvm.loop !28
33 for.end: ; preds = %for.cond
37 declare i32 @func2(i32, i32) local_unnamed_addr
39 ; Function Attrs: nounwind readnone
40 declare void @llvm.dbg.value(metadata, metadata, metadata) #2
42 attributes #0 = { noinline nounwind }
43 attributes #2 = { nounwind readnone }
44 attributes #3 = { nounwind }
47 !llvm.module.flags = !{!3, !4}
50 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 5.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
51 !1 = !DIFile(filename: "debug-phi.c", directory: "/work/projects/src/tests/debug")
53 !3 = !{i32 2, !"Dwarf Version", i32 4}
54 !4 = !{i32 2, !"Debug Info Version", i32 3}
55 !5 = !{!"clang version 5.0.0"}
56 !6 = distinct !DISubprogram(name: "func", scope: !1, file: !1, line: 2, type: !7, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
57 !7 = !DISubroutineType(types: !8)
59 !9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
60 !10 = !DILocalVariable(name: "a", arg: 1, scope: !6, file: !1, line: 2, type: !9)
62 !12 = !DILocation(line: 2, column: 15, scope: !6)
63 !13 = !DILocalVariable(name: "i", scope: !14, file: !1, line: 3, type: !9)
64 !14 = distinct !DILexicalBlock(scope: !6, file: !1, line: 3, column: 3)
65 !15 = !DILocation(line: 3, column: 11, scope: !14)
66 !16 = !DILocation(line: 3, column: 7, scope: !14)
67 !17 = !DILocation(line: 3, column: 20, scope: !18)
68 !18 = !DILexicalBlockFile(scope: !19, file: !1, discriminator: 1)
69 !19 = distinct !DILexicalBlock(scope: !14, file: !1, line: 3, column: 3)
70 !20 = !DILocation(line: 3, column: 3, scope: !21)
71 !21 = !DILexicalBlockFile(scope: !14, file: !1, discriminator: 1)
72 !22 = !DILocation(line: 4, column: 15, scope: !23)
73 !23 = distinct !DILexicalBlock(scope: !19, file: !1, line: 3, column: 31)
74 !24 = !DILocation(line: 4, column: 5, scope: !23)
75 !25 = !DILocation(line: 3, column: 27, scope: !26)
76 !26 = !DILexicalBlockFile(scope: !19, file: !1, discriminator: 2)
77 !27 = !DILocation(line: 3, column: 3, scope: !26)
78 !28 = distinct !{!28, !29, !30}
79 !29 = !DILocation(line: 3, column: 3, scope: !14)
80 !30 = !DILocation(line: 5, column: 3, scope: !14)
81 !31 = !DILocation(line: 6, column: 1, scope: !6)