summaryrefslogtreecommitdiff
path: root/lib/CodeGen/MachineRegisterInfo.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2010-04-26 19:16:00 +0000
committerEvan Cheng <evan.cheng@apple.com>2010-04-26 19:16:00 +0000
commitf48023b3cf80f3a360cfef94b1e0d0084fd5d760 (patch)
treebb19f23aa92529912fa0c1468406af43937f16a2 /lib/CodeGen/MachineRegisterInfo.cpp
parent552f09a0d716a73dc70efd66384146e73ee63a3e (diff)
downloadllvm-f48023b3cf80f3a360cfef94b1e0d0084fd5d760.tar.gz
llvm-f48023b3cf80f3a360cfef94b1e0d0084fd5d760.tar.bz2
llvm-f48023b3cf80f3a360cfef94b1e0d0084fd5d760.tar.xz
Insert dbg_value instructions for function entry block liveins (i.e. function arguments).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102368 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineRegisterInfo.cpp')
-rw-r--r--lib/CodeGen/MachineRegisterInfo.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/lib/CodeGen/MachineRegisterInfo.cpp b/lib/CodeGen/MachineRegisterInfo.cpp
index 850ade25da..724d81cdba 100644
--- a/lib/CodeGen/MachineRegisterInfo.cpp
+++ b/lib/CodeGen/MachineRegisterInfo.cpp
@@ -12,8 +12,9 @@
//===----------------------------------------------------------------------===//
#include "llvm/CodeGen/MachineRegisterInfo.h"
-#include "llvm/Support/CommandLine.h"
+#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/Target/TargetInstrInfo.h"
+#include "llvm/Support/CommandLine.h"
using namespace llvm;
MachineRegisterInfo::MachineRegisterInfo(const TargetRegisterInfo &TRI) {
@@ -219,6 +220,30 @@ 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
@@ -235,6 +260,8 @@ 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.
@@ -246,6 +273,8 @@ 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);
}
}