xref: /llvm-project/llvm/test/DebugInfo/X86/dbg-value-regmask-clobber.ll (revision 5a288fa32e0c91b211e39f3e370255916902f898)
1; RUN: llc < %s | FileCheck %s --check-prefix=ASM
2; RUN: llc -force-instr-ref-livedebugvalues=1 < %s | FileCheck %s --check-prefix=ASM
3; RUN: llc < %s -filetype=obj | llvm-dwarfdump - | FileCheck %s --check-prefix=DWARF
4; RUN: llc -force-instr-ref-livedebugvalues=1 < %s -filetype=obj | llvm-dwarfdump - | FileCheck %s --check-prefix=DWARF
5
6; Values in registers should be clobbered by calls, which use a regmask instead
7; of individual register def operands.
8
9; ASM: main: # @main
10; ASM: #DEBUG_VALUE: main:argc <- $ecx
11; ASM: movl $1, x(%rip)
12; ASM: callq clobber
13; ASM-NEXT: [[argc_range_end:.Ltmp[0-9]+]]:
14; ASM: #DEBUG_VALUE: main:argc <- [DW_OP_LLVM_entry_value 1] $ecx
15
16; argc is the first debug location.
17; ASM: .Ldebug_loc1:
18; ASM-NEXT: .quad   .Lfunc_begin0-.Lfunc_begin0
19; ASM-NEXT: .quad   [[argc_range_end]]-.Lfunc_begin0
20; ASM-NEXT: .short  1                       # Loc expr size
21; ASM-NEXT: .byte   82                      # super-register DW_OP_reg2
22
23; argc is the first formal parameter.
24; DWARF: .debug_info contents:
25; DWARF:  DW_TAG_formal_parameter
26; DWARF-NEXT:    DW_AT_location ({{0x.*}}
27; DWARF-NEXT:    [0x0000000000000000, 0x0000000000000013): DW_OP_reg2 RCX
28; DWARF-NEXT:    [0x0000000000000013, 0x0000000000000043): DW_OP_GNU_entry_value(DW_OP_reg2 RCX), DW_OP_stack_value
29; DWARF-NEXT:    DW_AT_name ("argc")
30
31; ModuleID = 't.cpp'
32source_filename = "test/DebugInfo/X86/dbg-value-regmask-clobber.ll"
33target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
34target triple = "x86_64-pc-windows-msvc18.0.0"
35
36@x = common global i32 0, align 4, !dbg !0
37
38; Function Attrs: nounwind uwtable
39define i32 @main(i32 %argc, ptr nocapture readnone %argv) #0 !dbg !12 {
40entry:
41  tail call void @llvm.dbg.value(metadata ptr %argv, metadata !19, metadata !21), !dbg !22
42  tail call void @llvm.dbg.value(metadata i32 %argc, metadata !20, metadata !21), !dbg !23
43  store volatile i32 1, ptr @x, align 4, !dbg !24, !tbaa !25
44  tail call void @clobber() #2, !dbg !29
45  store volatile i32 2, ptr @x, align 4, !dbg !30, !tbaa !25
46  %0 = load volatile i32, ptr @x, align 4, !dbg !31, !tbaa !25
47  %tobool = icmp eq i32 %0, 0, !dbg !31
48  br i1 %tobool, label %if.else, label %if.then, !dbg !33
49
50if.then:                                          ; preds = %entry
51  store volatile i32 3, ptr @x, align 4, !dbg !34, !tbaa !25
52  br label %if.end, !dbg !36
53
54if.else:                                          ; preds = %entry
55
56  store volatile i32 4, ptr @x, align 4, !dbg !37, !tbaa !25
57  br label %if.end
58
59if.end:                                           ; preds = %if.else, %if.then
60  ret i32 0, !dbg !39
61}
62
63declare void @clobber()
64
65; Function Attrs: nounwind readnone
66declare void @llvm.dbg.value(metadata, metadata, metadata) #1
67
68attributes #0 = { nounwind uwtable }
69attributes #1 = { nounwind readnone }
70attributes #2 = { nounwind }
71
72!llvm.dbg.cu = !{!2}
73!llvm.module.flags = !{!8, !9, !10}
74!llvm.ident = !{!11}
75
76!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
77!1 = !DIGlobalVariable(name: "x", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true)
78!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 3.9.0 (trunk 260617) (llvm/trunk 260619)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
79!3 = !DIFile(filename: "t.cpp", directory: "D:\5Csrc\5Cllvm\5Cbuild")
80!4 = !{}
81!5 = !{!0}
82!6 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !7)
83!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
84!8 = !{i32 2, !"Dwarf Version", i32 4}
85!9 = !{i32 2, !"Debug Info Version", i32 3}
86!10 = !{i32 1, !"PIC Level", i32 2}
87!11 = !{!"clang version 3.9.0 (trunk 260617) (llvm/trunk 260619)"}
88!12 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 4, type: !13, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: true, unit: !2, retainedNodes: !18)
89!13 = !DISubroutineType(types: !14)
90!14 = !{!7, !7, !15}
91!15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !16, size: 64, align: 64)
92!16 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !17, size: 64, align: 64)
93!17 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)
94!18 = !{!19, !20}
95!19 = !DILocalVariable(name: "argv", arg: 2, scope: !12, file: !3, line: 4, type: !15)
96!20 = !DILocalVariable(name: "argc", arg: 1, scope: !12, file: !3, line: 4, type: !7)
97!21 = !DIExpression()
98!22 = !DILocation(line: 4, column: 27, scope: !12)
99!23 = !DILocation(line: 4, column: 14, scope: !12)
100!24 = !DILocation(line: 5, column: 5, scope: !12)
101!25 = !{!26, !26, i64 0}
102!26 = !{!"int", !27, i64 0}
103!27 = !{!"omnipotent char", !28, i64 0}
104!28 = !{!"Simple C/C++ TBAA"}
105!29 = !DILocation(line: 6, column: 3, scope: !12)
106!30 = !DILocation(line: 7, column: 5, scope: !12)
107!31 = !DILocation(line: 8, column: 7, scope: !32)
108!32 = distinct !DILexicalBlock(scope: !12, file: !3, line: 8, column: 7)
109!33 = !DILocation(line: 8, column: 7, scope: !12)
110!34 = !DILocation(line: 9, column: 7, scope: !35)
111!35 = distinct !DILexicalBlock(scope: !32, file: !3, line: 8, column: 10)
112!36 = !DILocation(line: 10, column: 3, scope: !35)
113!37 = !DILocation(line: 11, column: 7, scope: !38)
114!38 = distinct !DILexicalBlock(scope: !32, file: !3, line: 10, column: 10)
115!39 = !DILocation(line: 13, column: 1, scope: !12)
116
117