1; RUN: llc -debug-entry-values -filetype=asm -o - %s | FileCheck %s
2
3; Verify that the entry value covers both of the DW_OP_regx pieces. Previously
4; the size operand of the entry value would be hardcoded to one.
5;
6; XXX: Is this really what should be emitted, or should we instead emit one
7; entry value operation per DW_OP_regx? GDB can currently not understand
8; entry values containing complex expressions like this.
9
10target datalayout = "E-m:e-i64:64-n32:64-S128"
11target triple = "sparc64"
12
13; Based on the following C reproducer:
14;
15; volatile long double global;
16; extern void clobber();
17; int foo(long double p) {
18;   global = p;
19;   clobber();
20;   return 123;
21; }
22
23; CHECK:      .byte   243       ! DW_OP_GNU_entry_value
24; CHECK-NEXT: .byte   8         ! 8
25; CHECK-NEXT: .byte   144       ! sub-register DW_OP_regx
26; CHECK-NEXT: .byte   72        ! 72
27; CHECK-NEXT: .byte   147       ! DW_OP_piece
28; CHECK-NEXT: .byte   8         ! 8
29; CHECK-NEXT: .byte   144       ! sub-register DW_OP_regx
30; CHECK-NEXT: .byte   73        ! 73
31; CHECK-NEXT: .byte   147       ! DW_OP_piece
32; CHECK-NEXT: .byte   8         ! 8
33; CHECK-NEXT: .byte   159       ! DW_OP_stack_value
34
35@global = common global fp128 0xL00000000000000000000000000000000, align 16, !dbg !0
36
37; Function Attrs: nounwind
38define signext i32 @foo(fp128 %p) #0 !dbg !12 {
39entry:
40  call void @llvm.dbg.value(metadata fp128 %p, metadata !17, metadata !DIExpression()), !dbg !18
41  store volatile fp128 %p, fp128* @global, align 16, !dbg !19
42  tail call void @clobber(), !dbg !20
43  ret i32 123, !dbg !21
44}
45
46declare void @clobber()
47
48; Function Attrs: nounwind readnone speculatable willreturn
49declare void @llvm.dbg.value(metadata, metadata, metadata) #1
50
51attributes #0 = { nounwind }
52attributes #1 = { nounwind readnone speculatable willreturn }
53
54!llvm.dbg.cu = !{!2}
55!llvm.module.flags = !{!8, !9, !10}
56!llvm.ident = !{!11}
57
58!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
59!1 = distinct !DIGlobalVariable(name: "global", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true)
60!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, nameTableKind: None)
61!3 = !DIFile(filename: "entry-value-complex-reg-expr.c", directory: "/")
62!4 = !{}
63!5 = !{!0}
64!6 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !7)
65!7 = !DIBasicType(name: "long double", size: 128, encoding: DW_ATE_float)
66!8 = !{i32 2, !"Dwarf Version", i32 4}
67!9 = !{i32 2, !"Debug Info Version", i32 3}
68!10 = !{i32 1, !"wchar_size", i32 4}
69!11 = !{!"clang version 10.0.0"}
70!12 = distinct !DISubprogram(name: "foo", scope: !3, file: !3, line: 3, type: !13, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !16)
71!13 = !DISubroutineType(types: !14)
72!14 = !{!15, !7}
73!15 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
74!16 = !{!17}
75!17 = !DILocalVariable(name: "p", arg: 1, scope: !12, file: !3, line: 3, type: !7)
76!18 = !DILocation(line: 0, scope: !12)
77!19 = !DILocation(line: 4, scope: !12)
78!20 = !DILocation(line: 5, scope: !12)
79!21 = !DILocation(line: 6, scope: !12)
80