1 ; RUN: llc -mtriple=x86_64-unknown-unknown %s -o - -stop-after=livedebugvalues | FileCheck %s
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.
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.
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.
17 ; CHECK: ![[FOOVARNUM:[0-9]+]] = !DILocalVariable(name: "toast"
18 ; CHECK: ![[BAZVARNUM:[0-9]+]] = !DILocalVariable(name: "crumpets"
19 ; CHECK: ![[QUUXVARNUM:[0-9]+]] = !DILocalVariable(name: "teacake"
22 ; CHECK-LABEL: bb.1.loop
23 ; CHECK-NOT: DBG_VALUE
24 ; CHECK-LABEL: CALL64pcrel32 @booler
25 ; CHECK: DBG_VALUE 0, $noreg, ![[FOOVARNUM]]
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]]
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
47 declare void @escape(i32)
48 declare void @llvm.dbg.value(metadata, metadata, metadata)
51 define i32 @foo(i32 %bar) !dbg !4 {
53 call void @llvm.dbg.value(metadata i32 %bar, metadata !3, metadata !DIExpression()), !dbg !6
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
61 store i32 %bar, i32 *@glob
67 define i32 @baz(i32 %bar) !dbg !104 {
69 call void @llvm.dbg.value(metadata i32 %bar, metadata !103, metadata !DIExpression()), !dbg !106
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
80 define i32 @quux(i32 %bar) !dbg !204 {
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
87 %retval = call i1 @booler(), !dbg !206
88 br i1 %retval, label %loop, label %exit
93 !llvm.module.flags = !{!0, !100}
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)
104 !14 = !DISubroutineType(types: !15)
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)
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)