[llvm] 473e83b - GuardWidening: Pass through AssumptionCache (NFC)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 26 11:53:14 PDT 2022
Author: Matt Arsenault
Date: 2022-09-26T14:53:00-04:00
New Revision: 473e83b95ad2858a27e8bfdd62830809891c441c
URL: https://github.com/llvm/llvm-project/commit/473e83b95ad2858a27e8bfdd62830809891c441c
DIFF: https://github.com/llvm/llvm-project/commit/473e83b95ad2858a27e8bfdd62830809891c441c.diff
LOG: GuardWidening: Pass through AssumptionCache (NFC)
Added:
Modified:
llvm/lib/Transforms/Scalar/GuardWidening.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/GuardWidening.cpp b/llvm/lib/Transforms/Scalar/GuardWidening.cpp
index 912f155db187..6f0349fc7bf4 100644
--- a/llvm/lib/Transforms/Scalar/GuardWidening.cpp
+++ b/llvm/lib/Transforms/Scalar/GuardWidening.cpp
@@ -42,6 +42,7 @@
#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"
@@ -116,6 +117,7 @@ class GuardWideningImpl {
DominatorTree &DT;
PostDominatorTree *PDT;
LoopInfo &LI;
+ AssumptionCache ∾
MemorySSAUpdater *MSSAU;
/// Together, these describe the region of interest. This might be all of
@@ -273,10 +275,10 @@ class GuardWideningImpl {
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.
@@ -468,7 +470,7 @@ bool GuardWideningImpl::isAvailableAt(
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;
@@ -488,7 +490,7 @@ void GuardWideningImpl::makeAvailableAt(Value *V, Instruction *Loc) const {
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())
@@ -764,11 +766,12 @@ PreservedAnalyses GuardWideningPass::run(Function &F,
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();
@@ -791,8 +794,10 @@ PreservedAnalyses GuardWideningPass::run(Loop &L, LoopAnalysisManager &AM,
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();
@@ -814,12 +819,13 @@ struct GuardWideningLegacyPass : public FunctionPass {
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();
@@ -848,6 +854,8 @@ struct LoopGuardWideningLegacyPass : public LoopPass {
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>();
@@ -861,8 +869,9 @@ struct LoopGuardWideningLegacyPass : public LoopPass {
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 {
More information about the llvm-commits
mailing list