[llvm-branch-commits] [llvm-branch] r104568 - in /llvm/branches/Apple/Morbo: include/llvm/CodeGen/MachineRegisterInfo.h lib/CodeGen/MachineFunction.cpp lib/CodeGen/MachineRegisterInfo.cpp
Evan Cheng
evan.cheng at apple.com
Mon May 24 15:08:12 PDT 2010
Author: evancheng
Date: Mon May 24 17:08:12 2010
New Revision: 104568
URL: http://llvm.org/viewvc/llvm-project?rev=104568&view=rev
Log:
Merge 104560.
Modified:
llvm/branches/Apple/Morbo/include/llvm/CodeGen/MachineRegisterInfo.h
llvm/branches/Apple/Morbo/lib/CodeGen/MachineFunction.cpp
llvm/branches/Apple/Morbo/lib/CodeGen/MachineRegisterInfo.cpp
Modified: llvm/branches/Apple/Morbo/include/llvm/CodeGen/MachineRegisterInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/include/llvm/CodeGen/MachineRegisterInfo.h?rev=104568&r1=104567&r2=104568&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/include/llvm/CodeGen/MachineRegisterInfo.h (original)
+++ llvm/branches/Apple/Morbo/include/llvm/CodeGen/MachineRegisterInfo.h Mon May 24 17:08:12 2010
@@ -275,6 +275,10 @@
/// corresponding live-in physical register.
unsigned getLiveInPhysReg(unsigned VReg) const;
+ /// getLiveInVirtReg - If PReg is a live-in physical register, return the
+ /// corresponding live-in physical register.
+ unsigned getLiveInVirtReg(unsigned PReg) const;
+
private:
void HandleVRegListReallocation();
Modified: llvm/branches/Apple/Morbo/lib/CodeGen/MachineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/CodeGen/MachineFunction.cpp?rev=104568&r1=104567&r2=104568&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/lib/CodeGen/MachineFunction.cpp (original)
+++ llvm/branches/Apple/Morbo/lib/CodeGen/MachineFunction.cpp Mon May 24 17:08:12 2010
@@ -431,8 +431,14 @@
unsigned MachineFunction::addLiveIn(unsigned PReg,
const TargetRegisterClass *RC) {
assert(RC->contains(PReg) && "Not the correct regclass!");
- unsigned VReg = getRegInfo().createVirtualRegister(RC);
- getRegInfo().addLiveIn(PReg, VReg);
+ MachineRegisterInfo &MRI = getRegInfo();
+ unsigned VReg = MRI.getLiveInVirtReg(PReg);
+ if (VReg) {
+ assert(MRI.getRegClass(VReg) == RC && "Register class mismatch!");
+ return VReg;
+ }
+ VReg = MRI.createVirtualRegister(RC);
+ MRI.addLiveIn(PReg, VReg);
return VReg;
}
Modified: llvm/branches/Apple/Morbo/lib/CodeGen/MachineRegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/CodeGen/MachineRegisterInfo.cpp?rev=104568&r1=104567&r2=104568&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/lib/CodeGen/MachineRegisterInfo.cpp (original)
+++ llvm/branches/Apple/Morbo/lib/CodeGen/MachineRegisterInfo.cpp Mon May 24 17:08:12 2010
@@ -145,3 +145,12 @@
return I->first;
return 0;
}
+
+/// getLiveInVirtReg - If PReg is a live-in physical register, return the
+/// corresponding live-in physical register.
+unsigned MachineRegisterInfo::getLiveInVirtReg(unsigned PReg) const {
+ for (livein_iterator I = livein_begin(), E = livein_end(); I != E; ++I)
+ if (I->first == PReg)
+ return I->second;
+ return 0;
+}
More information about the llvm-branch-commits
mailing list