diff --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h b/llvm/include/llvm/CodeGen/BasicTTIImpl.h --- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h +++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h @@ -380,7 +380,7 @@ TLI->isOperationLegalOrCustom(ISD::BRIND, MVT::Other); } - bool shouldBuildRelLookupTables() { + bool shouldBuildRelLookupTables() const { const TargetMachine &TM = getTLI()->getTargetMachine(); // If non-PIC mode, do not generate a relative lookup table. if (!TM.isPositionIndependent()) diff --git a/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h b/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h --- a/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h +++ b/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h @@ -76,7 +76,7 @@ bool isLSRCostLess(TargetTransformInfo::LSRCost &C1, TargetTransformInfo::LSRCost &C2); bool isNumRegsMajorCostOfLSR(); - + bool shouldBuildRelLookupTables() const; /// @} /// \name Vector TTI Implementations diff --git a/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp b/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp --- a/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp +++ b/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp @@ -1260,6 +1260,14 @@ return false; } +bool PPCTTIImpl::shouldBuildRelLookupTables() const { + const PPCTargetMachine &TM = ST->getTargetMachine(); + // XCOFF hasn't implemented lowerRelativeReference, disable non-ELF for now. + if (!TM.isELFv2ABI()) + return false; + return BaseT::shouldBuildRelLookupTables(); +} + bool PPCTTIImpl::getTgtMemIntrinsic(IntrinsicInst *Inst, MemIntrinsicInfo &Info) { switch (Inst->getIntrinsicID()) {