1; RUN: llc -start-after=codegenprepare -stop-before=finalize-isel < %s -o - | FileCheck %s
2
3; Test that stack frame dbg.values are lowered to DBG_VALUEs, in blocks that
4; are local to the alloca, and elsewhere. Differs from dbg-value-frame-index.ll
5; because this test does not result in the frame-index being in a vreg,
6; instead it's exclusively referred to by memory operands of instructions.
7;
8; Additionally test that we don't re-order with constant values -- both are
9; independent of the order the instructions get lowered, but should not
10; interleave.
11
12target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
13target triple = "x86_64-unknown-unknown"
14
15declare void @dud()
16
17; CHECK: [[BARVAR:![0-9]+]] = !DILocalVariable(name: "bar",
18
19define i32 @foo() !dbg !6 {
20; CHECK-LABEL: body
21
22; CHECK:      DBG_VALUE 0, $noreg, [[BARVAR]]
23; CHECK-NEXT: MOV32mi %[[STACKLOC:[a-zA-Z0-9\.]+]], 1, $noreg
24; CHECK-NEXT: DBG_VALUE %[[STACKLOC]], $noreg, [[BARVAR]]
25
26  %p1 = alloca i32
27  call void @llvm.dbg.value(metadata i32 *null, metadata !17, metadata !DIExpression()), !dbg !18
28  store i32 0, i32 *%p1
29  call void @llvm.dbg.value(metadata i32 *%p1, metadata !17, metadata !DIExpression()), !dbg !18
30  br label %foo
31
32foo:
33
34; CHECK-LABEL: bb.1.foo
35; CHECK:      DBG_VALUE %[[STACKLOC]], $noreg, [[BARVAR]]
36
37  call void @dud()
38  call void @llvm.dbg.value(metadata i32 *%p1, metadata !17, metadata !DIExpression()), !dbg !18
39  br label %bar
40
41bar:
42
43; CHECK-LABEL: bb.2.bar
44; CHECK:      DBG_VALUE %[[STACKLOC]], $noreg, [[BARVAR]]
45; CHECK-NEXT: ADJCALLSTACKDOWN
46; CHECK-NEXT: CALL
47; CHECK-NEXT: ADJCALLSTACKUP
48; CHECK-NEXT: DBG_VALUE 0, $noreg, [[BARVAR]]
49  call void @llvm.dbg.value(metadata i32 *%p1, metadata !17, metadata !DIExpression()), !dbg !18
50  call void @dud()
51  call void @llvm.dbg.value(metadata i32 *null, metadata !17, metadata !DIExpression()), !dbg !18
52  %loaded = load i32, i32 *%p1
53  ret i32 %loaded, !dbg !19
54}
55
56; Function Attrs: nounwind readnone speculatable
57declare void @llvm.dbg.value(metadata, metadata, metadata) #6
58
59!llvm.dbg.cu = !{!0}
60!llvm.module.flags = !{!3, !4}
61!llvm.ident = !{!5}
62
63!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2, globals: !2)
64!1 = !DIFile(filename: "a.c", directory: "b")
65!2 = !{}
66!3 = !{i32 2, !"Dwarf Version", i32 4}
67!4 = !{i32 2, !"Debug Info Version", i32 3}
68!5 = !{!""}
69!6 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 13, type: !7, isLocal: false, isDefinition: true, scopeLine: 14, isOptimized: false, unit: !0, retainedNodes: !2)
70!7 = !DISubroutineType(types: !8)
71!8 = !{!140}
72!140 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
73!15 = !{!16}
74!16 = !DISubrange(count: 5)
75!17 = !DILocalVariable(name: "bar", scope: !6, line: 13, type: !140)
76!18 = !DILocation(line: 13, column: 23, scope: !6)
77!19 = !DILocation(line: 15, column: 5, scope: !6)
78!20 = !DILocation(line: 16, column: 1, scope: !6)
79!21 = !DILocalVariable(name: "baz", scope: !6, line: 13, type: !140)
80