diff options
author | Sam Parker <sam.parker@arm.com> | 2019-12-10 13:21:12 +0000 |
---|---|---|
committer | Sam Parker <sam.parker@arm.com> | 2019-12-10 13:23:00 +0000 |
commit | 933de40729128be04f1dc24ce12be128ad2eb70c (patch) | |
tree | fdbea9a1dbc91285d276d4d9f7877af883fdb39f | |
parent | f482708149138088f74f6b01668208a8c037563c (diff) | |
download | llvm-933de40729128be04f1dc24ce12be128ad2eb70c.zip llvm-933de40729128be04f1dc24ce12be128ad2eb70c.tar.gz llvm-933de40729128be04f1dc24ce12be128ad2eb70c.tar.bz2 |
[TypePromotion] Query target register width
TargetLoweringInfo may report that an integer should be promoted, but
it maybe provide a size that isn't natively supported by the target
register file... So check this before trying to perform a promotion.
This is to fix some chromium issues:
https://bugs.chromium.org/p/chromium/issues/detail?id=1031978
https://bugs.chromium.org/p/chromium/issues/detail?id=1031979
Differential Revision: https://reviews.llvm.org/D71200
-rw-r--r-- | llvm/lib/CodeGen/TypePromotion.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/TypePromotion.cpp b/llvm/lib/CodeGen/TypePromotion.cpp index 94fe7d2..d78589c 100644 --- a/llvm/lib/CodeGen/TypePromotion.cpp +++ b/llvm/lib/CodeGen/TypePromotion.cpp @@ -17,6 +17,7 @@ #include "llvm/ADT/SetVector.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Analysis/TargetTransformInfo.h" #include "llvm/CodeGen/Passes.h" #include "llvm/CodeGen/TargetLowering.h" #include "llvm/CodeGen/TargetPassConfig.h" @@ -158,6 +159,7 @@ public: TypePromotion() : FunctionPass(ID) {} void getAnalysisUsage(AnalysisUsage &AU) const override { + AU.addRequired<TargetTransformInfoWrapperPass>(); AU.addRequired<TargetPassConfig>(); } @@ -681,8 +683,9 @@ void IRPromoter::Mutate(Type *OrigTy, unsigned PromotedWidth, SmallPtrSetImpl<Instruction*> &Sinks, SmallPtrSetImpl<Instruction*> &SafeToPromote, SmallPtrSetImpl<Instruction*> &SafeWrap) { - LLVM_DEBUG(dbgs() << "IR Promotion: Promoting use-def chains to from " - << TypePromotion::TypeSize << " to 32-bits\n"); + LLVM_DEBUG(dbgs() << "IR Promotion: Promoting use-def chains from " + << TypePromotion::TypeSize << " to " << PromotedWidth + << "-bits\n"); assert(isa<IntegerType>(OrigTy) && "expected integer type"); this->OrigTy = cast<IntegerType>(OrigTy); @@ -936,6 +939,8 @@ bool TypePromotion::runOnFunction(Function &F) { const TargetMachine &TM = TPC->getTM<TargetMachine>(); const TargetSubtargetInfo *SubtargetInfo = TM.getSubtargetImpl(F); const TargetLowering *TLI = SubtargetInfo->getTargetLowering(); + const TargetTransformInfo &TII = + getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F); // Search up from icmps to try to promote their operands. for (BasicBlock &BB : F) { @@ -966,6 +971,12 @@ bool TypePromotion::runOnFunction(Function &F) { break; EVT PromotedVT = TLI->getTypeToTransformTo(ICmp->getContext(), SrcVT); + if (TII.getRegisterBitWidth(false) < PromotedVT.getSizeInBits()) { + LLVM_DEBUG(dbgs() << "IR Promotion: Couldn't find target register " + << "for promoted type\n"); + break; + } + MadeChange |= TryToPromote(I, PromotedVT.getSizeInBits()); break; } |