From d88d8c5b8607bff56d0ccd6a500157487c5819e7 Mon Sep 17 00:00:00 2001 From: Jinsong Ji Date: Mon, 19 Apr 2021 18:57:18 +0000 Subject: [PATCH] [PowerPC] Disable relative lookup table converter pass for AIX XCOFF hasn't implemented lowerRelativeReference. So we need to disable new pass introduced by https://reviews.llvm.org/D94355 for AIX for now. Reviewed By: gulfem Differential Revision: https://reviews.llvm.org/D100584 --- llvm/include/llvm/CodeGen/BasicTTIImpl.h | 2 +- llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp | 8 ++++++++ llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h b/llvm/include/llvm/CodeGen/BasicTTIImpl.h index d28e36da17cf..adf1fb83ead0 100644 --- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h +++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h @@ -380,7 +380,7 @@ public: 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.cpp b/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp index 70552e97836a..0b43452b6454 100644 --- a/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp +++ b/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp @@ -1260,6 +1260,14 @@ bool PPCTTIImpl::isNumRegsMajorCostOfLSR() { 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()) { diff --git a/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h b/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h index 300debe6ec35..1794ab880d12 100644 --- a/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h +++ b/llvm/lib/Target/PowerPC/PPCTargetTransformInfo.h @@ -76,7 +76,7 @@ public: bool isLSRCostLess(TargetTransformInfo::LSRCost &C1, TargetTransformInfo::LSRCost &C2); bool isNumRegsMajorCostOfLSR(); - + bool shouldBuildRelLookupTables() const; /// @} /// \name Vector TTI Implementations