diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2017-01-15 06:32:49 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2017-01-15 06:32:49 +0000 |
commit | ca68a3ec47416185252b84d2bf60710c88be155f (patch) | |
tree | ee01d0ac2b40351bb1a659719488d3db1ca43268 /llvm/include | |
parent | f1388ef006fa87b5799e4bb7cc0662e0b644b35d (diff) | |
download | bcm5719-llvm-ca68a3ec47416185252b84d2bf60710c88be155f.tar.gz bcm5719-llvm-ca68a3ec47416185252b84d2bf60710c88be155f.zip |
[PM] Introduce an analysis set used to preserve all analyses over
a function's CFG when that CFG is unchanged.
This allows transformation passes to simply claim they preserve the CFG
and analysis passes to check for the CFG being preserved to remove the
fanout of all analyses being listed in all passes.
I've gone through and removed or cleaned up as many of the comments
reminding us to do this as I could.
Differential Revision: https://reviews.llvm.org/D28627
llvm-svn: 292054
Diffstat (limited to 'llvm/include')
-rw-r--r-- | llvm/include/llvm/Analysis/BlockFrequencyInfo.h | 4 | ||||
-rw-r--r-- | llvm/include/llvm/Analysis/DominanceFrontier.h | 4 | ||||
-rw-r--r-- | llvm/include/llvm/Analysis/LoopInfo.h | 4 | ||||
-rw-r--r-- | llvm/include/llvm/Analysis/PostDominators.h | 4 | ||||
-rw-r--r-- | llvm/include/llvm/Analysis/RegionInfo.h | 4 | ||||
-rw-r--r-- | llvm/include/llvm/IR/Dominators.h | 4 | ||||
-rw-r--r-- | llvm/include/llvm/IR/PassManager.h | 63 |
7 files changed, 64 insertions, 23 deletions
diff --git a/llvm/include/llvm/Analysis/BlockFrequencyInfo.h b/llvm/include/llvm/Analysis/BlockFrequencyInfo.h index 562041d11fa..e2d21ef9de3 100644 --- a/llvm/include/llvm/Analysis/BlockFrequencyInfo.h +++ b/llvm/include/llvm/Analysis/BlockFrequencyInfo.h @@ -45,6 +45,10 @@ public: ~BlockFrequencyInfo(); + /// Handle invalidation explicitly. + bool invalidate(Function &F, const PreservedAnalyses &PA, + FunctionAnalysisManager::Invalidator &); + const Function *getFunction() const; const BranchProbabilityInfo *getBPI() const; void view() const; diff --git a/llvm/include/llvm/Analysis/DominanceFrontier.h b/llvm/include/llvm/Analysis/DominanceFrontier.h index b9667f801ed..8cae63c3c86 100644 --- a/llvm/include/llvm/Analysis/DominanceFrontier.h +++ b/llvm/include/llvm/Analysis/DominanceFrontier.h @@ -141,6 +141,10 @@ public: typedef DominanceFrontierBase<BasicBlock>::DomSetType DomSetType; typedef DominanceFrontierBase<BasicBlock>::iterator iterator; typedef DominanceFrontierBase<BasicBlock>::const_iterator const_iterator; + + /// Handle invalidation explicitly. + bool invalidate(Function &F, const PreservedAnalyses &PA, + FunctionAnalysisManager::Invalidator &); }; class DominanceFrontierWrapperPass : public FunctionPass { diff --git a/llvm/include/llvm/Analysis/LoopInfo.h b/llvm/include/llvm/Analysis/LoopInfo.h index 50d0fc62ac8..1156c98d8c7 100644 --- a/llvm/include/llvm/Analysis/LoopInfo.h +++ b/llvm/include/llvm/Analysis/LoopInfo.h @@ -682,6 +682,10 @@ public: return *this; } + /// Handle invalidation explicitly. + bool invalidate(Function &F, const PreservedAnalyses &PA, + FunctionAnalysisManager::Invalidator &); + // Most of the public interface is provided via LoopInfoBase. /// Update LoopInfo after removing the last backedge from a loop. This updates diff --git a/llvm/include/llvm/Analysis/PostDominators.h b/llvm/include/llvm/Analysis/PostDominators.h index 34361dac8c1..94ee3b03bb8 100644 --- a/llvm/include/llvm/Analysis/PostDominators.h +++ b/llvm/include/llvm/Analysis/PostDominators.h @@ -26,6 +26,10 @@ struct PostDominatorTree : public DominatorTreeBase<BasicBlock> { typedef DominatorTreeBase<BasicBlock> Base; PostDominatorTree() : DominatorTreeBase<BasicBlock>(true) {} + + /// Handle invalidation explicitly. + bool invalidate(Function &F, const PreservedAnalyses &PA, + FunctionAnalysisManager::Invalidator &); }; /// \brief Analysis pass which computes a \c PostDominatorTree. diff --git a/llvm/include/llvm/Analysis/RegionInfo.h b/llvm/include/llvm/Analysis/RegionInfo.h index f2f27a137a8..caeb21db613 100644 --- a/llvm/include/llvm/Analysis/RegionInfo.h +++ b/llvm/include/llvm/Analysis/RegionInfo.h @@ -886,6 +886,10 @@ public: return *this; } + /// Handle invalidation explicitly. + bool invalidate(Function &F, const PreservedAnalyses &PA, + FunctionAnalysisManager::Invalidator &); + // updateStatistics - Update statistic about created regions. void updateStatistics(Region *R) final; diff --git a/llvm/include/llvm/IR/Dominators.h b/llvm/include/llvm/IR/Dominators.h index 7c733bac8da..e39ef64e699 100644 --- a/llvm/include/llvm/IR/Dominators.h +++ b/llvm/include/llvm/IR/Dominators.h @@ -102,6 +102,10 @@ public: recalculate(F); } + /// Handle invalidation explicitly. + bool invalidate(Function &F, const PreservedAnalyses &PA, + FunctionAnalysisManager::Invalidator &); + /// \brief Returns *false* if the other dominator tree matches this dominator /// tree. inline bool compare(const DominatorTree &Other) const { diff --git a/llvm/include/llvm/IR/PassManager.h b/llvm/include/llvm/IR/PassManager.h index 2e95f67a14a..0825ed713ac 100644 --- a/llvm/include/llvm/IR/PassManager.h +++ b/llvm/include/llvm/IR/PassManager.h @@ -73,6 +73,46 @@ struct alignas(8) AnalysisKey {}; /// if it is, the analysis knows that it itself is preserved. struct alignas(8) AnalysisSetKey {}; +/// This templated class represents "all analyses that operate over \<a +/// particular IR unit\>" (e.g. a Function or a Module) in instances of +/// PreservedAnalysis. +/// +/// This lets a transformation say e.g. "I preserved all function analyses". +/// +/// Note that you must provide an explicit instantiation declaration and +/// definition for this template in order to get the correct behavior on +/// Windows. Otherwise, the address of SetKey will not be stable. +template <typename IRUnitT> class AllAnalysesOn { +public: + static AnalysisSetKey *ID() { return &SetKey; } + +private: + static AnalysisSetKey SetKey; +}; + +template <typename IRUnitT> AnalysisSetKey AllAnalysesOn<IRUnitT>::SetKey; + +extern template class AllAnalysesOn<Module>; +extern template class AllAnalysesOn<Function>; + +/// Represents analyses that only rely on functions' control flow. +/// +/// This can be used with \c PreservedAnalyses to mark the CFG as preserved and +/// to query whether it has been preserved. +/// +/// The CFG of a function is defined as the set of basic blocks and the edges +/// between them. Changing the set of basic blocks in a function is enough to +/// mutate the CFG. Mutating the condition of a branch or argument of an +/// invoked function does not mutate the CFG, but changing the successor labels +/// of those instructions does. +class CFGAnalyses { +public: + static AnalysisSetKey *ID() { return &SetKey; } + +private: + static AnalysisSetKey SetKey; +}; + /// A set of analyses that are preserved following a run of a transformation /// pass. /// @@ -342,29 +382,6 @@ struct AnalysisInfoMixin : PassInfoMixin<DerivedT> { static AnalysisKey *ID() { return &DerivedT::Key; } }; -/// This templated class represents "all analyses that operate over \<a -/// particular IR unit\>" (e.g. a Function or a Module) in instances of -/// PreservedAnalysis. -/// -/// This lets a transformation say e.g. "I preserved all function analyses". -/// -/// Note that you must provide an explicit instantiation declaration and -/// definition for this template in order to get the correct behavior on -/// Windows. Otherwise, the address of SetKey will not be stable. -template <typename IRUnitT> -class AllAnalysesOn { -public: - static AnalysisSetKey *ID() { return &SetKey; } - -private: - static AnalysisSetKey SetKey; -}; - -template <typename IRUnitT> AnalysisSetKey AllAnalysesOn<IRUnitT>::SetKey; - -extern template class AllAnalysesOn<Module>; -extern template class AllAnalysesOn<Function>; - /// \brief Manages a sequence of passes over a particular unit of IR. /// /// A pass manager contains a sequence of passes to run over a particular unit |