1 ; RUN: opt -S -loop-rotate < %s | FileCheck %s 2 3 ;CHECK-LABEL: func 4 ;CHECK-LABEL: entry 5 ;CHECK-NEXT: tail call void @llvm.dbg.value(metadata i32 %a 6 ;CHECK-NEXT: tail call void @llvm.dbg.value(metadata i32 1, metadata ![[I_VAR:[0-9]+]], metadata !DIExpression()) 7 ;CHECK-LABEL: for.body: 8 ;CHECK-NEXT: [[I:%.*]] = phi i32 [ 1, %entry ], [ %inc, %for.body ] 9 ;CHECK-NEXT: tail call void @llvm.dbg.value(metadata i32 [[I]], metadata ![[I_VAR]], metadata !DIExpression()) 10 11 ; CHECK: ![[I_VAR]] = !DILocalVariable(name: "i",{{.*}}) 12 13 ; Function Attrs: noinline nounwind 14 define void @func(i32 %a) local_unnamed_addr #0 !dbg !6 { 15 entry: 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 19 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 25 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 32 33 for.end: ; preds = %for.cond 34 ret void, !dbg !31 35 } 36 37 declare i32 @func2(i32, i32) local_unnamed_addr 38 39 ; Function Attrs: nounwind readnone 40 declare void @llvm.dbg.value(metadata, metadata, metadata) #2 41 42 attributes #0 = { noinline nounwind } 43 attributes #2 = { nounwind readnone } 44 attributes #3 = { nounwind } 45 46 !llvm.dbg.cu = !{!0} 47 !llvm.module.flags = !{!3, !4} 48 !llvm.ident = !{!5} 49 50 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 5.0.0 (http://llvm.org/git/clang.git 0f3ed908c1f13f83da4b240f7595eb8d05e0a754) (http://llvm.org/git/llvm.git 8e270f5a6b8ceb0f3ac3ef1ffb83c5e29b44ae68)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) 51 !1 = !DIFile(filename: "debug-phi.c", directory: "/work/projects/src/tests/debug") 52 !2 = !{} 53 !3 = !{i32 2, !"Dwarf Version", i32 4} 54 !4 = !{i32 2, !"Debug Info Version", i32 3} 55 !5 = !{!"clang version 5.0.0 (http://llvm.org/git/clang.git 0f3ed908c1f13f83da4b240f7595eb8d05e0a754) (http://llvm.org/git/llvm.git 8e270f5a6b8ceb0f3ac3ef1ffb83c5e29b44ae68)"} 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) 58 !8 = !{null, !9} 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) 61 !11 = !DIExpression() 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) 82