mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:42:57 +01:00
Update debug info when live-in reg is copied into a vreg.
llvm-svn: 104732
This commit is contained in:
parent
7eae1aeb51
commit
2ea3f77515
@ -250,6 +250,13 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) {
|
||||
MachineBasicBlock *EntryMBB = MF->begin();
|
||||
RegInfo->EmitLiveInCopies(EntryMBB, TRI, TII);
|
||||
|
||||
DenseMap<unsigned, unsigned> LiveInMap;
|
||||
if (!FuncInfo->ArgDbgValues.empty())
|
||||
for (MachineRegisterInfo::livein_iterator LI = RegInfo->livein_begin(),
|
||||
E = RegInfo->livein_end(); LI != E; ++LI)
|
||||
if (LI->second)
|
||||
LiveInMap.insert(std::make_pair(LI->first, LI->second));
|
||||
|
||||
// Insert DBG_VALUE instructions for function arguments to the entry block.
|
||||
for (unsigned i = 0, e = FuncInfo->ArgDbgValues.size(); i != e; ++i) {
|
||||
MachineInstr *MI = FuncInfo->ArgDbgValues[e-i-1];
|
||||
@ -262,6 +269,21 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) {
|
||||
// FIXME: VR def may not be in entry block.
|
||||
Def->getParent()->insert(llvm::next(InsertPos), MI);
|
||||
}
|
||||
|
||||
// If Reg is live-in then update debug info to track its copy in a vreg.
|
||||
DenseMap<unsigned, unsigned>::iterator LDI = LiveInMap.find(Reg);
|
||||
if (LDI != LiveInMap.end()) {
|
||||
MachineInstr *Def = RegInfo->getVRegDef(LDI->second);
|
||||
MachineBasicBlock::iterator InsertPos = Def;
|
||||
const MDNode *Variable =
|
||||
MI->getOperand(MI->getNumOperands()-1).getMetadata();
|
||||
unsigned Offset = MI->getOperand(1).getImm();
|
||||
// Def is never a terminator here, so it is ok to increment InsertPos.
|
||||
BuildMI(*EntryMBB, ++InsertPos, MI->getDebugLoc(),
|
||||
TII.get(TargetOpcode::DBG_VALUE))
|
||||
.addReg(LDI->second, RegState::Debug)
|
||||
.addImm(Offset).addMetadata(Variable);
|
||||
}
|
||||
}
|
||||
|
||||
// Determine if there are any calls in this machine function.
|
||||
|
66
test/CodeGen/X86/2010-05-26-DotDebugLoc.ll
Normal file
66
test/CodeGen/X86/2010-05-26-DotDebugLoc.ll
Normal file
@ -0,0 +1,66 @@
|
||||
; RUN: llc -O2 < %s | FileCheck %s
|
||||
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
|
||||
target triple = "x86_64-apple-darwin"
|
||||
|
||||
%struct.a = type { i32, %struct.a* }
|
||||
|
||||
@llvm.used = appending global [1 x i8*] [i8* bitcast (i8* (%struct.a*)* @bar to i8*)], section "llvm.metadata" ; <[1 x i8*]*> [#uses=0]
|
||||
|
||||
define i8* @bar(%struct.a* %myvar) nounwind optsize noinline ssp {
|
||||
entry:
|
||||
tail call void @llvm.dbg.value(metadata !{%struct.a* %myvar}, i64 0, metadata !8)
|
||||
%0 = getelementptr inbounds %struct.a* %myvar, i64 0, i32 0, !dbg !28 ; <i32*> [#uses=1]
|
||||
%1 = load i32* %0, align 8, !dbg !28 ; <i32> [#uses=1]
|
||||
tail call void @foo(i32 %1) nounwind optsize noinline ssp, !dbg !28
|
||||
%2 = bitcast %struct.a* %myvar to i8*, !dbg !30 ; <i8*> [#uses=1]
|
||||
ret i8* %2, !dbg !30
|
||||
}
|
||||
|
||||
declare void @foo(i32) nounwind optsize noinline ssp
|
||||
|
||||
declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
|
||||
|
||||
!llvm.dbg.gv = !{!0}
|
||||
!llvm.dbg.lv = !{!4, !8, !18, !25, !26}
|
||||
|
||||
!0 = metadata !{i32 524340, i32 0, metadata !1, metadata !"ret", metadata !"ret", metadata !"", metadata !1, i32 7, metadata !3, i1 false, i1 true, null} ; [ DW_TAG_variable ]
|
||||
!1 = metadata !{i32 524329, metadata !"foo.c", metadata !"/tmp/", metadata !2} ; [ DW_TAG_file_type ]
|
||||
!2 = metadata !{i32 524305, i32 0, i32 1, metadata !"foo.c", metadata !"/tmp/", metadata !"4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", i1 true, i1 true, metadata !"", i32 0} ; [ DW_TAG_compile_unit ]
|
||||
!3 = metadata !{i32 524324, metadata !1, metadata !"int", metadata !1, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ]
|
||||
!4 = metadata !{i32 524545, metadata !5, metadata !"x", metadata !1, i32 12, metadata !3} ; [ DW_TAG_arg_variable ]
|
||||
!5 = metadata !{i32 524334, i32 0, metadata !1, metadata !"foo", metadata !"foo", metadata !"foo", metadata !1, i32 13, metadata !6, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 true} ; [ DW_TAG_subprogram ]
|
||||
!6 = metadata !{i32 524309, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !7, i32 0, null} ; [ DW_TAG_subroutine_type ]
|
||||
!7 = metadata !{null, metadata !3}
|
||||
!8 = metadata !{i32 524545, metadata !9, metadata !"myvar", metadata !1, i32 17, metadata !13} ; [ DW_TAG_arg_variable ]
|
||||
!9 = metadata !{i32 524334, i32 0, metadata !1, metadata !"bar", metadata !"bar", metadata !"bar", metadata !1, i32 17, metadata !10, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 true} ; [ DW_TAG_subprogram ]
|
||||
!10 = metadata !{i32 524309, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !11, i32 0, null} ; [ DW_TAG_subroutine_type ]
|
||||
!11 = metadata !{metadata !12, metadata !13}
|
||||
!12 = metadata !{i32 524303, metadata !1, metadata !"", metadata !1, i32 0, i64 64, i64 64, i64 0, i32 0, null} ; [ DW_TAG_pointer_type ]
|
||||
!13 = metadata !{i32 524303, metadata !1, metadata !"", metadata !1, i32 0, i64 64, i64 64, i64 0, i32 0, metadata !14} ; [ DW_TAG_pointer_type ]
|
||||
!14 = metadata !{i32 524307, metadata !1, metadata !"a", metadata !1, i32 2, i64 128, i64 64, i64 0, i32 0, null, metadata !15, i32 0, null} ; [ DW_TAG_structure_type ]
|
||||
!15 = metadata !{metadata !16, metadata !17}
|
||||
!16 = metadata !{i32 524301, metadata !14, metadata !"c", metadata !1, i32 3, i64 32, i64 32, i64 0, i32 0, metadata !3} ; [ DW_TAG_member ]
|
||||
!17 = metadata !{i32 524301, metadata !14, metadata !"d", metadata !1, i32 4, i64 64, i64 64, i64 64, i32 0, metadata !13} ; [ DW_TAG_member ]
|
||||
!18 = metadata !{i32 524545, metadata !19, metadata !"argc", metadata !1, i32 22, metadata !3} ; [ DW_TAG_arg_variable ]
|
||||
!19 = metadata !{i32 524334, i32 0, metadata !1, metadata !"main", metadata !"main", metadata !"main", metadata !1, i32 22, metadata !20, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 true} ; [ DW_TAG_subprogram ]
|
||||
!20 = metadata !{i32 524309, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !21, i32 0, null} ; [ DW_TAG_subroutine_type ]
|
||||
!21 = metadata !{metadata !3, metadata !3, metadata !22}
|
||||
!22 = metadata !{i32 524303, metadata !1, metadata !"", metadata !1, i32 0, i64 64, i64 64, i64 0, i32 0, metadata !23} ; [ DW_TAG_pointer_type ]
|
||||
!23 = metadata !{i32 524303, metadata !1, metadata !"", metadata !1, i32 0, i64 64, i64 64, i64 0, i32 0, metadata !24} ; [ DW_TAG_pointer_type ]
|
||||
!24 = metadata !{i32 524324, metadata !1, metadata !"char", metadata !1, i32 0, i64 8, i64 8, i64 0, i32 0, i32 6} ; [ DW_TAG_base_type ]
|
||||
!25 = metadata !{i32 524545, metadata !19, metadata !"argv", metadata !1, i32 22, metadata !22} ; [ DW_TAG_arg_variable ]
|
||||
!26 = metadata !{i32 524544, metadata !27, metadata !"e", metadata !1, i32 23, metadata !14} ; [ DW_TAG_auto_variable ]
|
||||
!27 = metadata !{i32 524299, metadata !19, i32 22, i32 0} ; [ DW_TAG_lexical_block ]
|
||||
!28 = metadata !{i32 18, i32 0, metadata !29, null}
|
||||
!29 = metadata !{i32 524299, metadata !9, i32 17, i32 0} ; [ DW_TAG_lexical_block ]
|
||||
!30 = metadata !{i32 19, i32 0, metadata !29, null}
|
||||
|
||||
; CHECK: Ldebug_loc1
|
||||
; CHECK-NEXT: .quad Lfunc_begin0
|
||||
; CHECK-NEXT: .quad Ltmp3
|
||||
; CHECK-NEXT: .short 1
|
||||
; CHECK-NEXT: .byte 85
|
||||
; CHECK-NEXT: .quad Ltmp3
|
||||
; CHECK-NEXT: .quad Lfunc_end
|
||||
; CHECK-NEXT: .short 1
|
||||
; CHECK-NEXT: .byte 83
|
Loading…
Reference in New Issue
Block a user