1 ; RUN: llc < %s | FileCheck %s
2 ; RUN: llc -O0 < %s | FileCheck %s
4 ; Make sure we insert DW_OP_deref when spilling indirect DBG_VALUE instructions.
7 ; #define FORCE_SPILL() \
8 ; __asm volatile("" : : : \
9 ; "rax", "rbx", "rcx", "rdx", "rsi", "rdi", "rbp", "r8", \
10 ; "r9", "r10", "r11", "r12", "r13", "r14", "r15")
17 ; string get_string() {
23 ; CHECK-LABEL: _Z10get_stringv:
24 ; CHECK: #DEBUG_VALUE: get_string:result <- [DW_OP_deref] $rdi
25 ; CHECK: movq %rdi, [[OFFS:[0-9]+]](%rsp) # 8-byte Spill
26 ; CHECK: #DEBUG_VALUE: get_string:result <- [DW_OP_plus_uconst [[OFFS]], DW_OP_deref] [$rsp+0]
27 ; CHECK: callq _ZN6stringC1Ei
32 source_filename = "t.cpp"
33 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
34 target triple = "x86_64--linux"
36 %struct.string = type { i32 }
38 ; Function Attrs: uwtable
39 define void @_Z10get_stringv(%struct.string* noalias sret %agg.result) #0 !dbg !7 {
41 %nrvo = alloca i1, align 1
42 store i1 false, i1* %nrvo, align 1, !dbg !24
43 call void @llvm.dbg.declare(metadata %struct.string* %agg.result, metadata !23, metadata !DIExpression()), !dbg !25
44 call void @_ZN6stringC1Ei(%struct.string* %agg.result, i32 3), !dbg !26
45 call void asm sideeffect "", "~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15},~{dirflag},~{fpsr},~{flags}"() #3, !dbg !27, !srcloc !28
46 store i1 true, i1* %nrvo, align 1, !dbg !29
47 %nrvo.val = load i1, i1* %nrvo, align 1, !dbg !30
48 br i1 %nrvo.val, label %nrvo.skipdtor, label %nrvo.unused, !dbg !30
50 nrvo.unused: ; preds = %entry
51 call void @_ZN6stringD1Ev(%struct.string* %agg.result), !dbg !30
52 br label %nrvo.skipdtor, !dbg !30
54 nrvo.skipdtor: ; preds = %nrvo.unused, %entry
58 ; Function Attrs: nounwind readnone speculatable
59 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
61 declare void @_ZN6stringC1Ei(%struct.string*, i32) unnamed_addr
63 declare void @_ZN6stringD1Ev(%struct.string*) unnamed_addr
65 attributes #0 = { uwtable }
66 attributes #1 = { nounwind readnone speculatable }
67 attributes #3 = { nounwind }
70 !llvm.module.flags = !{!3, !4, !5}
73 !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)
74 !1 = !DIFile(filename: "t.cpp", directory: "C:\5Csrc\5Cllvm-project\5Cbuild")
76 !3 = !{i32 2, !"Dwarf Version", i32 4}
77 !4 = !{i32 2, !"Debug Info Version", i32 3}
78 !5 = !{i32 1, !"wchar_size", i32 4}
79 !6 = !{!"clang version 6.0.0 "}
80 !7 = distinct !DISubprogram(name: "get_string", linkageName: "_Z10get_stringv", scope: !1, file: !1, line: 13, type: !8, isLocal: false, isDefinition: true, scopeLine: 13, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !22)
81 !8 = !DISubroutineType(types: !9)
83 !10 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "string", file: !1, line: 7, size: 32, elements: !11, identifier: "_ZTS6string")
84 !11 = !{!12, !14, !18, !21}
85 !12 = !DIDerivedType(tag: DW_TAG_member, name: "i", scope: !10, file: !1, line: 11, baseType: !13, size: 32)
86 !13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
87 !14 = !DISubprogram(name: "string", scope: !10, file: !1, line: 8, type: !15, isLocal: false, isDefinition: false, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: true)
88 !15 = !DISubroutineType(types: !16)
90 !17 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
91 !18 = !DISubprogram(name: "string", scope: !10, file: !1, line: 9, type: !19, isLocal: false, isDefinition: false, scopeLine: 9, flags: DIFlagPrototyped, isOptimized: true)
92 !19 = !DISubroutineType(types: !20)
93 !20 = !{null, !17, !13}
94 !21 = !DISubprogram(name: "~string", scope: !10, file: !1, line: 10, type: !15, isLocal: false, isDefinition: false, scopeLine: 10, flags: DIFlagPrototyped, isOptimized: true)
96 !23 = !DILocalVariable(name: "result", scope: !7, file: !1, line: 14, type: !10)
97 !24 = !DILocation(line: 14, column: 3, scope: !7)
98 !25 = !DILocation(line: 14, column: 10, scope: !7)
99 !26 = !DILocation(line: 14, column: 19, scope: !7)
100 !27 = !DILocation(line: 15, column: 3, scope: !7)
101 !28 = !{i32 -2147471175}
102 !29 = !DILocation(line: 16, column: 3, scope: !7)
103 !30 = !DILocation(line: 17, column: 1, scope: !7)