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