diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/ppc64.h b/llvm/include/llvm/ExecutionEngine/JITLink/ppc64.h --- a/llvm/include/llvm/ExecutionEngine/JITLink/ppc64.h +++ b/llvm/include/llvm/ExecutionEngine/JITLink/ppc64.h @@ -175,13 +175,13 @@ bool visitEdge(LinkGraph &G, Block *B, Edge &E) { Edge::Kind K = E.getKind(); - if (K == ppc64::RequestPLTCallStubSaveTOC && E.getTarget().isExternal()) { + if (K == ppc64::RequestPLTCallStubSaveTOC) { E.setKind(ppc64::CallBranchDeltaRestoreTOC); this->StubKind = LongBranchSaveR2; E.setTarget(this->getEntryForTarget(G, E.getTarget())); return true; } - if (K == ppc64::RequestPLTCallStubNoTOC && E.getTarget().isExternal()) { + if (K == ppc64::RequestPLTCallStubNoTOC) { E.setKind(ppc64::CallBranchDelta); this->StubKind = LongBranchNoTOC; E.setTarget(this->getEntryForTarget(G, E.getTarget())); diff --git a/llvm/lib/ExecutionEngine/JITLink/ELF_ppc64.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_ppc64.cpp --- a/llvm/lib/ExecutionEngine/JITLink/ELF_ppc64.cpp +++ b/llvm/lib/ExecutionEngine/JITLink/ELF_ppc64.cpp @@ -218,8 +218,9 @@ break; case ELF::R_PPC64_REL24_NOTOC: case ELF::R_PPC64_REL24: { - bool isLocal = !GraphSymbol->isExternal(); - if (isLocal) { + bool isExternal = + (*ObjSymbol)->isUndefined() && (*ObjSymbol)->isExternal(); + if (!isExternal) { // TODO: There are cases a local function call need a call stub. // 1. Caller uses TOC, the callee doesn't, need a r2 save stub. // 2. Caller doesn't use TOC, the callee does, need a r12 setup stub.