1 ; RUN: llc -mtriple=x86_64-unknown-unknown %s -o - -stop-after=livedebugvalues -experimental-debug-variable-locations=true | 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-LABEL: bb.1.loop
39 ; CHECK: DBG_VALUE $ebx, $noreg, ![[QUUXVARNUM]]
40 ; CHECK-NOT: DBG_VALUE $noreg
41 ; CHECK-LABEL: bb.2.exit
42 ; CHECK: DBG_VALUE $ebx, $noreg, ![[QUUXVARNUM]]
43 ; CHECK-NOT: DBG_VALUE $noreg
45 declare dso_local i1 @booler()
46 declare dso_local void @escape(i32)
47 declare void @llvm.dbg.value(metadata, metadata, metadata)
50 define i32 @foo(i32 %bar) !dbg !4 {
52 call void @llvm.dbg.value(metadata i32 %bar, metadata !3, metadata !DIExpression()), !dbg !6
55 call void @escape(i32 %bar)
56 %retval = call i1 @booler(), !dbg !6
57 call void @llvm.dbg.value(metadata i32 0, metadata !3, metadata !DIExpression()), !dbg !6
58 br i1 %retval, label %loop2, label %exit
60 store i32 %bar, ptr @glob
66 define i32 @baz(i32 %bar) !dbg !104 {
68 call void @llvm.dbg.value(metadata i32 %bar, metadata !103, metadata !DIExpression()), !dbg !106
71 call void @escape(i32 %bar)
72 %retval = call i1 @booler(), !dbg !106
73 call void @llvm.dbg.value(metadata i32 0, metadata !103, metadata !DIExpression()), !dbg !106
74 br i1 %retval, label %loop, label %exit
79 define i32 @quux(i32 %bar) !dbg !204 {
81 ; %bar will be placed in a nonvolatile or spill location for the loop,
82 ; before being returned later.
83 call void @llvm.dbg.value(metadata i32 %bar, metadata !203, metadata !DIExpression()), !dbg !206
86 %retval = call i1 @booler(), !dbg !206
87 br i1 %retval, label %loop, label %exit
92 !llvm.module.flags = !{!0, !100}
95 !100 = !{i32 2, !"Dwarf Version", i32 4}
96 !0 = !{i32 2, !"Debug Info Version", i32 3}
97 !1 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !2, producer: "beards", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
98 !2 = !DIFile(filename: "bees.cpp", directory: ".")
99 !3 = !DILocalVariable(name: "toast", scope: !4, file: !2, line: 1, type: !16)
100 !4 = distinct !DISubprogram(name: "nope", scope: !2, file: !2, line: 1, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !13, type: !14, isDefinition: true)
101 !6 = !DILocation(line: 1, scope: !4)
103 !14 = !DISubroutineType(types: !15)
105 !16 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
106 !103 = !DILocalVariable(name: "crumpets", scope: !104, file: !2, line: 1, type: !16)
107 !104 = distinct !DISubprogram(name: "ribbit", scope: !2, file: !2, line: 1, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !113, type: !14, isDefinition: true)
108 !106 = !DILocation(line: 1, scope: !104)
110 !203 = !DILocalVariable(name: "teacake", scope: !204, file: !2, line: 1, type: !16)
111 !204 = distinct !DISubprogram(name: "toad", scope: !2, file: !2, line: 1, spFlags: DISPFlagDefinition, unit: !1, retainedNodes: !113, type: !14, isDefinition: true)
112 !206 = !DILocation(line: 1, scope: !204)