[llvm-commits] [llvm] r124903 - in /llvm/trunk: lib/CodeGen/RegAllocFast.cpp test/CodeGen/X86/2011-02-04-FastRegallocNoFP.ll

Nick Lewycky nicholas at mxc.ca
Fri Feb 4 14:44:08 PST 2011


Author: nicholas
Date: Fri Feb  4 16:44:08 2011
New Revision: 124903

URL: http://llvm.org/viewvc/llvm-project?rev=124903&view=rev
Log:
Mark that the return is using EAX so that we don't use it for some other
purpose. Fixes PR9080!

Added:
    llvm/trunk/test/CodeGen/X86/2011-02-04-FastRegallocNoFP.ll
Modified:
    llvm/trunk/lib/CodeGen/RegAllocFast.cpp

Modified: llvm/trunk/lib/CodeGen/RegAllocFast.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocFast.cpp?rev=124903&r1=124902&r2=124903&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegAllocFast.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegAllocFast.cpp Fri Feb  4 16:44:08 2011
@@ -735,6 +735,27 @@
 void RAFast::AllocateBasicBlock() {
   DEBUG(dbgs() << "\nAllocating " << *MBB);
 
+  // FIXME: This should probably be added by instruction selection instead?
+  // If the last instruction in the block is a return, make sure to mark it as
+  // using all of the live-out values in the function.  Things marked both call
+  // and return are tail calls; do not do this for them.  The tail callee need
+  // not take the same registers as input that it produces as output, and there
+  // are dependencies for its input registers elsewhere.
+  if (!MBB->empty() && MBB->back().getDesc().isReturn() &&
+      !MBB->back().getDesc().isCall()) {
+    MachineInstr *Ret = &MBB->back();
+
+    for (MachineRegisterInfo::liveout_iterator
+         I = MF->getRegInfo().liveout_begin(),
+         E = MF->getRegInfo().liveout_end(); I != E; ++I) {
+      assert(TargetRegisterInfo::isPhysicalRegister(*I) &&
+             "Cannot have a live-out virtual register.");
+
+      // Add live-out registers as implicit uses.
+      Ret->addRegisterKilled(*I, TRI, true);
+    }
+  }
+
   PhysRegState.assign(TRI->getNumRegs(), regDisabled);
   assert(LiveVirtRegs.empty() && "Mapping not cleared form last block?");
 

Added: llvm/trunk/test/CodeGen/X86/2011-02-04-FastRegallocNoFP.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2011-02-04-FastRegallocNoFP.ll?rev=124903&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/2011-02-04-FastRegallocNoFP.ll (added)
+++ llvm/trunk/test/CodeGen/X86/2011-02-04-FastRegallocNoFP.ll Fri Feb  4 16:44:08 2011
@@ -0,0 +1,14 @@
+; RUN: llc -O0 < %s | FileCheck %s
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare i32 @foo()
+
+define i32 @bar() nounwind {
+; CHECK: bar
+; CHECK-NOT: pop.*ax
+  %call = call i32 @foo()
+  ret i32 %call
+}
+





More information about the llvm-commits mailing list