• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s | FileCheck %s
2
3; Make sure we insert DW_OP_deref when spilling indirect DBG_VALUE instructions.
4; In this example, 'nt' is passed by address because it is not trivially
5; copyable. When we spill the physical argument register at the barrier, we need
6; to insert DW_OP_deref.
7
8; #define FORCE_SPILL() \
9;   __asm volatile("" : : : \
10;                    "rax", "rbx", "rcx", "rdx", "rsi", "rdi", "rbp", "r8", \
11;                    "r9", "r10", "r11", "r12", "r13", "r14", "r15")
12; struct NonTrivial {
13;   NonTrivial();
14;   ~NonTrivial();
15;   int i;
16; };
17; int foo(NonTrivial nt) {
18;   FORCE_SPILL();
19;   return nt.i;
20; }
21
22; CHECK-LABEL: _Z3foo10NonTrivial:
23; CHECK: #DEBUG_VALUE: foo:nt <- [$rdi+0]
24; CHECK: movq    %rdi, -8(%rsp)          # 8-byte Spill
25; CHECK: #DEBUG_VALUE: foo:nt <- [DW_OP_constu 8, DW_OP_minus, DW_OP_deref] [$rsp+0]
26; CHECK: #APP
27; CHECK: #NO_APP
28; CHECK: movq    -8(%rsp), %rax          # 8-byte Reload
29; CHECK: movl    (%rax), %eax
30
31; ModuleID = 't.cpp'
32source_filename = "t.cpp"
33target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
34target triple = "x86_64--linux"
35
36%struct.NonTrivial = type { i32 }
37
38; Function Attrs: nounwind uwtable
39define i32 @_Z3foo10NonTrivial(%struct.NonTrivial* nocapture readonly %nt) local_unnamed_addr #0 !dbg !7 {
40entry:
41  tail call void @llvm.dbg.declare(metadata %struct.NonTrivial* %nt, metadata !20, metadata !DIExpression()), !dbg !21
42  tail call void asm sideeffect "", "~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15},~{dirflag},~{fpsr},~{flags}"() #2, !dbg !22, !srcloc !23
43  %i = getelementptr inbounds %struct.NonTrivial, %struct.NonTrivial* %nt, i64 0, i32 0, !dbg !24
44  %0 = load i32, i32* %i, align 4, !dbg !24, !tbaa !25
45  ret i32 %0, !dbg !30
46}
47
48; Function Attrs: nounwind readnone speculatable
49declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
50
51attributes #0 = { nounwind uwtable }
52attributes #1 = { nounwind readnone speculatable }
53attributes #2 = { nounwind }
54
55!llvm.dbg.cu = !{!0}
56!llvm.module.flags = !{!3, !4, !5}
57!llvm.ident = !{!6}
58
59!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 6.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
60!1 = !DIFile(filename: "t.cpp", directory: "C:\5Csrc\5Cllvm-project\5Cbuild")
61!2 = !{}
62!3 = !{i32 2, !"Dwarf Version", i32 4}
63!4 = !{i32 2, !"Debug Info Version", i32 3}
64!5 = !{i32 1, !"wchar_size", i32 4}
65!6 = !{!"clang version 6.0.0 "}
66!7 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foo10NonTrivial", scope: !1, file: !1, line: 10, type: !8, isLocal: false, isDefinition: true, scopeLine: 10, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !19)
67!8 = !DISubroutineType(types: !9)
68!9 = !{!10, !11}
69!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
70!11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "NonTrivial", file: !1, line: 5, size: 32, elements: !12, identifier: "_ZTS10NonTrivial")
71!12 = !{!13, !14, !18}
72!13 = !DIDerivedType(tag: DW_TAG_member, name: "i", scope: !11, file: !1, line: 8, baseType: !10, size: 32)
73!14 = !DISubprogram(name: "NonTrivial", scope: !11, file: !1, line: 6, type: !15, isLocal: false, isDefinition: false, scopeLine: 6, flags: DIFlagPrototyped, isOptimized: true)
74!15 = !DISubroutineType(types: !16)
75!16 = !{null, !17}
76!17 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
77!18 = !DISubprogram(name: "~NonTrivial", scope: !11, file: !1, line: 7, type: !15, isLocal: false, isDefinition: false, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: true)
78!19 = !{!20}
79!20 = !DILocalVariable(name: "nt", arg: 1, scope: !7, file: !1, line: 10, type: !11)
80!21 = !DILocation(line: 10, column: 20, scope: !7)
81!22 = !DILocation(line: 11, column: 3, scope: !7)
82!23 = !{i32 -2147471481}
83!24 = !DILocation(line: 12, column: 13, scope: !7)
84!25 = !{!26, !27, i64 0}
85!26 = !{!"_ZTS10NonTrivial", !27, i64 0}
86!27 = !{!"int", !28, i64 0}
87!28 = !{!"omnipotent char", !29, i64 0}
88!29 = !{!"Simple C++ TBAA"}
89!30 = !DILocation(line: 12, column: 3, scope: !7)
90