From: Chandler Carruth Date: Sun, 1 Feb 2015 12:01:35 +0000 (+0000) Subject: [multiversion] Thread a function argument through all the callers of the X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=baceda736e85ecd0e85127710ed2f91f139e07d5;p=oota-llvm.git [multiversion] Thread a function argument through all the callers of the getTTI method used to get an actual TTI object. No functionality changed. This just threads the argument and ensures code like the inliner can correctly look up the callee's TTI rather than using a fixed one. The next change will use this to implement per-function subtarget usage by TTI. The changes after that should eliminate the need for FTTI as that will have become the default. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227730 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Analysis/InlineCost.h b/include/llvm/Analysis/InlineCost.h index a064cfc897b..63d399afad8 100644 --- a/include/llvm/Analysis/InlineCost.h +++ b/include/llvm/Analysis/InlineCost.h @@ -23,7 +23,7 @@ class AssumptionCacheTracker; class CallSite; class DataLayout; class Function; -class TargetTransformInfo; +class TargetTransformInfoWrapperPass; namespace InlineConstants { // Various magic constants used to adjust heuristics. @@ -100,7 +100,7 @@ public: /// \brief Cost analyzer used by inliner. class InlineCostAnalysis : public CallGraphSCCPass { - const TargetTransformInfo *TTI; + TargetTransformInfoWrapperPass *TTIWP; AssumptionCacheTracker *ACT; public: diff --git a/include/llvm/Analysis/TargetTransformInfo.h b/include/llvm/Analysis/TargetTransformInfo.h index 9908853bc49..affa9336e1f 100644 --- a/include/llvm/Analysis/TargetTransformInfo.h +++ b/include/llvm/Analysis/TargetTransformInfo.h @@ -806,8 +806,7 @@ public: explicit TargetTransformInfoWrapperPass(TargetTransformInfo TTI); - TargetTransformInfo &getTTI() { return TTI; } - const TargetTransformInfo &getTTI() const { return TTI; } + TargetTransformInfo &getTTI(Function &F) { return TTI; } }; /// \brief Create an analysis pass wrapper around a TTI object. diff --git a/lib/Analysis/CostModel.cpp b/lib/Analysis/CostModel.cpp index 7b5dfa2c7c8..b529c1a70aa 100644 --- a/lib/Analysis/CostModel.cpp +++ b/lib/Analysis/CostModel.cpp @@ -84,7 +84,7 @@ bool CostModelAnalysis::runOnFunction(Function &F) { this->F = &F; auto *TTIWP = getAnalysisIfAvailable(); - TTI = TTIWP ? &TTIWP->getTTI() : nullptr; + TTI = TTIWP ? &TTIWP->getTTI(F) : nullptr; return false; } diff --git a/lib/Analysis/FunctionTargetTransformInfo.cpp b/lib/Analysis/FunctionTargetTransformInfo.cpp index 36f182098b3..d1307b4ebfb 100644 --- a/lib/Analysis/FunctionTargetTransformInfo.cpp +++ b/lib/Analysis/FunctionTargetTransformInfo.cpp @@ -45,6 +45,6 @@ void FunctionTargetTransformInfo::releaseMemory() {} bool FunctionTargetTransformInfo::runOnFunction(Function &F) { Fn = &F; - TTI = &getAnalysis().getTTI(); + TTI = &getAnalysis().getTTI(F); return false; } diff --git a/lib/Analysis/IPA/InlineCost.cpp b/lib/Analysis/IPA/InlineCost.cpp index bbae2533889..166488bf67e 100644 --- a/lib/Analysis/IPA/InlineCost.cpp +++ b/lib/Analysis/IPA/InlineCost.cpp @@ -1251,7 +1251,7 @@ void InlineCostAnalysis::getAnalysisUsage(AnalysisUsage &AU) const { } bool InlineCostAnalysis::runOnSCC(CallGraphSCC &SCC) { - TTI = &getAnalysis().getTTI(); + TTIWP = &getAnalysis(); ACT = &getAnalysis(); return false; } @@ -1309,7 +1309,7 @@ InlineCost InlineCostAnalysis::getInlineCost(CallSite CS, Function *Callee, DEBUG(llvm::dbgs() << " Analyzing call of " << Callee->getName() << "...\n"); - CallAnalyzer CA(Callee->getDataLayout(), *TTI, + CallAnalyzer CA(Callee->getDataLayout(), TTIWP->getTTI(*Callee), ACT->getAssumptionCache(*Callee), *Callee, Threshold); bool ShouldInline = CA.analyzeCall(CS); diff --git a/lib/CodeGen/CodeGenPrepare.cpp b/lib/CodeGen/CodeGenPrepare.cpp index 184a6a4c0cc..7f8019dcc72 100644 --- a/lib/CodeGen/CodeGenPrepare.cpp +++ b/lib/CodeGen/CodeGenPrepare.cpp @@ -213,7 +213,7 @@ bool CodeGenPrepare::runOnFunction(Function &F) { if (TM) TLI = TM->getSubtargetImpl(F)->getTargetLowering(); TLInfo = &getAnalysis().getTLI(); - TTI = &getAnalysis().getTTI(); + TTI = &getAnalysis().getTTI(F); DominatorTreeWrapperPass *DTWP = getAnalysisIfAvailable(); DT = DTWP ? &DTWP->getDomTree() : nullptr; diff --git a/lib/Transforms/Scalar/ConstantHoisting.cpp b/lib/Transforms/Scalar/ConstantHoisting.cpp index 0a027010d58..b84fe37e6c8 100644 --- a/lib/Transforms/Scalar/ConstantHoisting.cpp +++ b/lib/Transforms/Scalar/ConstantHoisting.cpp @@ -138,7 +138,7 @@ private: /// \brief Initialize the pass. void setup(Function &Fn) { DT = &getAnalysis().getDomTree(); - TTI = &getAnalysis().getTTI(); + TTI = &getAnalysis().getTTI(Fn); Entry = &Fn.getEntryBlock(); } diff --git a/lib/Transforms/Scalar/EarlyCSE.cpp b/lib/Transforms/Scalar/EarlyCSE.cpp index 5daac84aa3e..c8dc7711746 100644 --- a/lib/Transforms/Scalar/EarlyCSE.cpp +++ b/lib/Transforms/Scalar/EarlyCSE.cpp @@ -734,7 +734,7 @@ public: DataLayoutPass *DLP = getAnalysisIfAvailable(); auto *DL = DLP ? &DLP->getDataLayout() : nullptr; auto &TLI = getAnalysis().getTLI(); - auto &TTI = getAnalysis().getTTI(); + auto &TTI = getAnalysis().getTTI(F); auto &DT = getAnalysis().getDomTree(); auto &AC = getAnalysis().getAssumptionCache(F); diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp index 1c055f6ec34..f99ebbc453f 100644 --- a/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -1937,7 +1937,7 @@ bool IndVarSimplify::runOnLoop(Loop *L, LPPassManager &LPM) { auto *TLIP = getAnalysisIfAvailable(); TLI = TLIP ? &TLIP->getTLI() : nullptr; auto *TTIP = getAnalysisIfAvailable(); - TTI = TTIP ? &TTIP->getTTI() : nullptr; + TTI = TTIP ? &TTIP->getTTI(*L->getHeader()->getParent()) : nullptr; DeadInsts.clear(); Changed = false; diff --git a/lib/Transforms/Scalar/LoopIdiomRecognize.cpp b/lib/Transforms/Scalar/LoopIdiomRecognize.cpp index 78d8c1ccd42..14984a9a587 100644 --- a/lib/Transforms/Scalar/LoopIdiomRecognize.cpp +++ b/lib/Transforms/Scalar/LoopIdiomRecognize.cpp @@ -204,8 +204,9 @@ namespace { } const TargetTransformInfo *getTargetTransformInfo() { - return TTI ? TTI : (TTI = &getAnalysis() - .getTTI()); + return TTI ? TTI + : (TTI = &getAnalysis().getTTI( + *CurLoop->getHeader()->getParent())); } Loop *getLoop() const { return CurLoop; } diff --git a/lib/Transforms/Scalar/LoopRotation.cpp b/lib/Transforms/Scalar/LoopRotation.cpp index 541afa53bba..2606805400f 100644 --- a/lib/Transforms/Scalar/LoopRotation.cpp +++ b/lib/Transforms/Scalar/LoopRotation.cpp @@ -101,10 +101,11 @@ bool LoopRotate::runOnLoop(Loop *L, LPPassManager &LPM) { // Save the loop metadata. MDNode *LoopMD = L->getLoopID(); + Function &F = *L->getHeader()->getParent(); + LI = &getAnalysis().getLoopInfo(); - TTI = &getAnalysis().getTTI(); - AC = &getAnalysis().getAssumptionCache( - *L->getHeader()->getParent()); + TTI = &getAnalysis().getTTI(F); + AC = &getAnalysis().getAssumptionCache(F); auto *DTWP = getAnalysisIfAvailable(); DT = DTWP ? &DTWP->getDomTree() : nullptr; diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 8325333c0d3..fe4f884ec90 100644 --- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -4866,8 +4866,9 @@ LSRInstance::LSRInstance(Loop *L, Pass *P) : IU(P->getAnalysis()), SE(P->getAnalysis()), DT(P->getAnalysis().getDomTree()), LI(P->getAnalysis().getLoopInfo()), - TTI(P->getAnalysis().getTTI()), L(L), - Changed(false), IVIncInsertPos(nullptr) { + TTI(P->getAnalysis().getTTI( + *L->getHeader()->getParent())), + L(L), Changed(false), IVIncInsertPos(nullptr) { // If LoopSimplify form is not available, stay out of trouble. if (!L->isLoopSimplifyForm()) return; @@ -5100,7 +5101,8 @@ bool LoopStrengthReduce::runOnLoop(Loop *L, LPPassManager & /*LPM*/) { #endif unsigned numFolded = Rewriter.replaceCongruentIVs( L, &getAnalysis().getDomTree(), DeadInsts, - &getAnalysis().getTTI()); + &getAnalysis().getTTI( + *L->getHeader()->getParent())); if (numFolded) { Changed = true; DeleteTriviallyDeadInstructions(DeadInsts); diff --git a/lib/Transforms/Scalar/LoopUnrollPass.cpp b/lib/Transforms/Scalar/LoopUnrollPass.cpp index 86231a1bbb0..1f9cf451525 100644 --- a/lib/Transforms/Scalar/LoopUnrollPass.cpp +++ b/lib/Transforms/Scalar/LoopUnrollPass.cpp @@ -346,14 +346,15 @@ bool LoopUnroll::runOnLoop(Loop *L, LPPassManager &LPM) { if (skipOptnoneFunction(L)) return false; + Function &F = *L->getHeader()->getParent(); + LoopInfo *LI = &getAnalysis().getLoopInfo(); ScalarEvolution *SE = &getAnalysis(); const TargetTransformInfo &TTI = - getAnalysis().getTTI(); + getAnalysis().getTTI(F); const FunctionTargetTransformInfo &FTTI = getAnalysis(); - auto &AC = getAnalysis().getAssumptionCache( - *L->getHeader()->getParent()); + auto &AC = getAnalysis().getAssumptionCache(F); BasicBlock *Header = L->getHeader(); DEBUG(dbgs() << "Loop Unroll: F[" << Header->getParent()->getName() diff --git a/lib/Transforms/Scalar/LoopUnswitch.cpp b/lib/Transforms/Scalar/LoopUnswitch.cpp index 9d18615f774..79344379a20 100644 --- a/lib/Transforms/Scalar/LoopUnswitch.cpp +++ b/lib/Transforms/Scalar/LoopUnswitch.cpp @@ -433,7 +433,8 @@ bool LoopUnswitch::processCurrentLoop() { // Probably we reach the quota of branches for this loop. If so // stop unswitching. if (!BranchesInfo.countLoop( - currentLoop, getAnalysis().getTTI(), + currentLoop, getAnalysis().getTTI( + *currentLoop->getHeader()->getParent()), AC)) return false; diff --git a/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp b/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp index da50fdf0221..31d7df39c78 100644 --- a/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp +++ b/lib/Transforms/Scalar/PartiallyInlineLibCalls.cpp @@ -63,7 +63,7 @@ bool PartiallyInlineLibCalls::runOnFunction(Function &F) { TargetLibraryInfo *TLI = &getAnalysis().getTLI(); const TargetTransformInfo *TTI = - &getAnalysis().getTTI(); + &getAnalysis().getTTI(F); for (Function::iterator BB = F.begin(), BE = F.end(); BB != BE;) { CurrBB = BB++; diff --git a/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp b/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp index caace80a2d6..bffe8dff4b6 100644 --- a/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp +++ b/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp @@ -859,7 +859,8 @@ bool SeparateConstOffsetFromGEP::splitGEP(GetElementPtrInst *GEP) { // case. if (!LowerGEP) { TargetTransformInfo &TTI = - getAnalysis().getTTI(); + getAnalysis().getTTI( + *GEP->getParent()->getParent()); if (!TTI.isLegalAddressingMode(GEP->getType()->getElementType(), /*BaseGV=*/nullptr, AccumulativeByteOffset, /*HasBaseReg=*/true, /*Scale=*/0)) { diff --git a/lib/Transforms/Scalar/SimplifyCFGPass.cpp b/lib/Transforms/Scalar/SimplifyCFGPass.cpp index bc2ae2423e1..fb8fe38c8d7 100644 --- a/lib/Transforms/Scalar/SimplifyCFGPass.cpp +++ b/lib/Transforms/Scalar/SimplifyCFGPass.cpp @@ -206,7 +206,7 @@ struct CFGSimplifyPass : public FunctionPass { AssumptionCache *AC = &getAnalysis().getAssumptionCache(F); const TargetTransformInfo &TTI = - getAnalysis().getTTI(); + getAnalysis().getTTI(F); DataLayoutPass *DLP = getAnalysisIfAvailable(); const DataLayout *DL = DLP ? &DLP->getDataLayout() : nullptr; return simplifyFunctionCFG(F, TTI, DL, AC, BonusInstThreshold); diff --git a/lib/Transforms/Scalar/TailRecursionElimination.cpp b/lib/Transforms/Scalar/TailRecursionElimination.cpp index 3fccd4f53ad..715ddeb168a 100644 --- a/lib/Transforms/Scalar/TailRecursionElimination.cpp +++ b/lib/Transforms/Scalar/TailRecursionElimination.cpp @@ -386,7 +386,7 @@ bool TailCallElim::runTRE(Function &F) { // right, so don't even try to convert it... if (F.getFunctionType()->isVarArg()) return false; - TTI = &getAnalysis().getTTI(); + TTI = &getAnalysis().getTTI(F); BasicBlock *OldEntry = nullptr; bool TailCallsAreMarkedTail = false; SmallVector ArgumentPHIs; diff --git a/lib/Transforms/Vectorize/BBVectorize.cpp b/lib/Transforms/Vectorize/BBVectorize.cpp index 8b541f6b1df..525c050cf28 100644 --- a/lib/Transforms/Vectorize/BBVectorize.cpp +++ b/lib/Transforms/Vectorize/BBVectorize.cpp @@ -201,7 +201,7 @@ namespace { initializeBBVectorizePass(*PassRegistry::getPassRegistry()); } - BBVectorize(Pass *P, const VectorizeConfig &C) + BBVectorize(Pass *P, Function &F, const VectorizeConfig &C) : BasicBlockPass(ID), Config(C) { AA = &P->getAnalysis(); DT = &P->getAnalysis().getDomTree(); @@ -210,7 +210,7 @@ namespace { DL = DLP ? &DLP->getDataLayout() : nullptr; TTI = IgnoreTargetInfo ? nullptr - : &P->getAnalysis().getTTI(); + : &P->getAnalysis().getTTI(F); } typedef std::pair ValuePair; @@ -446,7 +446,8 @@ namespace { DL = DLP ? &DLP->getDataLayout() : nullptr; TTI = IgnoreTargetInfo ? nullptr - : &getAnalysis().getTTI(); + : &getAnalysis().getTTI( + *BB.getParent()); return vectorizeBB(BB); } @@ -3207,7 +3208,7 @@ BasicBlockPass *llvm::createBBVectorizePass(const VectorizeConfig &C) { bool llvm::vectorizeBasicBlock(Pass *P, BasicBlock &BB, const VectorizeConfig &C) { - BBVectorize BBVectorizer(P, C); + BBVectorize BBVectorizer(P, *BB.getParent(), C); return BBVectorizer.vectorizeBB(BB); } diff --git a/lib/Transforms/Vectorize/LoopVectorize.cpp b/lib/Transforms/Vectorize/LoopVectorize.cpp index f6b60569149..f671dcba00a 100644 --- a/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -1330,7 +1330,7 @@ struct LoopVectorize : public FunctionPass { DataLayoutPass *DLP = getAnalysisIfAvailable(); DL = DLP ? &DLP->getDataLayout() : nullptr; LI = &getAnalysis().getLoopInfo(); - TTI = &getAnalysis().getTTI(); + TTI = &getAnalysis().getTTI(F); DT = &getAnalysis().getDomTree(); BFI = &getAnalysis(); auto *TLIP = getAnalysisIfAvailable(); diff --git a/lib/Transforms/Vectorize/SLPVectorizer.cpp b/lib/Transforms/Vectorize/SLPVectorizer.cpp index 2a12c2078d2..08af1daf9bb 100644 --- a/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -3052,7 +3052,7 @@ struct SLPVectorizer : public FunctionPass { SE = &getAnalysis(); DataLayoutPass *DLP = getAnalysisIfAvailable(); DL = DLP ? &DLP->getDataLayout() : nullptr; - TTI = &getAnalysis().getTTI(); + TTI = &getAnalysis().getTTI(F); auto *TLIP = getAnalysisIfAvailable(); TLI = TLIP ? &TLIP->getTLI() : nullptr; AA = &getAnalysis();