236 lines · plain
1# RUN: llc -run-pass=livedebugvalues %s -o - | FileCheck %s2#3# This test tests tracking variables value transferring from one register to another.4# This example is altered additionally in order to test transferring from one float register5# to another. The altered instructions are labeled below.6#7# CHECK: ![[ARG1:.*]] = !DILocalVariable(name: "arg1"8# CHECK: ![[VAR1:.*]] = !DILocalVariable(name: "var1"9# CHECK: DBG_VALUE $ebx, $noreg, ![[ARG1]], !DIExpression(), debug-location10# CHECK: DBG_VALUE_LIST ![[VAR1]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus), $ebx, $r13d11# CHECK: $r12d = MOV32rr killed $ebx, implicit-def $r1212# CHECK-NEXT: DBG_VALUE_LIST !13, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus), $r12d, $r13d13# CHECK-NEXT: DBG_VALUE $r12d, $noreg, ![[ARG1]], !DIExpression(), debug-location14# CHECK: $r10d = MOV32rr killed $r13d, implicit-def $r1015# CHECK-NEXT: DBG_VALUE_LIST !13, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus), $r12d, $r10d16--- |17 ; ModuleID = 'live-debug-values-reg-copy.ll'18 source_filename = "live-debug-values-reg-copy.c"19 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"20 target triple = "x86_64-unknown-linux-gnu"21 22 define dso_local i32 @foo(i32 %arg1) local_unnamed_addr !dbg !7 {23 entry:24 %local1 = alloca i32, align 425 call void @llvm.dbg.value(metadata i32 %arg1, metadata !12, metadata !DIExpression()), !dbg !1526 %0 = bitcast ptr %local1 to ptr, !dbg !1527 call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %0), !dbg !1528 call void @init(ptr nonnull %local1), !dbg !1529 %1 = load i32, ptr %local1, align 4, !dbg !15, !tbaa !2030 %add = add nsw i32 %1, %arg1, !dbg !1531 %call = call i32 @coeficient(i32 %add), !dbg !1532 %cmp = icmp sgt i32 %call, 32, !dbg !1533 br i1 %cmp, label %if.then, label %if.else, !dbg !1534 35 if.then: ; preds = %entry36 %call1 = call i32 @externFunc(i32 %arg1), !dbg !1537 %2 = load i32, ptr %local1, align 4, !dbg !15, !tbaa !2038 %add2 = add nsw i32 %2, %call1, !dbg !1539 br label %if.end, !dbg !1540 41 if.else: ; preds = %entry42 %call3 = call i32 @externFunc2(i32 %arg1), !dbg !1543 %3 = load i32, ptr %local1, align 4, !dbg !15, !tbaa !2044 %add4 = add nsw i32 %3, %call3, !dbg !1545 br label %if.end46 47 if.end: ; preds = %if.else, %if.then48 %storemerge = phi i32 [ %add4, %if.else ], [ %add2, %if.then ]49 %4 = bitcast ptr %local1 to ptr50 %mul = shl nsw i32 %arg1, 2, !dbg !1551 %add5 = add nsw i32 %storemerge, %mul, !dbg !1552 %mul6 = mul nsw i32 %add5, %call, !dbg !1553 call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4), !dbg !1554 ret i32 %mul6, !dbg !1555 }56 57 ; Function Attrs: argmemonly nounwind58 declare void @llvm.lifetime.start.p0(i64, ptr nocapture) #059 60 declare dso_local void @init(ptr) local_unnamed_addr61 62 declare dso_local i32 @coeficient(i32) local_unnamed_addr63 64 declare dso_local i32 @externFunc(i32) local_unnamed_addr65 66 declare dso_local i32 @externFunc2(i32) local_unnamed_addr67 68 ; Function Attrs: argmemonly nounwind69 declare void @llvm.lifetime.end.p0(i64, ptr nocapture) #070 71 ; Function Attrs: nounwind readnone speculatable72 declare void @llvm.dbg.value(metadata, metadata, metadata) #173 74 ; Function Attrs: nounwind75 declare void @llvm.stackprotector(ptr, ptr) #276 77 attributes #0 = { argmemonly nounwind }78 attributes #1 = { nounwind readnone speculatable }79 attributes #2 = { nounwind }80 81 !llvm.dbg.cu = !{!0}82 !llvm.module.flags = !{!3, !4, !5}83 !llvm.ident = !{!6}84 85 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 7.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)86 !1 = !DIFile(filename: "live-debug-values-reg-copy.c", directory: "/")87 !2 = !{}88 !3 = !{i32 2, !"Dwarf Version", i32 4}89 !4 = !{i32 2, !"Debug Info Version", i32 3}90 !5 = !{i32 1, !"wchar_size", i32 4}91 !6 = !{!"clang version 7.0.0 "}92 !7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 6, type: !8, isLocal: false, isDefinition: true, scopeLine: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !11)93 !8 = !DISubroutineType(types: !9)94 !9 = !{!10, !10}95 !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)96 !11 = !{!12, !13}97 !12 = !DILocalVariable(name: "arg1", arg: 1, scope: !7, file: !1, line: 6, type: !10)98 !13 = !DILocalVariable(name: "var1", arg: 1, scope: !7, file: !1, line: 6, type: !10)99 !15 = !DILocation(line: 6, column: 13, scope: !7)100 !20 = !{!21, !21, i64 0}101 !21 = !{!"int", !22, i64 0}102 !22 = !{!"omnipotent char", !23, i64 0}103 !23 = !{!"Simple C/C++ TBAA"}104 105...106---107name: foo108alignment: 16109exposesReturnsTwice: false110legalized: false111regBankSelected: false112selected: false113tracksRegLiveness: true114debugInstrRef: true115registers:116liveins:117 - { reg: '$edi', virtual-reg: '' }118 - { reg: '$r8d', virtual-reg: '' }119frameInfo:120 isFrameAddressTaken: false121 isReturnAddressTaken: false122 hasStackMap: false123 hasPatchPoint: false124 stackSize: 48125 offsetAdjustment: -48126 maxAlignment: 4127 adjustsStack: true128 hasCalls: true129 stackProtector: ''130 maxCallFrameSize: 0131 hasOpaqueSPAdjustment: false132 hasVAStart: false133 hasMustTailInVarArgFunc: false134 savePoint: []135 restorePoint: []136fixedStack:137 - { id: 0, type: spill-slot, offset: -48, size: 8, alignment: 16, stack-id: default,138 callee-saved-register: '$rbx', callee-saved-restored: true }139 - { id: 1, type: spill-slot, offset: -40, size: 8, alignment: 8, stack-id: default,140 callee-saved-register: '$r12', callee-saved-restored: true }141 - { id: 2, type: spill-slot, offset: -32, size: 8, alignment: 16, stack-id: default,142 callee-saved-register: '$rbp', callee-saved-restored: true }143 - { id: 3, type: spill-slot, offset: -24, size: 8, alignment: 16, stack-id: default,144 callee-saved-register: '$r13', callee-saved-restored: true }145 - { id: 4, type: spill-slot, offset: -16, size: 8, alignment: 16, stack-id: default,146 callee-saved-register: '$r10', callee-saved-restored: true }147stack:148 - { id: 0, name: local1, type: default, offset: -36, size: 4, alignment: 4,149 stack-id: default, callee-saved-register: '', callee-saved-restored: true,150 debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }151constants:152body: |153 bb.0.entry:154 successors: %bb.1(0x40000000), %bb.2(0x40000000)155 liveins: $edi, $rbp, $r8, $r10, $r13, $r12, $rbx156 157 DBG_VALUE $edi, $noreg, !12, !DIExpression(), debug-location !15158 DBG_VALUE_LIST !13, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus), $edi, $r8d, debug-location !15159 frame-setup PUSH64r killed $r10, implicit-def $rsp, implicit $rsp160 CFI_INSTRUCTION def_cfa_offset 16161 frame-setup PUSH64r killed $r13, implicit-def $rsp, implicit $rsp162 CFI_INSTRUCTION def_cfa_offset 24163 frame-setup PUSH64r killed $rbp, implicit-def $rsp, implicit $rsp164 CFI_INSTRUCTION def_cfa_offset 32165 frame-setup PUSH64r killed $r12, implicit-def $rsp, implicit $rsp166 CFI_INSTRUCTION def_cfa_offset 40167 frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp168 CFI_INSTRUCTION def_cfa_offset 48169 $rsp = frame-setup SUB64ri8 $rsp, 16, implicit-def dead $eflags170 CFI_INSTRUCTION def_cfa_offset 56171 CFI_INSTRUCTION offset $rbx, -48172 CFI_INSTRUCTION offset $rbx, -40173 CFI_INSTRUCTION offset $r12, -32174 CFI_INSTRUCTION offset $rbp, -24175 CFI_INSTRUCTION offset $r13, -16176 renamable $ebx = COPY $edi, implicit-def $rbx177 renamable $r13d = COPY $r8d, implicit-def $r13178 DBG_VALUE $ebx, $noreg, !12, !DIExpression(), debug-location !15179 DBG_VALUE_LIST !13, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus), $ebx, $r13d, debug-location !15180 renamable $rdi = LEA64r $rsp, 1, $noreg, 12, $noreg181 renamable $r8 = LEA64r $rsp, 1, $noreg, 12, $noreg182 CALL64pcrel32 @init, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp, debug-location !15183 renamable $edi = MOV32rm $rsp, 1, $noreg, 12, $noreg :: (dereferenceable load (s32) from %ir.local1, !tbaa !20)184 renamable $edi = ADD32rr killed renamable $edi, renamable $ebx, implicit-def dead $eflags, debug-location !15185 renamable $r8d = MOV32rm $rsp, 1, $noreg, 12, $noreg :: (dereferenceable load (s32) from %ir.local1, !tbaa !20)186 renamable $r8d = ADD32rr killed renamable $r8d, renamable $r13d, implicit-def dead $eflags, debug-location !15187 CALL64pcrel32 @coeficient, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit $r8d, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-location !15188 renamable $ebp = COPY $eax, debug-location !15189 CMP32ri8 $eax, 33, implicit-def $eflags, debug-location !15190 JCC_1 %bb.2, 12, implicit killed $eflags, debug-location !15191 JMP_1 %bb.1, debug-location !15192 193 bb.1.if.then:194 successors: %bb.3(0x80000000)195 liveins: $ebp, $rbx, $r13196 197 $edi = COPY renamable $ebx, debug-location !15198 $r8d = COPY renamable $r13d, debug-location !15199 CALL64pcrel32 @externFunc, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-location !15200 renamable $eax = KILL $eax, implicit-def $rax, debug-location !15201 renamable $eax = nsw ADD32rm renamable $eax, $rsp, 1, $noreg, 12, $noreg, implicit-def dead $eflags, implicit killed $rax, implicit-def $rax, debug-location !15 :: (dereferenceable load (s32) from %ir.local1, !tbaa !20)202 JMP_1 %bb.3, debug-location !15203 204 bb.2.if.else:205 successors: %bb.3(0x80000000)206 liveins: $ebp, $r13, $rbx207 208 $edi = COPY renamable $ebx, debug-location !15209 $r8d = COPY renamable $r13d, debug-location !15210 CALL64pcrel32 @externFunc2, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-location !15211 renamable $eax = KILL $eax, implicit-def $rax, debug-location !15212 renamable $eax = nsw ADD32rm renamable $eax, $rsp, 1, $noreg, 12, $noreg, implicit-def dead $eflags, implicit killed $rax, implicit-def $rax, debug-location !15 :: (dereferenceable load (s32) from %ir.local1, !tbaa !20)213 214 bb.3.if.end:215 liveins: $ebp, $rax, $rbx, $r13, $r12, $r10216 ; Instruction below is added in order to test moving variable's value from one register to another.217 $r12d = MOV32rr killed $ebx, implicit-def $r12218 $r10d = MOV32rr killed $r13d, implicit-def $r10219 renamable $eax = nsw LEA64_32r killed renamable $rax, 4, killed renamable $rbx, 0, $noreg, debug-location !15220 renamable $eax = nsw IMUL32rr killed renamable $eax, killed renamable $ebp, implicit-def dead $eflags, debug-location !15221 $rsp = frame-destroy ADD64ri8 $rsp, 16, implicit-def dead $eflags, debug-location !15222 CFI_INSTRUCTION def_cfa_offset 48, debug-location !15223 $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !15224 CFI_INSTRUCTION def_cfa_offset 40, debug-location !15225 $r12 = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !15226 CFI_INSTRUCTION def_cfa_offset 32, debug-location !15227 $rbp = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !15228 CFI_INSTRUCTION def_cfa_offset 24, debug-location !15229 $r13 = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !15230 CFI_INSTRUCTION def_cfa_offset 16, debug-location !15231 $r13 = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !15232 CFI_INSTRUCTION def_cfa_offset 8, debug-location !15233 RET 0, $eax, debug-location !15234 235...236