diff options
Diffstat (limited to 'llvm/lib/Analysis/BasicAliasAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/BasicAliasAnalysis.cpp | 82 |
1 files changed, 28 insertions, 54 deletions
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp index ec80aa5..f7b0edd 100644 --- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp +++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp @@ -24,7 +24,6 @@ #include "llvm/Analysis/CaptureTracking.h" #include "llvm/Analysis/MemoryBuiltins.h" #include "llvm/Analysis/MemoryLocation.h" -#include "llvm/Analysis/PhiValues.h" #include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/Analysis/ValueTracking.h" #include "llvm/IR/Argument.h" @@ -87,8 +86,7 @@ bool BasicAAResult::invalidate(Function &Fn, const PreservedAnalyses &PA, // may be created without handles to some analyses and in that case don't // depend on them. if (Inv.invalidate<AssumptionAnalysis>(Fn, PA) || - (DT && Inv.invalidate<DominatorTreeAnalysis>(Fn, PA)) || - (PV && Inv.invalidate<PhiValuesAnalysis>(Fn, PA))) + (DT && Inv.invalidate<DominatorTreeAnalysis>(Fn, PA))) return true; // Otherwise this analysis result remains valid. @@ -1339,56 +1337,37 @@ AliasResult BasicAAResult::aliasPHI(const PHINode *PN, LocationSize PNSize, return false; }; - if (PV) { - // If we have PhiValues then use it to get the underlying phi values. - const PhiValues::ValueSet &PhiValueSet = PV->getValuesForPhi(PN); - // If we have more phi values than the search depth then return MayAlias - // conservatively to avoid compile time explosion. The worst possible case - // is if both sides are PHI nodes. In which case, this is O(m x n) time - // where 'm' and 'n' are the number of PHI sources. - if (PhiValueSet.size() > MaxLookupSearchDepth) - return AliasResult::MayAlias; - // Add the values to V1Srcs - for (Value *PV1 : PhiValueSet) { - if (CheckForRecPhi(PV1)) - continue; - V1Srcs.push_back(PV1); - } - } else { - // If we don't have PhiInfo then just look at the operands of the phi itself - // FIXME: Remove this once we can guarantee that we have PhiInfo always - SmallPtrSet<Value *, 4> UniqueSrc; - Value *OnePhi = nullptr; - for (Value *PV1 : PN->incoming_values()) { - // Skip the phi itself being the incoming value. - if (PV1 == PN) - continue; + SmallPtrSet<Value *, 4> UniqueSrc; + Value *OnePhi = nullptr; + for (Value *PV1 : PN->incoming_values()) { + // Skip the phi itself being the incoming value. + if (PV1 == PN) + continue; - if (isa<PHINode>(PV1)) { - if (OnePhi && OnePhi != PV1) { - // To control potential compile time explosion, we choose to be - // conserviate when we have more than one Phi input. It is important - // that we handle the single phi case as that lets us handle LCSSA - // phi nodes and (combined with the recursive phi handling) simple - // pointer induction variable patterns. - return AliasResult::MayAlias; - } - OnePhi = PV1; + if (isa<PHINode>(PV1)) { + if (OnePhi && OnePhi != PV1) { + // To control potential compile time explosion, we choose to be + // conserviate when we have more than one Phi input. It is important + // that we handle the single phi case as that lets us handle LCSSA + // phi nodes and (combined with the recursive phi handling) simple + // pointer induction variable patterns. + return AliasResult::MayAlias; } - - if (CheckForRecPhi(PV1)) - continue; - - if (UniqueSrc.insert(PV1).second) - V1Srcs.push_back(PV1); + OnePhi = PV1; } - if (OnePhi && UniqueSrc.size() > 1) - // Out of an abundance of caution, allow only the trivial lcssa and - // recursive phi cases. - return AliasResult::MayAlias; + if (CheckForRecPhi(PV1)) + continue; + + if (UniqueSrc.insert(PV1).second) + V1Srcs.push_back(PV1); } + if (OnePhi && UniqueSrc.size() > 1) + // Out of an abundance of caution, allow only the trivial lcssa and + // recursive phi cases. + return AliasResult::MayAlias; + // If V1Srcs is empty then that means that the phi has no underlying non-phi // value. This should only be possible in blocks unreachable from the entry // block, but return MayAlias just in case. @@ -1776,8 +1755,7 @@ BasicAAResult BasicAA::run(Function &F, FunctionAnalysisManager &AM) { auto &TLI = AM.getResult<TargetLibraryAnalysis>(F); auto &AC = AM.getResult<AssumptionAnalysis>(F); auto *DT = &AM.getResult<DominatorTreeAnalysis>(F); - auto *PV = AM.getCachedResult<PhiValuesAnalysis>(F); - return BasicAAResult(F.getParent()->getDataLayout(), F, TLI, AC, DT, PV); + return BasicAAResult(F.getParent()->getDataLayout(), F, TLI, AC, DT); } BasicAAWrapperPass::BasicAAWrapperPass() : FunctionPass(ID) { @@ -1793,7 +1771,6 @@ INITIALIZE_PASS_BEGIN(BasicAAWrapperPass, "basic-aa", INITIALIZE_PASS_DEPENDENCY(AssumptionCacheTracker) INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass) -INITIALIZE_PASS_DEPENDENCY(PhiValuesWrapperPass) INITIALIZE_PASS_END(BasicAAWrapperPass, "basic-aa", "Basic Alias Analysis (stateless AA impl)", true, true) @@ -1805,12 +1782,10 @@ bool BasicAAWrapperPass::runOnFunction(Function &F) { auto &ACT = getAnalysis<AssumptionCacheTracker>(); auto &TLIWP = getAnalysis<TargetLibraryInfoWrapperPass>(); auto &DTWP = getAnalysis<DominatorTreeWrapperPass>(); - auto *PVWP = getAnalysisIfAvailable<PhiValuesWrapperPass>(); Result.reset(new BasicAAResult(F.getParent()->getDataLayout(), F, TLIWP.getTLI(F), ACT.getAssumptionCache(F), - &DTWP.getDomTree(), - PVWP ? &PVWP->getResult() : nullptr)); + &DTWP.getDomTree())); return false; } @@ -1820,7 +1795,6 @@ void BasicAAWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequiredTransitive<AssumptionCacheTracker>(); AU.addRequiredTransitive<DominatorTreeWrapperPass>(); AU.addRequiredTransitive<TargetLibraryInfoWrapperPass>(); - AU.addUsedIfAvailable<PhiValuesWrapperPass>(); } BasicAAResult llvm::createLegacyPMBasicAAResult(Pass &P, Function &F) { |