xref: /llvm-project/llvm/test/DebugInfo/Sparc/entry-value-complex-reg-expr.ll (revision 391f323690b9ef84d13a09ff07fb805008401fee)
1; RUN: llc -debug-entry-values -filetype=asm -o - %s | FileCheck %s
2; RUN: llc -force-instr-ref-livedebugvalues=1 -debug-entry-values -filetype=asm -o - %s | FileCheck %s
3
4; The q0 register does not have a DWARF register number, and is instead emitted
5; as a composite location description with two sub-registers. Previously we
6; emitted a single DW_OP_entry_value wrapping that whole composite location
7; description, but that is not valid DWARF; DW_OP_entry_value operations can
8; only hold DWARF expressions and register location descriptions.
9;
10; In the future we may want to emit a composite location description where each
11; DW_OP_regx operation is wrapped in an entry value operation, but for now
12; just verify that no invalid DWARF is emitted.
13
14target datalayout = "E-m:e-i64:64-n32:64-S128"
15target triple = "sparc64"
16
17; Based on the following C reproducer:
18;
19; volatile long double global;
20; extern void clobber();
21; int foo(long double p) {
22;   global = p;
23;   clobber();
24;   return 123;
25; }
26
27; Verify that we got an entry value in the DIExpression...
28; CHECK: DEBUG_VALUE: foo:p <- [DW_OP_LLVM_entry_value 1] $q0
29
30; ... but that no entry value location was emitted:
31; CHECK:      .half   8         ! Loc expr size
32; CHECK-NEXT: .byte   144       ! sub-register DW_OP_regx
33; CHECK-NEXT: .byte   72        ! 72
34; CHECK-NEXT: .byte   147       ! DW_OP_piece
35; CHECK-NEXT: .byte   8         ! 8
36; CHECK-NEXT: .byte   144       ! sub-register DW_OP_regx
37; CHECK-NEXT: .byte   73        ! 73
38; CHECK-NEXT: .byte   147       ! DW_OP_piece
39; CHECK-NEXT: .byte   8         ! 8
40; CHECK-NEXT: .xword  0
41; CHECK-NEXT: .xword  0
42
43@global = common global fp128 0xL00000000000000000000000000000000, align 16, !dbg !0
44
45; Function Attrs: nounwind
46define signext i32 @foo(fp128 %p) #0 !dbg !12 {
47entry:
48  call void @llvm.dbg.value(metadata fp128 %p, metadata !17, metadata !DIExpression()), !dbg !18
49  store volatile fp128 %p, ptr @global, align 16, !dbg !19
50  tail call void @clobber(), !dbg !20
51  ret i32 123, !dbg !21
52}
53
54declare void @clobber()
55
56; Function Attrs: nounwind readnone speculatable willreturn
57declare void @llvm.dbg.value(metadata, metadata, metadata) #1
58
59attributes #0 = { nounwind }
60attributes #1 = { nounwind readnone speculatable willreturn }
61
62!llvm.dbg.cu = !{!2}
63!llvm.module.flags = !{!8, !9, !10}
64!llvm.ident = !{!11}
65
66!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
67!1 = distinct !DIGlobalVariable(name: "global", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true)
68!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)
69!3 = !DIFile(filename: "entry-value-complex-reg-expr.c", directory: "/")
70!4 = !{}
71!5 = !{!0}
72!6 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !7)
73!7 = !DIBasicType(name: "long double", size: 128, encoding: DW_ATE_float)
74!8 = !{i32 2, !"Dwarf Version", i32 4}
75!9 = !{i32 2, !"Debug Info Version", i32 3}
76!10 = !{i32 1, !"wchar_size", i32 4}
77!11 = !{!"clang version 10.0.0"}
78!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)
79!13 = !DISubroutineType(types: !14)
80!14 = !{!15, !7}
81!15 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
82!16 = !{!17}
83!17 = !DILocalVariable(name: "p", arg: 1, scope: !12, file: !3, line: 3, type: !7)
84!18 = !DILocation(line: 0, scope: !12)
85!19 = !DILocation(line: 4, scope: !12)
86!20 = !DILocation(line: 5, scope: !12)
87!21 = !DILocation(line: 6, scope: !12)
88