diff options
author | Bill Wendling <isanbard@gmail.com> | 2013-11-22 18:01:22 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2013-11-22 18:01:22 +0000 |
commit | 0162226db8b99306d598d7b790be7cc938bb689e (patch) | |
tree | be010a2447ca5e3ccf635268ffc1c31b33aef08d /lib | |
parent | 92ee08fbc242efb0a6d8e862fc7cb5fc0cedfd8e (diff) | |
download | external_llvm-0162226db8b99306d598d7b790be7cc938bb689e.zip external_llvm-0162226db8b99306d598d7b790be7cc938bb689e.tar.gz external_llvm-0162226db8b99306d598d7b790be7cc938bb689e.tar.bz2 |
Merging r195439:
------------------------------------------------------------------------
r195439 | kcc | 2013-11-22 02:30:39 -0800 (Fri, 22 Nov 2013) | 3 lines
Revert r195318 as it causes miscompilation (PR18029)
------------------------------------------------------------------------
git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_34@195478 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Target/X86/X86ISelLowering.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 0deb181..9df0232 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -2665,15 +2665,21 @@ X86TargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI, RegsToPass.push_back(std::make_pair(unsigned(X86::EBX), DAG.getNode(X86ISD::GlobalBaseReg, SDLoc(), getPointerTy()))); } else { - // If we are tail calling a global or external symbol in GOT pic mode, we - // cannot use a direct jump, since that would make lazy dynamic linking - // impossible (see PR15086). So pretend this is not a tail call, to - // prevent the optimization to a jump. + // If we are tail calling and generating PIC/GOT style code load the + // address of the callee into ECX. The value in ecx is used as target of + // the tail jump. This is done to circumvent the ebx/callee-saved problem + // for tail 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. + + // Note: The actual moving to ECX is done further down. GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee); - if ((G && !G->getGlobal()->hasHiddenVisibility() && - !G->getGlobal()->hasProtectedVisibility()) || - isa<ExternalSymbolSDNode>(Callee)) - isTailCall = false; + if (G && !G->getGlobal()->hasHiddenVisibility() && + !G->getGlobal()->hasProtectedVisibility()) + Callee = LowerGlobalAddress(Callee, DAG); + else if (isa<ExternalSymbolSDNode>(Callee)) + Callee = LowerExternalSymbol(Callee, DAG); } } |