# RUN: llc -run-pass=livedebugvalues %s -o - | FileCheck %s # # This test tests tracking variables value transferring from one register to another. # This example is altered additionally in order to test transferring from one float register # to another. The altered instructions are labeled below. # # CHECK: ![[ARG1:.*]] = !DILocalVariable(name: "arg1" # CHECK: DBG_VALUE $ebx, $noreg, ![[ARG1]], !DIExpression(), debug-location # CHECK: $r12d = MOV32rr killed $ebx, implicit-def $r12 # CHECK-NEXT: DBG_VALUE $r12d, $noreg, ![[ARG1]], !DIExpression(), debug-location --- | ; ModuleID = 'live-debug-values-reg-copy.ll' source_filename = "live-debug-values-reg-copy.c" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" define dso_local i32 @foo(i32 %arg1) local_unnamed_addr !dbg !7 { entry: %local1 = alloca i32, align 4 call void @llvm.dbg.value(metadata i32 %arg1, metadata !12, metadata !DIExpression()), !dbg !15 %0 = bitcast i32* %local1 to i8*, !dbg !15 call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %0), !dbg !15 call void @init(i32* nonnull %local1), !dbg !15 %1 = load i32, i32* %local1, align 4, !dbg !15, !tbaa !20 %add = add nsw i32 %1, %arg1, !dbg !15 %call = call i32 @coeficient(i32 %add), !dbg !15 %cmp = icmp sgt i32 %call, 32, !dbg !15 br i1 %cmp, label %if.then, label %if.else, !dbg !15 if.then: ; preds = %entry %call1 = call i32 @externFunc(i32 %arg1), !dbg !15 %2 = load i32, i32* %local1, align 4, !dbg !15, !tbaa !20 %add2 = add nsw i32 %2, %call1, !dbg !15 br label %if.end, !dbg !15 if.else: ; preds = %entry %call3 = call i32 @externFunc2(i32 %arg1), !dbg !15 %3 = load i32, i32* %local1, align 4, !dbg !15, !tbaa !20 %add4 = add nsw i32 %3, %call3, !dbg !15 br label %if.end if.end: ; preds = %if.else, %if.then %storemerge = phi i32 [ %add4, %if.else ], [ %add2, %if.then ] %4 = bitcast i32* %local1 to i8* %mul = shl nsw i32 %arg1, 2, !dbg !15 %add5 = add nsw i32 %storemerge, %mul, !dbg !15 %mul6 = mul nsw i32 %add5, %call, !dbg !15 call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %4), !dbg !15 ret i32 %mul6, !dbg !15 } ; Function Attrs: argmemonly nounwind declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #0 declare dso_local void @init(i32*) local_unnamed_addr declare dso_local i32 @coeficient(i32) local_unnamed_addr declare dso_local i32 @externFunc(i32) local_unnamed_addr declare dso_local i32 @externFunc2(i32) local_unnamed_addr ; Function Attrs: argmemonly nounwind declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #0 ; Function Attrs: nounwind readnone speculatable declare void @llvm.dbg.value(metadata, metadata, metadata) #1 ; Function Attrs: nounwind declare void @llvm.stackprotector(i8*, i8**) #2 attributes #0 = { argmemonly nounwind } attributes #1 = { nounwind readnone speculatable } attributes #2 = { nounwind } !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 7.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) !1 = !DIFile(filename: "live-debug-values-reg-copy.c", directory: "/") !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 7.0.0 "} !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) !8 = !DISubroutineType(types: !9) !9 = !{!10, !10} !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) !11 = !{!12} !12 = !DILocalVariable(name: "arg1", arg: 1, scope: !7, file: !1, line: 6, type: !10) !15 = !DILocation(line: 6, column: 13, scope: !7) !20 = !{!21, !21, i64 0} !21 = !{!"int", !22, i64 0} !22 = !{!"omnipotent char", !23, i64 0} !23 = !{!"Simple C/C++ TBAA"} ... --- name: foo alignment: 16 exposesReturnsTwice: false legalized: false regBankSelected: false selected: false tracksRegLiveness: true registers: liveins: - { reg: '$edi', virtual-reg: '' } frameInfo: isFrameAddressTaken: false isReturnAddressTaken: false hasStackMap: false hasPatchPoint: false stackSize: 40 offsetAdjustment: -40 maxAlignment: 4 adjustsStack: true hasCalls: true stackProtector: '' maxCallFrameSize: 0 hasOpaqueSPAdjustment: false hasVAStart: false hasMustTailInVarArgFunc: false savePoint: '' restorePoint: '' fixedStack: - { id: 0, type: spill-slot, offset: -32, size: 8, alignment: 16, stack-id: default, callee-saved-register: '$rbx', callee-saved-restored: true } - { id: 1, type: spill-slot, offset: -24, size: 8, alignment: 8, stack-id: default, callee-saved-register: '$r12', callee-saved-restored: true } - { id: 2, type: spill-slot, offset: -16, size: 8, alignment: 16, stack-id: default, callee-saved-register: '$rbp', callee-saved-restored: true } stack: - { id: 0, name: local1, type: default, offset: -36, size: 4, alignment: 4, stack-id: default, callee-saved-register: '', callee-saved-restored: true, debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } constants: body: | bb.0.entry: successors: %bb.1(0x40000000), %bb.2(0x40000000) liveins: $edi, $rbp, $r12, $rbx DBG_VALUE $edi, $noreg, !12, !DIExpression(), debug-location !15 frame-setup PUSH64r killed $rbp, implicit-def $rsp, implicit $rsp CFI_INSTRUCTION def_cfa_offset 16 frame-setup PUSH64r killed $r12, implicit-def $rsp, implicit $rsp CFI_INSTRUCTION def_cfa_offset 24 frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp CFI_INSTRUCTION def_cfa_offset 32 $rsp = frame-setup SUB64ri8 $rsp, 16, implicit-def dead $eflags CFI_INSTRUCTION def_cfa_offset 48 CFI_INSTRUCTION offset $rbx, -32 CFI_INSTRUCTION offset $r12, -24 CFI_INSTRUCTION offset $rbp, -16 renamable $ebx = COPY $edi, implicit-def $rbx DBG_VALUE $ebx, $noreg, !12, !DIExpression(), debug-location !15 renamable $rdi = LEA64r $rsp, 1, $noreg, 12, $noreg CALL64pcrel32 @init, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp, debug-location !15 renamable $edi = MOV32rm $rsp, 1, $noreg, 12, $noreg :: (dereferenceable load (s32) from %ir.local1, !tbaa !20) renamable $edi = ADD32rr killed renamable $edi, renamable $ebx, implicit-def dead $eflags, debug-location !15 CALL64pcrel32 @coeficient, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-location !15 renamable $ebp = COPY $eax, debug-location !15 CMP32ri8 $eax, 33, implicit-def $eflags, debug-location !15 JCC_1 %bb.2, 12, implicit killed $eflags, debug-location !15 JMP_1 %bb.1, debug-location !15 bb.1.if.then: successors: %bb.3(0x80000000) liveins: $ebp, $rbx $edi = COPY renamable $ebx, debug-location !15 CALL64pcrel32 @externFunc, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-location !15 renamable $eax = KILL $eax, implicit-def $rax, debug-location !15 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) JMP_1 %bb.3, debug-location !15 bb.2.if.else: successors: %bb.3(0x80000000) liveins: $ebp, $rbx $edi = COPY renamable $ebx, debug-location !15 CALL64pcrel32 @externFunc2, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-location !15 renamable $eax = KILL $eax, implicit-def $rax, debug-location !15 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) bb.3.if.end: liveins: $ebp, $rax, $rbx, $r12 ; Instruction below is added in order to test moving variable's value from one register to another. $r12d = MOV32rr killed $ebx, implicit-def $r12 renamable $eax = nsw LEA64_32r killed renamable $rax, 4, killed renamable $rbx, 0, $noreg, debug-location !15 renamable $eax = nsw IMUL32rr killed renamable $eax, killed renamable $ebp, implicit-def dead $eflags, debug-location !15 $rsp = frame-destroy ADD64ri8 $rsp, 16, implicit-def dead $eflags, debug-location !15 CFI_INSTRUCTION def_cfa_offset 32, debug-location !15 $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !15 CFI_INSTRUCTION def_cfa_offset 24, debug-location !15 $r12 = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !15 CFI_INSTRUCTION def_cfa_offset 16, debug-location !15 $rbp = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !15 CFI_INSTRUCTION def_cfa_offset 8, debug-location !15 RET 0, $eax, debug-location !15 ...