summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-04-09 15:23:25 +0000
committerChris Lattner <sabre@nondot.org>2005-04-09 15:23:25 +0000
commit4c6ab01a20b0345caf2b99639c196a06a1249df8 (patch)
tree37b6bff29ecc168e87793a9efb51262b43312c1e /llvm/lib/CodeGen
parent576db37185de6ea0a3dc60d5704e9e869bc9cf20 (diff)
downloadbcm5719-llvm-4c6ab01a20b0345caf2b99639c196a06a1249df8.tar.gz
bcm5719-llvm-4c6ab01a20b0345caf2b99639c196a06a1249df8.zip
Consider the livein/out set for a function, allowing targets to not have to
use ugly imp_def/imp_uses for arguments and return values. llvm-svn: 21180
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/LiveVariables.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/LiveVariables.cpp b/llvm/lib/CodeGen/LiveVariables.cpp
index 80316102601..175b5fd7c16 100644
--- a/llvm/lib/CodeGen/LiveVariables.cpp
+++ b/llvm/lib/CodeGen/LiveVariables.cpp
@@ -163,6 +163,14 @@ bool LiveVariables::runOnMachineFunction(MachineFunction &MF) {
/// Get some space for a respectable number of registers...
VirtRegInfo.resize(64);
+
+ // Mark live-in registers as live-in.
+ for (MachineFunction::liveinout_iterator I = MF.livein_begin(),
+ E = MF.livein_end(); I != E; ++I) {
+ assert(MRegisterInfo::isPhysicalRegister(*I) &&
+ "Cannot have a live-in virtual register!");
+ HandlePhysRegDef(*I, 0);
+ }
// Calculate live variable information in depth first order on the CFG of the
// function. This guarantees that we will see the definition of a virtual
@@ -260,6 +268,18 @@ bool LiveVariables::runOnMachineFunction(MachineFunction &MF) {
}
}
+ // Finally, if the last block in the function is a return, make sure to mark
+ // it as using all of the live-out values in the function.
+ if (!MBB->empty() && TII.isReturn(MBB->back().getOpcode())) {
+ MachineInstr *Ret = &MBB->back();
+ for (MachineFunction::liveinout_iterator I = MF.liveout_begin(),
+ E = MF.liveout_end(); I != E; ++I) {
+ assert(MRegisterInfo::isPhysicalRegister(*I) &&
+ "Cannot have a live-in virtual register!");
+ HandlePhysRegUse(*I, Ret);
+ }
+ }
+
// Loop over PhysRegInfo, killing any registers that are available at the
// end of the basic block. This also resets the PhysRegInfo map.
for (unsigned i = 0, e = RegInfo->getNumRegs(); i != e; ++i)
OpenPOWER on IntegriCloud