[llvm] 6d98f3a - [LoopVersioningLICM] Clarify scope of AST (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 14 06:29:07 PST 2022
Author: Nikita Popov
Date: 2022-11-14T15:28:59+01:00
New Revision: 6d98f3a6dfa392b2c87a0e55d0d2aa4685faba0d
URL: https://github.com/llvm/llvm-project/commit/6d98f3a6dfa392b2c87a0e55d0d2aa4685faba0d
DIFF: https://github.com/llvm/llvm-project/commit/6d98f3a6dfa392b2c87a0e55d0d2aa4685faba0d.diff
LOG: [LoopVersioningLICM] Clarify scope of AST (NFC)
Make it clearer that the AST is only temporarily used during the
legality check, and does not have to survive into the transformation
phase.
Added:
Modified:
llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp b/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp
index 65df1aa839f0..38ebfe597cc4 100644
--- a/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp
@@ -147,13 +147,13 @@ struct LoopVersioningLICM {
// LoopAccessInfo will take place only when it's necessary.
LoopVersioningLICM(AliasAnalysis *AA, ScalarEvolution *SE,
OptimizationRemarkEmitter *ORE,
- LoopAccessInfoManager &LAIs,
+ LoopAccessInfoManager &LAIs, LoopInfo &LI,
Loop *CurLoop)
- : AA(AA), SE(SE), LAIs(LAIs), CurLoop(CurLoop), AST(*AA),
+ : AA(AA), SE(SE), LAIs(LAIs), LI(LI), CurLoop(CurLoop),
LoopDepthThreshold(LVLoopDepthThreshold),
InvariantThreshold(LVInvarThreshold), ORE(ORE) {}
- bool run(LoopInfo *LI, DominatorTree *DT);
+ bool run(DominatorTree *DT);
private:
// Current AliasAnalysis information
@@ -168,12 +168,11 @@ struct LoopVersioningLICM {
// Proxy for retrieving LoopAccessInfo.
LoopAccessInfoManager &LAIs;
+ LoopInfo &LI;
+
// The current loop we are working on.
Loop *CurLoop;
- // AliasSet information for the current loop.
- AliasSetTracker AST;
-
// Maximum loop nest threshold
unsigned LoopDepthThreshold;
@@ -256,9 +255,14 @@ bool LoopVersioningLICM::legalLoopStructure() {
/// Check memory accesses in loop and confirms it's good for
/// LoopVersioningLICM.
bool LoopVersioningLICM::legalLoopMemoryAccesses() {
- bool HasMayAlias = false;
- bool TypeSafety = false;
- bool HasMod = false;
+ // Loop over the body of this loop, construct AST.
+ AliasSetTracker AST(*AA);
+ for (auto *Block : CurLoop->getBlocks()) {
+ // Ignore blocks in subloops.
+ if (LI.getLoopFor(Block) == CurLoop)
+ AST.add(*Block);
+ }
+
// Memory check:
// Transform phase will generate a versioned loop and also a runtime check to
// ensure the pointers are independent and they don’t alias.
@@ -271,6 +275,9 @@ bool LoopVersioningLICM::legalLoopMemoryAccesses() {
//
// Iterate over alias tracker sets, and confirm AliasSets doesn't have any
// must alias set.
+ bool HasMayAlias = false;
+ bool TypeSafety = false;
+ bool HasMod = false;
for (const auto &I : AST) {
const AliasSet &AS = I;
// Skip Forward Alias Sets, as this should be ignored as part of
@@ -563,25 +570,18 @@ bool LoopVersioningLICMLegacyPass::runOnLoop(Loop *L, LPPassManager &LPM) {
ScalarEvolution *SE = &getAnalysis<ScalarEvolutionWrapperPass>().getSE();
OptimizationRemarkEmitter *ORE =
&getAnalysis<OptimizationRemarkEmitterWrapperPass>().getORE();
- LoopInfo *LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
+ LoopInfo &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
DominatorTree *DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
auto &LAIs = getAnalysis<LoopAccessLegacyAnalysis>().getLAIs();
- return LoopVersioningLICM(AA, SE, ORE, LAIs, L).run(LI, DT);
+ return LoopVersioningLICM(AA, SE, ORE, LAIs, LI, L).run(DT);
}
-bool LoopVersioningLICM::run(LoopInfo *LI, DominatorTree *DT) {
+bool LoopVersioningLICM::run(DominatorTree *DT) {
// Do not do the transformation if disabled by metadata.
if (hasLICMVersioningTransformation(CurLoop) & TM_Disable)
return false;
- // Loop over the body of this loop, construct AST.
- for (auto *Block : CurLoop->getBlocks()) {
- // Ignore blocks in subloops.
- if (LI->getLoopFor(Block) == CurLoop)
- AST.add(*Block); // Incorporate the specified basic block
- }
-
bool Changed = false;
// Check feasiblity of LoopVersioningLICM.
@@ -592,7 +592,7 @@ bool LoopVersioningLICM::run(LoopInfo *LI, DominatorTree *DT) {
// Create memcheck for memory accessed inside loop.
// Clone original loop, and set blocks properly.
LoopVersioning LVer(*LAI, LAI->getRuntimePointerChecking()->getChecks(),
- CurLoop, LI, DT, SE);
+ CurLoop, &LI, DT, SE);
LVer.versionLoop();
// Set Loop Versioning metaData for original loop.
addStringMetadataToLoop(LVer.getNonVersionedLoop(), LICMVersioningMetaData);
@@ -638,12 +638,11 @@ PreservedAnalyses LoopVersioningLICMPass::run(Loop &L, LoopAnalysisManager &AM,
AliasAnalysis *AA = &LAR.AA;
ScalarEvolution *SE = &LAR.SE;
DominatorTree *DT = &LAR.DT;
- LoopInfo *LI = &LAR.LI;
const Function *F = L.getHeader()->getParent();
OptimizationRemarkEmitter ORE(F);
- LoopAccessInfoManager LAIs(*SE, *AA, *DT, *LI, nullptr);
- if (!LoopVersioningLICM(AA, SE, &ORE, LAIs, &L).run(LI, DT))
+ LoopAccessInfoManager LAIs(*SE, *AA, *DT, LAR.LI, nullptr);
+ if (!LoopVersioningLICM(AA, SE, &ORE, LAIs, LAR.LI, &L).run(DT))
return PreservedAnalyses::all();
return getLoopPassPreservedAnalyses();
}
More information about the llvm-commits
mailing list