summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachineRegisterInfo.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2010-04-28 23:08:54 +0000
committerEvan Cheng <evan.cheng@apple.com>2010-04-28 23:08:54 +0000
commit6e822459ede4600dd43b859512a2223320132500 (patch)
treea3ad6dc0a5708bb698e80e4faefd1d7d9996e734 /llvm/lib/CodeGen/MachineRegisterInfo.cpp
parentc46382e4b39919ac89377a9134e1e73a2069f90f (diff)
downloadbcm5719-llvm-6e822459ede4600dd43b859512a2223320132500.tar.gz
bcm5719-llvm-6e822459ede4600dd43b859512a2223320132500.zip
Replace r102368 with code that's less fragile. This creates DBG_VALUE instructions for function arguments early and insert them after instruction selection is done.
llvm-svn: 102554
Diffstat (limited to 'llvm/lib/CodeGen/MachineRegisterInfo.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineRegisterInfo.cpp37
1 files changed, 9 insertions, 28 deletions
diff --git a/llvm/lib/CodeGen/MachineRegisterInfo.cpp b/llvm/lib/CodeGen/MachineRegisterInfo.cpp
index 724d81cdba8..ea5ca0cad8a 100644
--- a/llvm/lib/CodeGen/MachineRegisterInfo.cpp
+++ b/llvm/lib/CodeGen/MachineRegisterInfo.cpp
@@ -147,6 +147,15 @@ bool MachineRegisterInfo::isLiveOut(unsigned Reg) const {
return false;
}
+/// getLiveInPhysReg - If VReg is a live-in virtual register, return the
+/// corresponding live-in physical register.
+unsigned MachineRegisterInfo::getLiveInPhysReg(unsigned VReg) const {
+ for (livein_iterator I = livein_begin(), E = livein_end(); I != E; ++I)
+ if (I->second == VReg)
+ return I->first;
+ return 0;
+}
+
static cl::opt<bool>
SchedLiveInCopies("schedule-livein-copies", cl::Hidden,
cl::desc("Schedule copies of livein registers"),
@@ -220,30 +229,6 @@ static void EmitLiveInCopy(MachineBasicBlock *MBB,
}
}
-/// InsertLiveInDbgValue - Insert a DBG_VALUE instruction for each live-in
-/// register that has a corresponding source information metadata. e.g.
-/// function parameters.
-static void InsertLiveInDbgValue(MachineBasicBlock *MBB,
- MachineBasicBlock::iterator InsertPos,
- unsigned LiveInReg, unsigned VirtReg,
- const MachineRegisterInfo &MRI,
- const TargetInstrInfo &TII) {
- for (MachineRegisterInfo::use_iterator UI = MRI.use_begin(VirtReg),
- UE = MRI.use_end(); UI != UE; ++UI) {
- MachineInstr *UseMI = &*UI;
- if (!UseMI->isDebugValue() || UseMI->getParent() != MBB)
- continue;
- // Found local dbg_value. FIXME: Verify it's not possible to have multiple
- // dbg_value's which reference the vr in the same mbb.
- uint64_t Offset = UseMI->getOperand(1).getImm();
- const MDNode *MDPtr = UseMI->getOperand(2).getMetadata();
- BuildMI(*MBB, InsertPos, InsertPos->getDebugLoc(),
- TII.get(TargetOpcode::DBG_VALUE))
- .addReg(LiveInReg).addImm(Offset).addMetadata(MDPtr);
- return;
- }
-}
-
/// EmitLiveInCopies - Emit copies to initialize livein virtual registers
/// into the given entry block.
void
@@ -260,8 +245,6 @@ MachineRegisterInfo::EmitLiveInCopies(MachineBasicBlock *EntryMBB,
const TargetRegisterClass *RC = getRegClass(LI->second);
EmitLiveInCopy(EntryMBB, InsertPos, LI->second, LI->first,
RC, CopyRegMap, *this, TRI, TII);
- InsertLiveInDbgValue(EntryMBB, InsertPos,
- LI->first, LI->second, *this, TII);
}
} else {
// Emit the copies into the top of the block.
@@ -273,8 +256,6 @@ MachineRegisterInfo::EmitLiveInCopies(MachineBasicBlock *EntryMBB,
LI->second, LI->first, RC, RC);
assert(Emitted && "Unable to issue a live-in copy instruction!\n");
(void) Emitted;
- InsertLiveInDbgValue(EntryMBB, EntryMBB->begin(),
- LI->first, LI->second, *this, TII);
}
}
OpenPOWER on IntegriCloud