xref: /llvm-project/llvm/test/DebugInfo/MIR/ARM/param-reg-const-mix.mir (revision 92b33822e989884d29465d34769b07d78aeb1a84)
1# RUN: llc -mtriple=armv4t-unknown-unknown -start-after=livedebugvalues -filetype=obj -o - %s | llvm-dwarfdump - | FileCheck %s
2
3# This reproducer is based on the following C code:
4#
5# struct S0 { int f1; int f2; int f3; };
6#
7# int a;
8#
9# void fn1(struct S0 p1) {
10#   a = p1.f1 >= fn2(p1.f2);
11# }
12#
13# and was generated using the following commands:
14# $ clang -O1 -g --target=armv4t -S -emit-llvm
15# $ llc -O1 -stop-after=livedebugvalues
16
17--- |
18  target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
19  target triple = "armv4t-unknown-unknown"
20
21  ; Function Attrs: nounwind
22  define arm_aapcscc i32 @fn1([3 x i32] %p1.coerce) !dbg !7 {
23  entry:
24    %p1.coerce.fca.0.extract = extractvalue [3 x i32] %p1.coerce, 0
25    call void @llvm.dbg.value(metadata i32 %p1.coerce.fca.0.extract, metadata !17, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 32)), !dbg !18
26    %p1.coerce.fca.1.extract = extractvalue [3 x i32] %p1.coerce, 1
27    call void @llvm.dbg.value(metadata i32 %p1.coerce.fca.1.extract, metadata !17, metadata !DIExpression(DW_OP_LLVM_fragment, 32, 32)), !dbg !18
28    call void @llvm.dbg.value(metadata i32 undef, metadata !17, metadata !DIExpression(DW_OP_LLVM_fragment, 64, 32)), !dbg !18
29    %call = tail call arm_aapcscc i32 @fn2(i32 %p1.coerce.fca.1.extract), !dbg !19
30    %cmp = icmp sge i32 %p1.coerce.fca.0.extract, %call, !dbg !19
31    %conv = zext i1 %cmp to i32, !dbg !19
32    ret i32 %conv, !dbg !19
33  }
34
35  declare arm_aapcscc i32 @fn2(...)
36
37  ; Function Attrs: nounwind readnone speculatable
38  declare void @llvm.dbg.value(metadata, metadata, metadata) #0
39
40  attributes #0 = { nounwind readnone speculatable }
41
42  !llvm.dbg.cu = !{!0}
43  !llvm.module.flags = !{!3, !4, !5}
44  !llvm.ident = !{!6}
45
46  !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 9.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
47  !1 = !DIFile(filename: "test.c", directory: "/")
48  !2 = !{}
49  !3 = !{i32 2, !"Dwarf Version", i32 4}
50  !4 = !{i32 2, !"Debug Info Version", i32 3}
51  !5 = !{i32 1, !"min_enum_size", i32 4}
52  !6 = !{!"clang version 9.0.0"}
53  !7 = distinct !DISubprogram(name: "fn1", scope: !1, file: !1, line: 3, type: !8, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !16)
54  !8 = !DISubroutineType(types: !9)
55  !9 = !{!10, !11}
56  !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
57  !11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S0", file: !1, line: 1, size: 96, elements: !12)
58  !12 = !{!13, !14, !15}
59  !13 = !DIDerivedType(tag: DW_TAG_member, name: "f1", scope: !11, file: !1, line: 1, baseType: !10, size: 32)
60  !14 = !DIDerivedType(tag: DW_TAG_member, name: "f2", scope: !11, file: !1, line: 1, baseType: !10, size: 32, offset: 32)
61  !15 = !DIDerivedType(tag: DW_TAG_member, name: "f3", scope: !11, file: !1, line: 1, baseType: !10, size: 32, offset: 64)
62  !16 = !{!17}
63  !17 = !DILocalVariable(name: "p1", arg: 1, scope: !7, file: !1, line: 3, type: !11)
64  !18 = !DILocation(line: 3, scope: !7)
65  !19 = !DILocation(line: 4, scope: !7)
66
67...
68---
69name:            fn1
70tracksRegLiveness: true
71body:             |
72  bb.0.entry:
73    liveins: $r0, $r1, $r4, $lr
74
75    $sp = frame-setup STMDB_UPD $sp, 14, $noreg, killed $r4, killed $lr
76    $r4 = MOVr $r0, 14, $noreg, $noreg
77    DBG_VALUE $r1, $noreg, !17, !DIExpression(DW_OP_LLVM_fragment, 32, 32), debug-location !18
78    DBG_VALUE $noreg, $noreg, !17, !DIExpression(DW_OP_LLVM_fragment, 64, 32), debug-location !18
79    DBG_VALUE $r4, $noreg, !17, !DIExpression(DW_OP_LLVM_fragment, 0, 32), debug-location !18
80    $r0 = MOVr killed $r1, 14, $noreg, $noreg, debug-location !19
81    BL @fn2, csr_aapcs, implicit-def dead $lr, implicit $sp, implicit $r0, implicit-def $sp, implicit-def $r0, debug-location !19
82    renamable $r1 = MOVi 0, 14, $noreg, $noreg
83    CMPrr killed renamable $r4, killed renamable $r0, 14, $noreg, implicit-def $cpsr, debug-location !19
84    $r1 = MOVi 1, 10, killed $cpsr, $noreg, implicit killed renamable $r1, debug-location !19
85    $r0 = MOVr killed $r1, 14, $noreg, $noreg, debug-location !19
86    $sp = LDMIA_UPD $sp, 14, $noreg, def $r4, def $lr, debug-location !19
87    BX_RET 14, $noreg, implicit $r0, debug-location !19
88
89...
90
91# Verify that the addresses in the location list for the parameter are
92# monotonically increasing, and that the undef debug value fragment does not
93# terminate the non-overlapping fragment that is described by $r1.
94
95# CHECK: DW_AT_location (0x00000000
96# CHECK-NEXT: [0x00000008, 0x00000010): DW_OP_reg4 R4, DW_OP_piece 0x4, DW_OP_reg1 R1, DW_OP_piece 0x4
97# CHECK-NEXT: [0x00000010, 0x00000024): DW_OP_reg4 R4, DW_OP_piece 0x4)
98# CHECK-NEXT: DW_AT_name ("p1")
99