diff --git a/interpreter/llvm/src/lib/Target/PowerPC/PPCISelLowering.cpp b/interpreter/llvm/src/lib/Target/PowerPC/PPCISelLowering.cpp index 24d50074860d7..a922b40aa9026 100644 --- a/interpreter/llvm/src/lib/Target/PowerPC/PPCISelLowering.cpp +++ b/interpreter/llvm/src/lib/Target/PowerPC/PPCISelLowering.cpp @@ -4463,7 +4463,15 @@ callsShareTOCBase(const Function *Caller, SDValue Callee, if (!G) return false; - const GlobalValue *GV = G->getGlobal(); + const GlobalValue *GV = G->getGlobal(); + + // If the GV is not a strong definition then we need to assume it can be + // replaced by another function at link time. The function that replaces + // it may not share the same TOC as the caller since the callee may be + // replaced by a PC Relative version of the same function. + if (!GV->isStrongDefinitionForLinker()) + return false; + // The medium and large code models are expected to provide a sufficiently // large TOC to provide all data addressing needs of a module with a // single TOC. Since each module will be addressed with a single TOC then we @@ -4472,13 +4480,6 @@ callsShareTOCBase(const Function *Caller, SDValue Callee, CodeModel::Large == TM.getCodeModel()) return TM.shouldAssumeDSOLocal(*Caller->getParent(), GV); - // Otherwise we need to ensure callee and caller are in the same section, - // since the linker may allocate multiple TOCs, and we don't know which - // sections will belong to the same TOC base. - - if (!GV->isStrongDefinitionForLinker()) - return false; - // Any explicitly-specified sections and section prefixes must also match. // Also, if we're using -ffunction-sections, then each function is always in // a different section (the same is true for COMDAT functions).