[llvm-commits] CVS: llvm/lib/CodeGen/LiveVariables.cpp

Chris Lattner lattner at cs.uiuc.edu
Sat Apr 9 08:23:41 PDT 2005



Changes in directory llvm/lib/CodeGen:

LiveVariables.cpp updated: 1.47 -> 1.48
---
Log message:

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.


---
Diffs of the changes:  (+20 -0)

 LiveVariables.cpp |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+)


Index: llvm/lib/CodeGen/LiveVariables.cpp
diff -u llvm/lib/CodeGen/LiveVariables.cpp:1.47 llvm/lib/CodeGen/LiveVariables.cpp:1.48
--- llvm/lib/CodeGen/LiveVariables.cpp:1.47	Wed Jan 19 11:11:51 2005
+++ llvm/lib/CodeGen/LiveVariables.cpp	Sat Apr  9 10:23:25 2005
@@ -163,6 +163,14 @@
 
   /// 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 @@
       }
     }
     
+    // 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)






More information about the llvm-commits mailing list