| # RUN: llc -run-pass livedebugvalues -march=x86-64 -o - %s | FileCheck %s |
| |
| # Generated from the following source with: |
| # clang -g -mllvm -stop-before=livedebugvalues -S -O2 test.c -o test.mir |
| |
| # #define FORCE_SPILL() \ |
| # __asm volatile("" : : : \ |
| # "rax", "rbx", "rcx", "rdx", "rsi", "rdi", "rbp", "r8", \ |
| # "r9", "r10", "r11", "r12", "r13", "r14", "r15") |
| # int f(int *p) { |
| # if (p) { |
| # FORCE_SPILL(); |
| # } |
| # return *(p + 1); |
| # } |
| |
| # Ascertain that the spill has been recognized and manifested in a DBG_VALUE. |
| # CHECK: MOV64mr $rsp,{{.*-8.*}}killed{{.*}}$rdi :: (store 8 into %stack.0) |
| # CHECK-NEXT: DBG_VALUE $rsp,{{.*}}![[MDIX:[0-9]+]],{{.*}}!DIExpression(DW_OP_constu, 8, DW_OP_minus) |
| |
| # Check for the restore. |
| # CHECK: $rdi = MOV64rm $rsp,{{.*-8.*}}:: (load 8 from %stack.0) |
| # CHECK-NEXT: DBG_VALUE $rdi,{{.*}}![[MDIX]], !DIExpression() |
| |
| --- | |
| define dso_local i32 @f(i32* readonly %p) local_unnamed_addr !dbg !7 { |
| entry: |
| call void @llvm.dbg.value(metadata i32* %p, metadata !13, metadata !DIExpression()), !dbg !14 |
| %tobool = icmp eq i32* %p, null, !dbg !15 |
| br i1 %tobool, label %if.end, label %if.then, !dbg !17 |
| |
| if.then: ; preds = %entry |
| tail call void asm sideeffect "", "~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15},~{dirflag},~{fpsr},~{flags}"(), !dbg !18, !srcloc !20 |
| br label %if.end, !dbg !21 |
| |
| if.end: ; preds = %entry, %if.then |
| %add.ptr = getelementptr inbounds i32, i32* %p, i64 1, !dbg !22 |
| %0 = load i32, i32* %add.ptr, align 4, !dbg !23, !tbaa !24 |
| ret i32 %0, !dbg !28 |
| } |
| |
| declare void @llvm.dbg.value(metadata, metadata, metadata) |
| |
| !llvm.dbg.cu = !{!0} |
| !llvm.module.flags = !{!3, !4, !5} |
| !llvm.ident = !{!6} |
| |
| !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 9.0.0 (https://git.llvm.org/git/clang.git/ 57a6ce7ac318de98e3e777e09cb9ed8282b5cc03) (https://git.llvm.org/git/llvm.git/ ff54a19e4912d7f15cb02798a7f2048441bff751)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None) |
| !1 = !DIFile(filename: "test2.c", directory: "/home/test") |
| !2 = !{} |
| !3 = !{i32 2, !"Dwarf Version", i32 4} |
| !4 = !{i32 2, !"Debug Info Version", i32 3} |
| !5 = !{i32 1, !"wchar_size", i32 4} |
| !6 = !{!"clang version 9.0.0 (https://git.llvm.org/git/clang.git/ 57a6ce7ac318de98e3e777e09cb9ed8282b5cc03) (https://git.llvm.org/git/llvm.git/ ff54a19e4912d7f15cb02798a7f2048441bff751)"} |
| !7 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 5, type: !8, scopeLine: 5, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !12) |
| !8 = !DISubroutineType(types: !9) |
| !9 = !{!10, !11} |
| !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) |
| !11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64) |
| !12 = !{!13} |
| !13 = !DILocalVariable(name: "p", arg: 1, scope: !7, file: !1, line: 5, type: !11) |
| !14 = !DILocation(line: 5, column: 12, scope: !7) |
| !15 = !DILocation(line: 6, column: 7, scope: !16) |
| !16 = distinct !DILexicalBlock(scope: !7, file: !1, line: 6, column: 7) |
| !17 = !DILocation(line: 6, column: 7, scope: !7) |
| !18 = !DILocation(line: 7, column: 5, scope: !19) |
| !19 = distinct !DILexicalBlock(scope: !16, file: !1, line: 6, column: 10) |
| !20 = !{i32 -2147471544} |
| !21 = !DILocation(line: 8, column: 3, scope: !19) |
| !22 = !DILocation(line: 9, column: 14, scope: !7) |
| !23 = !DILocation(line: 9, column: 10, scope: !7) |
| !24 = !{!25, !25, i64 0} |
| !25 = !{!"int", !26, i64 0} |
| !26 = !{!"omnipotent char", !27, i64 0} |
| !27 = !{!"Simple C/C++ TBAA"} |
| !28 = !DILocation(line: 9, column: 3, scope: !7) |
| |
| ... |
| --- |
| name: f |
| alignment: 4 |
| exposesReturnsTwice: false |
| legalized: false |
| regBankSelected: false |
| selected: false |
| failedISel: false |
| tracksRegLiveness: true |
| hasWinCFI: false |
| registers: [] |
| liveins: |
| - { reg: '$rdi', virtual-reg: '' } |
| frameInfo: |
| isFrameAddressTaken: false |
| isReturnAddressTaken: false |
| hasStackMap: false |
| hasPatchPoint: false |
| stackSize: 48 |
| offsetAdjustment: -48 |
| maxAlignment: 8 |
| adjustsStack: false |
| hasCalls: false |
| stackProtector: '' |
| maxCallFrameSize: 0 |
| cvBytesOfCalleeSavedRegisters: 48 |
| hasOpaqueSPAdjustment: false |
| hasVAStart: false |
| hasMustTailInVarArgFunc: false |
| localFrameSize: 0 |
| savePoint: '' |
| restorePoint: '' |
| fixedStack: |
| - { id: 0, type: spill-slot, offset: -56, size: 8, alignment: 8, stack-id: 0, |
| callee-saved-register: '$rbx', callee-saved-restored: true, debug-info-variable: '', |
| debug-info-expression: '', debug-info-location: '' } |
| - { id: 1, type: spill-slot, offset: -48, size: 8, alignment: 16, stack-id: 0, |
| callee-saved-register: '$r12', callee-saved-restored: true, debug-info-variable: '', |
| debug-info-expression: '', debug-info-location: '' } |
| - { id: 2, type: spill-slot, offset: -40, size: 8, alignment: 8, stack-id: 0, |
| callee-saved-register: '$r13', callee-saved-restored: true, debug-info-variable: '', |
| debug-info-expression: '', debug-info-location: '' } |
| - { id: 3, type: spill-slot, offset: -32, size: 8, alignment: 16, stack-id: 0, |
| callee-saved-register: '$r14', callee-saved-restored: true, debug-info-variable: '', |
| debug-info-expression: '', debug-info-location: '' } |
| - { id: 4, type: spill-slot, offset: -24, size: 8, alignment: 8, stack-id: 0, |
| callee-saved-register: '$r15', callee-saved-restored: true, debug-info-variable: '', |
| debug-info-expression: '', debug-info-location: '' } |
| - { id: 5, type: spill-slot, offset: -16, size: 8, alignment: 16, stack-id: 0, |
| callee-saved-register: '$rbp', callee-saved-restored: true, debug-info-variable: '', |
| debug-info-expression: '', debug-info-location: '' } |
| stack: |
| - { id: 0, name: '', type: spill-slot, offset: -64, size: 8, alignment: 8, |
| stack-id: 0, callee-saved-register: '', callee-saved-restored: true, |
| debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } |
| constants: [] |
| body: | |
| bb.0.entry: |
| successors: %bb.2(0x30000000), %bb.1(0x50000000) |
| liveins: $rdi, $rbx, $r12, $r13, $r14, $r15, $rbp |
| |
| DBG_VALUE $rdi, $noreg, !13, !DIExpression(), debug-location !14 |
| DBG_VALUE $rdi, $noreg, !13, !DIExpression(), debug-location !14 |
| TEST64rr renamable $rdi, renamable $rdi, implicit-def $eflags, debug-location !15 |
| JE_1 %bb.2, implicit $eflags, debug-location !17 |
| |
| bb.1.if.then: |
| successors: %bb.2(0x80000000) |
| liveins: $rdi, $rbp, $r15, $r14, $r13, $r12, $rbx |
| |
| frame-setup PUSH64r killed $rbp, implicit-def $rsp, implicit $rsp |
| CFI_INSTRUCTION def_cfa_offset 16 |
| frame-setup PUSH64r killed $r15, implicit-def $rsp, implicit $rsp |
| CFI_INSTRUCTION def_cfa_offset 24 |
| frame-setup PUSH64r killed $r14, implicit-def $rsp, implicit $rsp |
| CFI_INSTRUCTION def_cfa_offset 32 |
| frame-setup PUSH64r killed $r13, implicit-def $rsp, implicit $rsp |
| CFI_INSTRUCTION def_cfa_offset 40 |
| frame-setup PUSH64r killed $r12, implicit-def $rsp, implicit $rsp |
| CFI_INSTRUCTION def_cfa_offset 48 |
| frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp |
| CFI_INSTRUCTION def_cfa_offset 56 |
| CFI_INSTRUCTION offset $rbx, -56 |
| CFI_INSTRUCTION offset $r12, -48 |
| CFI_INSTRUCTION offset $r13, -40 |
| CFI_INSTRUCTION offset $r14, -32 |
| CFI_INSTRUCTION offset $r15, -24 |
| CFI_INSTRUCTION offset $rbp, -16 |
| MOV64mr $rsp, 1, $noreg, -8, $noreg, killed renamable $rdi :: (store 8 into %stack.0) |
| INLINEASM &"", 1, 12, implicit-def dead early-clobber $rax, 12, implicit-def dead early-clobber $rbx, 12, implicit-def dead early-clobber $rcx, 12, implicit-def dead early-clobber $rdx, 12, implicit-def dead early-clobber $rsi, 12, implicit-def dead early-clobber $rdi, 12, implicit-def dead early-clobber $rbp, 12, implicit-def dead early-clobber $r8, 12, implicit-def dead early-clobber $r9, 12, implicit-def dead early-clobber $r10, 12, implicit-def dead early-clobber $r11, 12, implicit-def dead early-clobber $r12, 12, implicit-def dead early-clobber $r13, 12, implicit-def dead early-clobber $r14, 12, implicit-def dead early-clobber $r15, 12, implicit-def dead early-clobber $eflags, !20, debug-location !18 |
| renamable $rdi = MOV64rm $rsp, 1, $noreg, -8, $noreg :: (load 8 from %stack.0) |
| $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp |
| CFI_INSTRUCTION def_cfa_offset 48 |
| $r12 = frame-destroy POP64r implicit-def $rsp, implicit $rsp |
| CFI_INSTRUCTION def_cfa_offset 40 |
| $r13 = frame-destroy POP64r implicit-def $rsp, implicit $rsp |
| CFI_INSTRUCTION def_cfa_offset 32 |
| $r14 = frame-destroy POP64r implicit-def $rsp, implicit $rsp |
| CFI_INSTRUCTION def_cfa_offset 24 |
| $r15 = frame-destroy POP64r implicit-def $rsp, implicit $rsp |
| CFI_INSTRUCTION def_cfa_offset 16 |
| $rbp = frame-destroy POP64r implicit-def $rsp, implicit $rsp |
| CFI_INSTRUCTION def_cfa_offset 8 |
| |
| bb.2.if.end: |
| liveins: $rdi, $rbx, $r12, $r13, $r14, $r15, $rbp |
| |
| renamable $eax = MOV32rm killed renamable $rdi, 1, $noreg, 4, $noreg, debug-location !23 :: (load 4 from %ir.add.ptr, !tbaa !24) |
| RETQ $eax, debug-location !28 |
| |
| ... |