1; RUN: llc -mtriple=x86_64-unknown-unknown %s -o - -stop-after=livedebugvalues | FileCheck %s 2; 3; In the simple loop below, the location of the variable "toast" is %bar in 4; the entry block, then set to constant zero at the end of the loop. We cannot 5; know the location of "toast" at the start of the %loop block. Test that no 6; location is given until after the call to @booler. 7; 8; Second function @baz added with an even tighter loop -- this tests different 9; code-paths through LiveDebugValues. Any blocks with an incoming backedge need 10; reconsideration after the parent of the backedge has had its OutLocs 11; initialized, even if OutLocs hasn't changed. 12; 13; Third function @quux tests that we don't delete too many variable locations. 14; A variable that is live across the body of the loop should maintain its 15; location across that loop, and not be invalidated. 16; 17; CHECK: ![[FOOVARNUM:[0-9]+]] = !DILocalVariable(name: "toast" 18; CHECK: ![[BAZVARNUM:[0-9]+]] = !DILocalVariable(name: "crumpets" 19; CHECK: ![[QUUXVARNUM:[0-9]+]] = !DILocalVariable(name: "teacake" 20; 21; foo tests 22; CHECK-LABEL: bb.1.loop 23; CHECK-NOT: DBG_VALUE 24; CHECK-LABEL: CALL64pcrel32 @booler 25; CHECK: DBG_VALUE 0, $noreg, ![[FOOVARNUM]] 26; 27; baz tests 28; CHECK-LABEL: name: baz 29; CHECK-LABEL: bb.1.loop 30; CHECK-NOT: DBG_VALUE 31; CHECK-LABEL: CALL64pcrel32 @booler 32; CHECK: DBG_VALUE 0, $noreg, ![[BAZVARNUM]] 33; 34; quux tests -- the variable arrives in $edi, should get a non-undef location 35; before the loop, and its position re-stated in each block. 36; CHECK-LABEL: name: quux 37; CHECK: DBG_VALUE $edi, $noreg, ![[QUUXVARNUM]] 38; CHECK: DBG_VALUE [[QUUXLOC:[a-zA-Z0-9$_]+]], $noreg, ![[QUUXVARNUM]] 39; CHECK-LABEL: bb.1.loop 40; CHECK: DBG_VALUE [[QUUXLOC]], $noreg, ![[QUUXVARNUM]] 41; CHECK-NOT: DBG_VALUE $noreg 42; CHECK-LABEL: bb.2.exit 43; CHECK: DBG_VALUE [[QUUXLOC]], $noreg, ![[QUUXVARNUM]] 44; CHECK-NOT: DBG_VALUE $noreg 45 46declare dso_local i1 @booler() 47declare dso_local void @escape(i32) 48declare void @llvm.dbg.value(metadata, metadata, metadata) 49@glob = global i32 0 50 51define i32 @foo(i32 %bar) !dbg !4 { 52entry: 53 call void @llvm.dbg.value(metadata i32 %bar, metadata !3, metadata !DIExpression()), !dbg !6 54 br label %loop 55loop: 56 call void @escape(i32 %bar) 57 %retval = call i1 @booler(), !dbg !6 58 call void @llvm.dbg.value(metadata i32 0, metadata !3, metadata !DIExpression()), !dbg !6 59 br i1 %retval, label %loop2, label %exit 60loop2: 61 store i32 %bar, i32 *@glob 62 br label %loop 63exit: 64 ret i32 %bar 65} 66 67define i32 @baz(i32 %bar) !dbg !104 { 68entry: 69 call void @llvm.dbg.value(metadata i32 %bar, metadata !103, metadata !DIExpression()), !dbg !106 70 br label %loop 71loop: 72 call void @escape(i32 %bar) 73 %retval = call i1 @booler(), !dbg !106 74 call void @llvm.dbg.value(metadata i32 0, metadata !103, metadata !DIExpression()), !dbg !106 75 br i1 %retval, label %loop, label %exit 76exit: 77 ret i32 %bar 78} 79 80define i32 @quux(i32 %bar) !dbg !204 { 81entry: 82 ; %bar will be placed in a nonvolatile or spill location for the loop, 83 ; before being returned later. 84 call void @llvm.dbg.value(metadata i32 %bar, metadata !203, metadata !DIExpression()), !dbg !206 85 br label %loop 86loop: 87 %retval = call i1 @booler(), !dbg !206 88 br i1 %retval, label %loop, label %exit 89exit: 90 ret i32 %bar 91} 92 93!llvm.module.flags = !{!0, !100} 94!llvm.dbg.cu = !{!1} 95 96!100 = !{i32 2, !"Dwarf Version", i32 4} 97!0 = !{i32 2, !"Debug Info Version", i32 3} 98!1 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !2, producer: "beards", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug) 99!2 = !DIFile(filename: "bees.cpp", directory: ".") 100!3 = !DILocalVariable(name: "toast", scope: !4, file: !2, line: 1, type: !16) 101!4 = distinct !DISubprogram(name: "nope", scope: !2, file: !2, line: 1, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !13, type: !14, isDefinition: true) 102!6 = !DILocation(line: 1, scope: !4) 103!13 = !{!3} 104!14 = !DISubroutineType(types: !15) 105!15 = !{!16} 106!16 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 107!103 = !DILocalVariable(name: "crumpets", scope: !104, file: !2, line: 1, type: !16) 108!104 = distinct !DISubprogram(name: "ribbit", scope: !2, file: !2, line: 1, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !113, type: !14, isDefinition: true) 109!106 = !DILocation(line: 1, scope: !104) 110!113 = !{!103} 111!203 = !DILocalVariable(name: "teacake", scope: !204, file: !2, line: 1, type: !16) 112!204 = distinct !DISubprogram(name: "toad", scope: !2, file: !2, line: 1, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !113, type: !14, isDefinition: true) 113!206 = !DILocation(line: 1, scope: !204) 114!213 = !{!203} 115