diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:10:56 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:10:56 +0000 |
commit | 044eb2f6afba375a914ac9d8024f8f5142bb912e (patch) | |
tree | 1475247dc9f9fe5be155ebd4c9069c75aadf8c20 /lib/Analysis/LoopAnalysisManager.cpp | |
parent | eb70dddbd77e120e5d490bd8fbe7ff3f8fa81c6b (diff) |
Notes
Diffstat (limited to 'lib/Analysis/LoopAnalysisManager.cpp')
-rw-r--r-- | lib/Analysis/LoopAnalysisManager.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/lib/Analysis/LoopAnalysisManager.cpp b/lib/Analysis/LoopAnalysisManager.cpp index e4a0f90b2f710..ea7a62d179c47 100644 --- a/lib/Analysis/LoopAnalysisManager.cpp +++ b/lib/Analysis/LoopAnalysisManager.cpp @@ -11,15 +11,21 @@ #include "llvm/Analysis/BasicAliasAnalysis.h" #include "llvm/Analysis/GlobalsModRef.h" #include "llvm/Analysis/LoopInfo.h" +#include "llvm/Analysis/MemorySSA.h" #include "llvm/Analysis/ScalarEvolution.h" #include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h" #include "llvm/IR/Dominators.h" using namespace llvm; +namespace llvm { +/// Enables memory ssa as a dependency for loop passes in legacy pass manager. +cl::opt<bool> EnableMSSALoopDependency( + "enable-mssa-loop-dependency", cl::Hidden, cl::init(false), + cl::desc("Enable MemorySSA dependency for loop pass manager")); + // Explicit template instantiations and specialization defininitions for core // template typedefs. -namespace llvm { template class AllAnalysesOn<Loop>; template class AnalysisManager<Loop, LoopStandardAnalysisResults &>; template class InnerAnalysisManagerProxy<LoopAnalysisManager, Function>; @@ -45,19 +51,25 @@ bool LoopAnalysisManagerFunctionProxy::Result::invalidate( // loop analyses declare any dependencies on these and use the more general // invalidation logic below to act on that. auto PAC = PA.getChecker<LoopAnalysisManagerFunctionProxy>(); + bool invalidateMemorySSAAnalysis = false; + if (EnableMSSALoopDependency) + invalidateMemorySSAAnalysis = Inv.invalidate<MemorySSAAnalysis>(F, PA); if (!(PAC.preserved() || PAC.preservedSet<AllAnalysesOn<Function>>()) || Inv.invalidate<AAManager>(F, PA) || Inv.invalidate<AssumptionAnalysis>(F, PA) || Inv.invalidate<DominatorTreeAnalysis>(F, PA) || Inv.invalidate<LoopAnalysis>(F, PA) || - Inv.invalidate<ScalarEvolutionAnalysis>(F, PA)) { + Inv.invalidate<ScalarEvolutionAnalysis>(F, PA) || + invalidateMemorySSAAnalysis) { // Note that the LoopInfo may be stale at this point, however the loop // objects themselves remain the only viable keys that could be in the // analysis manager's cache. So we just walk the keys and forcibly clear // those results. Note that the order doesn't matter here as this will just // directly destroy the results without calling methods on them. - for (Loop *L : PreOrderLoops) - InnerAM->clear(*L); + for (Loop *L : PreOrderLoops) { + // NB! `L` may not be in a good enough state to run Loop::getName. + InnerAM->clear(*L, "<possibly invalidated loop>"); + } // We also need to null out the inner AM so that when the object gets // destroyed as invalid we don't try to clear the inner AM again. At that @@ -135,7 +147,9 @@ PreservedAnalyses llvm::getLoopPassPreservedAnalyses() { PA.preserve<LoopAnalysis>(); PA.preserve<LoopAnalysisManagerFunctionProxy>(); PA.preserve<ScalarEvolutionAnalysis>(); - // TODO: What we really want to do here is preserve an AA category, but that + // FIXME: Uncomment this when all loop passes preserve MemorySSA + // PA.preserve<MemorySSAAnalysis>(); + // FIXME: What we really want to do here is preserve an AA category, but that // concept doesn't exist yet. PA.preserve<AAManager>(); PA.preserve<BasicAA>(); |