#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/Statistic.h"
+#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/GuardUtils.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/LoopPass.h"
DominatorTree &DT;
PostDominatorTree *PDT;
LoopInfo &LI;
+ AssumptionCache ∾
MemorySSAUpdater *MSSAU;
/// Together, these describe the region of interest. This might be all of
public:
explicit GuardWideningImpl(DominatorTree &DT, PostDominatorTree *PDT,
- LoopInfo &LI, MemorySSAUpdater *MSSAU,
- DomTreeNode *Root,
- std::function<bool(BasicBlock*)> BlockFilter)
- : DT(DT), PDT(PDT), LI(LI), MSSAU(MSSAU), Root(Root),
+ LoopInfo &LI, AssumptionCache &AC,
+ MemorySSAUpdater *MSSAU, DomTreeNode *Root,
+ std::function<bool(BasicBlock *)> BlockFilter)
+ : DT(DT), PDT(PDT), LI(LI), AC(AC), MSSAU(MSSAU), Root(Root),
BlockFilter(BlockFilter) {}
/// The entry point for this pass.
if (!Inst || DT.dominates(Inst, Loc) || Visited.count(Inst))
return true;
- if (!isSafeToSpeculativelyExecute(Inst, Loc, nullptr, &DT) ||
+ if (!isSafeToSpeculativelyExecute(Inst, Loc, &AC, &DT) ||
Inst->mayReadFromMemory())
return false;
if (!Inst || DT.dominates(Inst, Loc))
return;
- assert(isSafeToSpeculativelyExecute(Inst, Loc, nullptr, &DT) &&
+ assert(isSafeToSpeculativelyExecute(Inst, Loc, &AC, &DT) &&
!Inst->mayReadFromMemory() && "Should've checked with isAvailableAt!");
for (Value *Op : Inst->operands())
auto &DT = AM.getResult<DominatorTreeAnalysis>(F);
auto &LI = AM.getResult<LoopAnalysis>(F);
auto &PDT = AM.getResult<PostDominatorTreeAnalysis>(F);
+ auto &AC = AM.getResult<AssumptionAnalysis>(F);
auto *MSSAA = AM.getCachedResult<MemorySSAAnalysis>(F);
std::unique_ptr<MemorySSAUpdater> MSSAU;
if (MSSAA)
MSSAU = std::make_unique<MemorySSAUpdater>(&MSSAA->getMSSA());
- if (!GuardWideningImpl(DT, &PDT, LI, MSSAU ? MSSAU.get() : nullptr,
+ if (!GuardWideningImpl(DT, &PDT, LI, AC, MSSAU ? MSSAU.get() : nullptr,
DT.getRootNode(), [](BasicBlock *) { return true; })
.run())
return PreservedAnalyses::all();
std::unique_ptr<MemorySSAUpdater> MSSAU;
if (AR.MSSA)
MSSAU = std::make_unique<MemorySSAUpdater>(AR.MSSA);
- if (!GuardWideningImpl(AR.DT, nullptr, AR.LI, MSSAU ? MSSAU.get() : nullptr,
- AR.DT.getNode(RootBB), BlockFilter).run())
+ if (!GuardWideningImpl(AR.DT, nullptr, AR.LI, AR.AC,
+ MSSAU ? MSSAU.get() : nullptr, AR.DT.getNode(RootBB),
+ BlockFilter)
+ .run())
return PreservedAnalyses::all();
auto PA = getLoopPassPreservedAnalyses();
return false;
auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
auto &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
+ auto &AC = getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
auto &PDT = getAnalysis<PostDominatorTreeWrapperPass>().getPostDomTree();
auto *MSSAWP = getAnalysisIfAvailable<MemorySSAWrapperPass>();
std::unique_ptr<MemorySSAUpdater> MSSAU;
if (MSSAWP)
MSSAU = std::make_unique<MemorySSAUpdater>(&MSSAWP->getMSSA());
- return GuardWideningImpl(DT, &PDT, LI, MSSAU ? MSSAU.get() : nullptr,
+ return GuardWideningImpl(DT, &PDT, LI, AC, MSSAU ? MSSAU.get() : nullptr,
DT.getRootNode(),
[](BasicBlock *) { return true; })
.run();
return false;
auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
auto &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
+ auto &AC = getAnalysis<AssumptionCacheTracker>().getAssumptionCache(
+ *L->getHeader()->getParent());
auto *PDTWP = getAnalysisIfAvailable<PostDominatorTreeWrapperPass>();
auto *PDT = PDTWP ? &PDTWP->getPostDomTree() : nullptr;
auto *MSSAWP = getAnalysisIfAvailable<MemorySSAWrapperPass>();
auto BlockFilter = [&](BasicBlock *BB) {
return BB == RootBB || L->contains(BB);
};
- return GuardWideningImpl(DT, PDT, LI, MSSAU ? MSSAU.get() : nullptr,
- DT.getNode(RootBB), BlockFilter).run();
+ return GuardWideningImpl(DT, PDT, LI, AC, MSSAU ? MSSAU.get() : nullptr,
+ DT.getNode(RootBB), BlockFilter)
+ .run();
}
void getAnalysisUsage(AnalysisUsage &AU) const override {