diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2016-06-23 18:43:06 +0000 | 
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2016-06-23 18:43:06 +0000 | 
| commit | 53fd425e0660d3778f9005d3591689aad5e4940e (patch) | |
| tree | 3ec752ad622e172db07c82a275aab6ae5d590cef /llvm | |
| parent | a21a263101cca2908a2ff3220457462c1e951b4b (diff) | |
| download | bcm5719-llvm-53fd425e0660d3778f9005d3591689aad5e4940e.tar.gz bcm5719-llvm-53fd425e0660d3778f9005d3591689aad5e4940e.zip  | |
Refactor duplicated code. NFC.
llvm-svn: 273595
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Target/PowerPC/PPCISelLowering.cpp | 37 | 
1 files changed, 17 insertions, 20 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp index 1df07071f8e..d7dc35cf6eb 100644 --- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp @@ -4280,23 +4280,28 @@ PrepareCall(SelectionDAG &DAG, SDValue &Callee, SDValue &InFlag, SDValue &Chain,        needIndirectCall = false;      } +  // PC-relative references to external symbols should go through $stub, unless +  // we're building with the leopard linker or later, which automatically +  // synthesizes these stubs. +  Reloc::Model RM = DAG.getTarget().getRelocationModel(); +  const Triple &TargetTriple = Subtarget.getTargetTriple(); +  bool OldMachOLinker = +      TargetTriple.isMacOSX() && TargetTriple.isMacOSXVersionLT(10, 5); +  const Module *Mod = DAG.getMachineFunction().getFunction()->getParent(); +  const GlobalValue *GV = nullptr; +  if (auto *G = dyn_cast<GlobalAddressSDNode>(Callee)) +    GV = G->getGlobal(); +  bool Local = shouldAssumeDSOLocal(RM, TargetTriple, *Mod, GV); +  bool UsePlt = +      !Local && (OldMachOLinker || (Subtarget.isTargetELF() && !isPPC64)); +    if (isFunctionGlobalAddress(Callee)) {      GlobalAddressSDNode *G = cast<GlobalAddressSDNode>(Callee);      // A call to a TLS address is actually an indirect call to a      // thread-specific pointer.      unsigned OpFlags = 0; -    Reloc::Model RM = DAG.getTarget().getRelocationModel(); -    const Triple &TargetTriple = Subtarget.getTargetTriple(); -    const GlobalValue *GV = G->getGlobal(); -    bool OldMachOLinker = -        TargetTriple.isMacOSX() && TargetTriple.isMacOSXVersionLT(10, 5); -    if (!shouldAssumeDSOLocal(RM, TargetTriple, *GV->getParent(), GV) && -        (OldMachOLinker || (Subtarget.isTargetELF() && !isPPC64))) { -      // PC-relative references to external symbols should go through $stub, -      // unless we're building with the leopard linker or later, which -      // automatically synthesizes these stubs. +    if (UsePlt)        OpFlags = PPCII::MO_PLT_OR_STUB; -    }      // If the callee is a GlobalAddress/ExternalSymbol node (quite common,      // every direct call is) turn it into a TargetGlobalAddress / @@ -4309,16 +4314,8 @@ PrepareCall(SelectionDAG &DAG, SDValue &Callee, SDValue &InFlag, SDValue &Chain,    if (ExternalSymbolSDNode *S = dyn_cast<ExternalSymbolSDNode>(Callee)) {      unsigned char OpFlags = 0; -    if ((DAG.getTarget().getRelocationModel() != Reloc::Static && -         (Subtarget.getTargetTriple().isMacOSX() && -          Subtarget.getTargetTriple().isMacOSXVersionLT(10, 5))) || -        (Subtarget.isTargetELF() && !isPPC64 && -         DAG.getTarget().getRelocationModel() == Reloc::PIC_)) { -      // PC-relative references to external symbols should go through $stub, -      // unless we're building with the leopard linker or later, which -      // automatically synthesizes these stubs. +    if (UsePlt)        OpFlags = PPCII::MO_PLT_OR_STUB; -    }      Callee = DAG.getTargetExternalSymbol(S->getSymbol(), Callee.getValueType(),                                           OpFlags);  | 

