[llvm-commits] [llvm] r75090 - /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp

Chris Lattner sabre at nondot.org
Wed Jul 8 19:46:53 PDT 2009


Author: lattner
Date: Wed Jul  8 21:46:53 2009
New Revision: 75090

URL: http://llvm.org/viewvc/llvm-project?rev=75090&view=rev
Log:
hoist check for IsTailCall to callers.  Eliminate redundant check for 
x86-64: GOT-style PIC is never used on x86-64.

Modified:
    llvm/trunk/lib/Target/X86/X86ISelLowering.cpp

Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=75090&r1=75089&r2=75090&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Jul  8 21:46:53 2009
@@ -1321,22 +1321,18 @@
 
 /// CallRequiresGOTInRegister - Check whether the call requires the GOT pointer
 /// in a register before calling.
-static bool CallRequiresGOTPtrInReg(const TargetMachine &TM, 
-                                    bool IsTailCall) {
+static bool CallRequiresGOTPtrInReg(const TargetMachine &TM) {
   const X86Subtarget &Subtarget = TM.getSubtarget<X86Subtarget>();
 
-  return !IsTailCall && !Subtarget.is64Bit() &&
-         TM.getRelocationModel() == Reloc::PIC_ &&
+  return TM.getRelocationModel() == Reloc::PIC_ &&
          Subtarget.isPICStyleGOT();
 }
 
 /// CallRequiresFnAddressInReg - Check whether the call requires the function
 /// address to be loaded in a register.
-static bool CallRequiresFnAddressInReg(const TargetMachine &TM, 
-                                       bool IsTailCall) {
+static bool CallRequiresFnAddressInReg(const TargetMachine &TM) {
   const X86Subtarget &Subtarget = TM.getSubtarget<X86Subtarget>();
-  return !Subtarget.is64Bit() && IsTailCall &&
-         TM.getRelocationModel() == Reloc::PIC_ &&
+  return TM.getRelocationModel() == Reloc::PIC_ &&
          Subtarget.isPICStyleGOT();
 }
 
@@ -1808,7 +1804,7 @@
 
   // ELF / PIC requires GOT in the EBX register before function calls via PLT
   // GOT pointer.
-  if (CallRequiresGOTPtrInReg(getTargetMachine(), IsTailCall)) {
+  if (!IsTailCall && CallRequiresGOTPtrInReg(getTargetMachine())) {
     Chain = DAG.getCopyToReg(Chain, dl, X86::EBX,
                              DAG.getNode(X86ISD::GlobalBaseReg,
                                          DebugLoc::getUnknownLoc(),
@@ -1823,7 +1819,7 @@
   // calls on PIC/GOT architectures. Normally we would just put the address of
   // GOT into ebx and then call target at PLT. But for tail calls ebx would be
   // restored (since ebx is callee saved) before jumping to the target at PLT.
-  if (CallRequiresFnAddressInReg(getTargetMachine(), IsTailCall)) {
+  if (IsTailCall && CallRequiresFnAddressInReg(getTargetMachine())) {
     // Note: The actual moving to ecx is done further down.
     GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee);
     if (G && !G->getGlobal()->hasHiddenVisibility() &&





More information about the llvm-commits mailing list