1 ; RUN: llc -start-after=codegenprepare -stop-before=finalize-isel < %s -o - | FileCheck %s
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.
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
12 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
13 target triple = "x86_64-unknown-unknown"
17 ; CHECK: [[BARVAR:![0-9]+]] = !DILocalVariable(name: "bar",
19 define i32 @foo() !dbg !6 {
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]]
27 call void @llvm.dbg.value(metadata i32 *null, metadata !17, metadata !DIExpression()), !dbg !18
29 call void @llvm.dbg.value(metadata i32 *%p1, metadata !17, metadata !DIExpression()), !dbg !18
34 ; CHECK-LABEL: bb.1.foo
35 ; CHECK: DBG_VALUE %[[STACKLOC]], $noreg, [[BARVAR]]
38 call void @llvm.dbg.value(metadata i32 *%p1, metadata !17, metadata !DIExpression()), !dbg !18
43 ; CHECK-LABEL: bb.2.bar
44 ; CHECK: DBG_VALUE %[[STACKLOC]], $noreg, [[BARVAR]]
45 ; CHECK-NEXT: ADJCALLSTACKDOWN
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
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
56 ; Function Attrs: nounwind readnone speculatable
57 declare void @llvm.dbg.value(metadata, metadata, metadata) #6
60 !llvm.module.flags = !{!3, !4}
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")
66 !3 = !{i32 2, !"Dwarf Version", i32 4}
67 !4 = !{i32 2, !"Debug Info Version", i32 3}
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)
72 !140 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
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)