xref: /llvm-project/llvm/test/DebugInfo/MIR/X86/debug-entry-value-operation.mir (revision 92b33822e989884d29465d34769b07d78aeb1a84)
1# RUN: llc -start-before=livedebugvalues -mtriple=x86_64-apple-darwin -o %t %s -filetype=obj
2# RUN: llvm-dwarfdump %t | FileCheck %s
3
4# RUN: llc -force-instr-ref-livedebugvalues=1 -start-before=livedebugvalues -mtriple=x86_64-apple-darwin -o %t %s -filetype=obj
5# RUN: llvm-dwarfdump %t | FileCheck %s
6
7# RUN: llc -start-before=livedebugvalues -debugger-tune=sce -mtriple=x86_64-sce-ps4 -o %t1 %s -filetype=obj
8# RUN: llvm-dwarfdump %t1 | FileCheck %s -check-prefix=SCE
9
10# RUN: llc -force-instr-ref-livedebugvalues=1 -start-before=livedebugvalues -debugger-tune=sce -mtriple=x86_64-sce-ps4 -o %t1 %s -filetype=obj
11# RUN: llvm-dwarfdump %t1 | FileCheck %s -check-prefix=SCE
12
13## Based on:
14## int global;
15## int foo(int p, int q, int r) {
16##   global = p + 1;
17##   asm __volatile("" : : : "edi", "esi", "edx");
18##   return 123;
19## }
20
21# CHECK: DW_TAG_formal_parameter
22# CHECK:   DW_OP_entry_value
23
24# SCE-NOT: DW_OP_{{.*}}entry_value
25
26--- |
27  ; ModuleID = 'multiple-param-dbg-value-entry.ll'
28  source_filename = "multiple-param-dbg-value-entry.c"
29  target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
30
31  @global = common dso_local local_unnamed_addr global i32 0, align 4, !dbg !0
32
33  define dso_local i32 @foo(i32 %p, i32 %q, i32 %r) local_unnamed_addr !dbg !11 {
34  entry:
35    call void @llvm.dbg.value(metadata i32 %p, metadata !15, metadata !DIExpression()), !dbg !18
36    call void @llvm.dbg.value(metadata i32 %q, metadata !16, metadata !DIExpression()), !dbg !18
37    call void @llvm.dbg.value(metadata i32 %r, metadata !17, metadata !DIExpression()), !dbg !18
38    %add = add nsw i32 %p, 1, !dbg !18
39    store i32 %add, ptr @global, align 4, !dbg !18
40    tail call void asm sideeffect "", "~{edi},~{esi},~{edx},~{dirflag},~{fpsr},~{flags}"(), !dbg !18, !srcloc !19
41    ret i32 123, !dbg !18
42  }
43
44  ; Function Attrs: nounwind readnone speculatable
45  declare void @llvm.dbg.value(metadata, metadata, metadata)
46
47  !llvm.dbg.cu = !{!2}
48  !llvm.module.flags = !{!7, !8, !9}
49  !llvm.ident = !{!10}
50
51  !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
52  !1 = distinct !DIGlobalVariable(name: "global", scope: !2, file: !3, line: 8, type: !6, isLocal: false, isDefinition: true)
53  !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 9.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, nameTableKind: None)
54  !3 = !DIFile(filename: "multiple-param-dbg-value-entry.c", directory: "/")
55  !4 = !{}
56  !5 = !{!0}
57  !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
58  !7 = !{i32 2, !"Dwarf Version", i32 4}
59  !8 = !{i32 2, !"Debug Info Version", i32 3}
60  !9 = !{i32 1, !"wchar_size", i32 4}
61  !10 = !{!"clang version 9.0.0 "}
62  !11 = distinct !DISubprogram(name: "foo", scope: !3, file: !3, line: 9, type: !12, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !14)
63  !12 = !DISubroutineType(types: !13)
64  !13 = !{!6, !6, !6, !6}
65  !14 = !{!15, !16, !17}
66  !15 = !DILocalVariable(name: "p", arg: 1, scope: !11, file: !3, line: 9, type: !6)
67  !16 = !DILocalVariable(name: "q", arg: 2, scope: !11, file: !3, line: 9, type: !6)
68  !17 = !DILocalVariable(name: "r", arg: 3, scope: !11, file: !3, line: 9, type: !6)
69  !18 = !DILocation(line: 9, column: 13, scope: !11)
70  !19 = !{i32 213}
71
72...
73---
74name:            foo
75alignment:       16
76tracksRegLiveness: true
77liveins:
78  - { reg: '$edi' }
79body:             |
80  bb.0.entry:
81    liveins: $edi
82
83    DBG_VALUE $edi, $noreg, !15, !DIExpression(), debug-location !18
84    DBG_VALUE $edi, $noreg, !15, !DIExpression(), debug-location !18
85    DBG_VALUE $esi, $noreg, !16, !DIExpression(), debug-location !18
86    DBG_VALUE $edx, $noreg, !17, !DIExpression(), debug-location !18
87    renamable $edi = nsw INC32r killed renamable $edi, implicit-def dead $eflags, debug-location !18
88    MOV32mr $rip, 1, $noreg, @global, $noreg, killed renamable $edi, debug-location !18 :: (store (s32) into @global)
89    INLINEASM &"", 1, 12, implicit-def dead early-clobber $edi, 12, implicit-def dead early-clobber $esi, 12, implicit-def dead early-clobber $edx, 12, implicit-def dead early-clobber $df, 12, implicit-def dead early-clobber $fpsw, 12, implicit-def dead early-clobber $eflags, !19, debug-location !18
90    $eax = MOV32ri 123, debug-location !18
91    RET64 killed $eax, debug-location !18
92
93...
94