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