From 4d1e9bf7171ae9e9ef8bb74a3f11d17d298063ef Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 9 Jul 2009 02:46:53 +0000 Subject: hoist check for IsTailCall to callers. Eliminate redundant check for x86-64: GOT-style PIC is never used on x86-64. llvm-svn: 75090 --- llvm/lib/Target/X86/X86ISelLowering.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'llvm/lib') diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index a024d102001..3889e61acf6 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -1321,22 +1321,18 @@ X86TargetLowering::NameDecorationForFORMAL_ARGUMENTS(SDValue Op) { /// 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(); - 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(); - return !Subtarget.is64Bit() && IsTailCall && - TM.getRelocationModel() == Reloc::PIC_ && + return TM.getRelocationModel() == Reloc::PIC_ && Subtarget.isPICStyleGOT(); } @@ -1808,7 +1804,7 @@ SDValue X86TargetLowering::LowerCALL(SDValue Op, SelectionDAG &DAG) { // 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 @@ SDValue X86TargetLowering::LowerCALL(SDValue Op, SelectionDAG &DAG) { // calls on PIC/GOT architectures. Normally we would just put the address of // GOT into ebx and then call target@PLT. But for tail calls ebx would be // restored (since ebx is callee saved) before jumping to the target@PLT. - if (CallRequiresFnAddressInReg(getTargetMachine(), IsTailCall)) { + if (IsTailCall && CallRequiresFnAddressInReg(getTargetMachine())) { // Note: The actual moving to ecx is done further down. GlobalAddressSDNode *G = dyn_cast(Callee); if (G && !G->getGlobal()->hasHiddenVisibility() && -- cgit v1.2.3