2 ; RUN: llvm-mc %t.s -filetype=obj -triple=x86_64-windows-msvc -o %t.o
3 ; RUN: FileCheck %s < %t.s --check-prefix=ASM
4 ; RUN: llvm-dwarfdump %t.o | FileCheck %s --check-prefix=DWARF
7 ; See PR41992, the third and final dbg.value disappears after
10 ; In this example, the variable lives mostly in memory, but at the point of the
11 ; assignment to global, it lives nowhere, and is described as the constant
20 ; x = 1; // DSE should delete and insert dbg.value(i32 1)
22 ; x = 2; // DSE should insert dbg.addr
27 source_filename = "dse.c"
28 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
29 target triple = "x86_64-pc-windows-msvc19.0.24215"
31 declare void @llvm.dbg.addr(metadata, metadata, metadata) #2
32 declare void @llvm.dbg.value(metadata, metadata, metadata) #2
33 declare void @escape(i32*)
35 @global = external global i32, align 4
37 ; Function Attrs: nounwind uwtable
38 define void @f(i32 %x) #0 !dbg !8 {
40 %x.addr = alloca i32, align 4
41 store i32 %x, i32* %x.addr, align 4
42 call void @llvm.dbg.addr(metadata i32* %x.addr, metadata !13, metadata !DIExpression()), !dbg !18
43 call void @escape(i32* %x.addr), !dbg !19
44 call void @llvm.dbg.value(metadata i32 1, metadata !13, metadata !DIExpression()), !dbg !20
45 store i32 1, i32* @global, align 4, !dbg !22
46 call void @llvm.dbg.addr(metadata i32* %x.addr, metadata !13, metadata !DIExpression()), !dbg !23
47 store i32 2, i32* %x.addr, align 4, !dbg !23
48 call void @escape(i32* %x.addr), !dbg !24
53 ; ASM: #DEBUG_VALUE: f:x <- [DW_OP_plus_uconst [[OFF_X:[0-9]+]], DW_OP_deref] $rsp
54 ; ASM: movl %ecx, [[OFF_X]](%rsp)
56 ; ASM: #DEBUG_VALUE: f:x <- 1
57 ; ASM: movl $1, global(%rip)
58 ; ASM: #DEBUG_VALUE: f:x <- [DW_OP_plus_uconst [[OFF_X]], DW_OP_deref] $rsp
59 ; ASM: movl $2, [[OFF_X]](%rsp)
63 ; DWARF: DW_TAG_formal_parameter
64 ; DWARF-NEXT: DW_AT_location (0x00000000
65 ; DWARF-NEXT: {{[^:]*}}: DW_OP_breg7 RSP+{{[0-9]+}}
66 ; DWARF-NEXT: {{[^:]*}}: DW_OP_consts +1, DW_OP_stack_value
67 ; DWARF-NEXT: {{[^:]*}}: DW_OP_breg7 RSP+{{[0-9]+}})
68 ; DWARF-NEXT: DW_AT_name ("x")
70 attributes #0 = { nounwind uwtable }
71 attributes #2 = { nounwind readnone speculatable }
74 !llvm.module.flags = !{!3, !4, !5, !6}
77 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
78 !1 = !DIFile(filename: "dse.c", directory: "C:\5Csrc\5Cllvm-project\5Cbuild")
80 !3 = !{i32 2, !"Dwarf Version", i32 4}
81 !4 = !{i32 2, !"Debug Info Version", i32 3}
82 !5 = !{i32 1, !"wchar_size", i32 2}
83 !6 = !{i32 7, !"PIC Level", i32 2}
84 !7 = !{!"clang version 6.0.0 "}
85 !8 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 3, type: !9, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !12)
86 !9 = !DISubroutineType(types: !10)
88 !11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
90 !13 = !DILocalVariable(name: "x", arg: 1, scope: !8, file: !1, line: 3, type: !11)
91 !14 = !{!15, !15, i64 0}
92 !15 = !{!"int", !16, i64 0}
93 !16 = !{!"omnipotent char", !17, i64 0}
94 !17 = !{!"Simple C/C++ TBAA"}
95 !18 = !DILocation(line: 3, column: 12, scope: !8)
96 !19 = !DILocation(line: 4, column: 3, scope: !8)
97 !20 = !DILocation(line: 5, column: 5, scope: !8)
98 !21 = !DILocation(line: 6, column: 12, scope: !8)
99 !22 = !DILocation(line: 6, column: 10, scope: !8)
100 !23 = !DILocation(line: 7, column: 5, scope: !8)
101 !24 = !DILocation(line: 8, column: 3, scope: !8)
102 !25 = !DILocation(line: 9, column: 1, scope: !8)