diff options
| author | Roman Divacky <rdivacky@freebsd.org> | 2012-09-18 16:47:58 +0000 |
|---|---|---|
| committer | Roman Divacky <rdivacky@freebsd.org> | 2012-09-18 16:47:58 +0000 |
| commit | 762930637c007b8f0473020b9e3c90f71e4d6e83 (patch) | |
| tree | b757683aa20482bd96ecf238a4a99a778ab9f4cc /llvm/lib/Target | |
| parent | be42c1e0aa1c42fb8956b737013f53899cf3e50a (diff) | |
| download | bcm5719-llvm-762930637c007b8f0473020b9e3c90f71e4d6e83.tar.gz bcm5719-llvm-762930637c007b8f0473020b9e3c90f71e4d6e83.zip | |
Optimize local func calls to not emit nop for TOC restoration.
Patch by Adhemerval Zanella.
llvm-svn: 164138
Diffstat (limited to 'llvm/lib/Target')
| -rw-r--r-- | llvm/lib/Target/PowerPC/PPCISelLowering.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp index f1a673c3cc0..6b93d945f8d 100644 --- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp @@ -2808,6 +2808,14 @@ unsigned PrepareCall(SelectionDAG &DAG, SDValue &Callee, SDValue &InFlag, return CallOpc; } +static +bool isLocalCall(const SDValue &Callee) +{ + if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee)) + return !G->getGlobal()->isDeclaration(); + return false; +} + SDValue PPCTargetLowering::LowerCallResult(SDValue Chain, SDValue InFlag, CallingConv::ID CallConv, bool isVarArg, @@ -2916,8 +2924,8 @@ PPCTargetLowering::FinishCall(CallingConv::ID CallConv, DebugLoc dl, // from allocating it), resulting in an additional register being // allocated and an unnecessary move instruction being generated. needsTOCRestore = true; - } else if (CallOpc == PPCISD::CALL_SVR4) { - // Otherwise insert NOP. + } else if ((CallOpc == PPCISD::CALL_SVR4) && !isLocalCall(Callee)) { + // Otherwise insert NOP for non-local calls. CallOpc = PPCISD::CALL_NOP_SVR4; } } |

