summaryrefslogtreecommitdiff
path: root/include/llvm/IR/PassManager.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/IR/PassManager.h')
-rw-r--r--include/llvm/IR/PassManager.h122
1 files changed, 71 insertions, 51 deletions
diff --git a/include/llvm/IR/PassManager.h b/include/llvm/IR/PassManager.h
index c845112baa453..d03b7b65f81e2 100644
--- a/include/llvm/IR/PassManager.h
+++ b/include/llvm/IR/PassManager.h
@@ -39,8 +39,8 @@
#define LLVM_IR_PASSMANAGER_H
#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/TinyPtrVector.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Module.h"
@@ -48,9 +48,15 @@
#include "llvm/Support/Debug.h"
#include "llvm/Support/TypeName.h"
#include "llvm/Support/raw_ostream.h"
-#include "llvm/Support/type_traits.h"
+#include <algorithm>
+#include <cassert>
+#include <cstring>
+#include <iterator>
#include <list>
#include <memory>
+#include <tuple>
+#include <type_traits>
+#include <utility>
#include <vector>
namespace llvm {
@@ -469,15 +475,16 @@ public:
}
template <typename PassT> void addPass(PassT Pass) {
- typedef detail::PassModel<IRUnitT, PassT, PreservedAnalyses,
- AnalysisManagerT, ExtraArgTs...>
- PassModelT;
+ using PassModelT =
+ detail::PassModel<IRUnitT, PassT, PreservedAnalyses, AnalysisManagerT,
+ ExtraArgTs...>;
+
Passes.emplace_back(new PassModelT(std::move(Pass)));
}
private:
- typedef detail::PassConcept<IRUnitT, AnalysisManagerT, ExtraArgTs...>
- PassConceptT;
+ using PassConceptT =
+ detail::PassConcept<IRUnitT, AnalysisManagerT, ExtraArgTs...>;
std::vector<std::unique_ptr<PassConceptT>> Passes;
@@ -486,12 +493,14 @@ private:
};
extern template class PassManager<Module>;
+
/// \brief Convenience typedef for a pass manager over modules.
-typedef PassManager<Module> ModulePassManager;
+using ModulePassManager = PassManager<Module>;
extern template class PassManager<Function>;
+
/// \brief Convenience typedef for a pass manager over functions.
-typedef PassManager<Function> FunctionPassManager;
+using FunctionPassManager = PassManager<Function>;
/// \brief A container for analyses that lazily runs them and caches their
/// results.
@@ -504,11 +513,11 @@ public:
private:
// Now that we've defined our invalidator, we can define the concept types.
- typedef detail::AnalysisResultConcept<IRUnitT, PreservedAnalyses, Invalidator>
- ResultConceptT;
- typedef detail::AnalysisPassConcept<IRUnitT, PreservedAnalyses, Invalidator,
- ExtraArgTs...>
- PassConceptT;
+ using ResultConceptT =
+ detail::AnalysisResultConcept<IRUnitT, PreservedAnalyses, Invalidator>;
+ using PassConceptT =
+ detail::AnalysisPassConcept<IRUnitT, PreservedAnalyses, Invalidator,
+ ExtraArgTs...>;
/// \brief List of analysis pass IDs and associated concept pointers.
///
@@ -516,18 +525,18 @@ private:
/// erases. Provides the analysis ID to enable finding iterators to a given
/// entry in maps below, and provides the storage for the actual result
/// concept.
- typedef std::list<std::pair<AnalysisKey *, std::unique_ptr<ResultConceptT>>>
- AnalysisResultListT;
+ using AnalysisResultListT =
+ std::list<std::pair<AnalysisKey *, std::unique_ptr<ResultConceptT>>>;
/// \brief Map type from IRUnitT pointer to our custom list type.
- typedef DenseMap<IRUnitT *, AnalysisResultListT> AnalysisResultListMapT;
+ using AnalysisResultListMapT = DenseMap<IRUnitT *, AnalysisResultListT>;
/// \brief Map type from a pair of analysis ID and IRUnitT pointer to an
/// iterator into a particular result list (which is where the actual analysis
/// result is stored).
- typedef DenseMap<std::pair<AnalysisKey *, IRUnitT *>,
- typename AnalysisResultListT::iterator>
- AnalysisResultMapT;
+ using AnalysisResultMapT =
+ DenseMap<std::pair<AnalysisKey *, IRUnitT *>,
+ typename AnalysisResultListT::iterator>;
public:
/// API to communicate dependencies between analyses during invalidation.
@@ -558,10 +567,10 @@ public:
/// dependecies on it will become invalid as a result.
template <typename PassT>
bool invalidate(IRUnitT &IR, const PreservedAnalyses &PA) {
- typedef detail::AnalysisResultModel<IRUnitT, PassT,
- typename PassT::Result,
- PreservedAnalyses, Invalidator>
- ResultModelT;
+ using ResultModelT =
+ detail::AnalysisResultModel<IRUnitT, PassT, typename PassT::Result,
+ PreservedAnalyses, Invalidator>;
+
return invalidateImpl<ResultModelT>(PassT::ID(), IR, PA);
}
@@ -672,9 +681,11 @@ public:
"This analysis pass was not registered prior to being queried");
ResultConceptT &ResultConcept =
getResultImpl(PassT::ID(), IR, ExtraArgs...);
- typedef detail::AnalysisResultModel<IRUnitT, PassT, typename PassT::Result,
- PreservedAnalyses, Invalidator>
- ResultModelT;
+
+ using ResultModelT =
+ detail::AnalysisResultModel<IRUnitT, PassT, typename PassT::Result,
+ PreservedAnalyses, Invalidator>;
+
return static_cast<ResultModelT &>(ResultConcept).Result;
}
@@ -692,9 +703,10 @@ public:
if (!ResultConcept)
return nullptr;
- typedef detail::AnalysisResultModel<IRUnitT, PassT, typename PassT::Result,
- PreservedAnalyses, Invalidator>
- ResultModelT;
+ using ResultModelT =
+ detail::AnalysisResultModel<IRUnitT, PassT, typename PassT::Result,
+ PreservedAnalyses, Invalidator>;
+
return &static_cast<ResultModelT *>(ResultConcept)->Result;
}
@@ -717,10 +729,10 @@ public:
/// hashtable.)
template <typename PassBuilderT>
bool registerPass(PassBuilderT &&PassBuilder) {
- typedef decltype(PassBuilder()) PassT;
- typedef detail::AnalysisPassModel<IRUnitT, PassT, PreservedAnalyses,
- Invalidator, ExtraArgTs...>
- PassModelT;
+ using PassT = decltype(PassBuilder());
+ using PassModelT =
+ detail::AnalysisPassModel<IRUnitT, PassT, PreservedAnalyses,
+ Invalidator, ExtraArgTs...>;
auto &PassPtr = AnalysisPasses[PassT::ID()];
if (PassPtr)
@@ -876,7 +888,8 @@ private:
}
/// \brief Map type from module analysis pass ID to pass concept pointer.
- typedef DenseMap<AnalysisKey *, std::unique_ptr<PassConceptT>> AnalysisPassMapT;
+ using AnalysisPassMapT =
+ DenseMap<AnalysisKey *, std::unique_ptr<PassConceptT>>;
/// \brief Collection of module analysis passes, indexed by ID.
AnalysisPassMapT AnalysisPasses;
@@ -896,12 +909,14 @@ private:
};
extern template class AnalysisManager<Module>;
+
/// \brief Convenience typedef for the Module analysis manager.
-typedef AnalysisManager<Module> ModuleAnalysisManager;
+using ModuleAnalysisManager = AnalysisManager<Module>;
extern template class AnalysisManager<Function>;
+
/// \brief Convenience typedef for the Function analysis manager.
-typedef AnalysisManager<Function> FunctionAnalysisManager;
+using FunctionAnalysisManager = AnalysisManager<Function>;
/// \brief An analysis over an "outer" IR unit that provides access to an
/// analysis manager over an "inner" IR unit. The inner unit must be contained
@@ -927,20 +942,14 @@ public:
class Result {
public:
explicit Result(AnalysisManagerT &InnerAM) : InnerAM(&InnerAM) {}
+
Result(Result &&Arg) : InnerAM(std::move(Arg.InnerAM)) {
// We have to null out the analysis manager in the moved-from state
// because we are taking ownership of the responsibilty to clear the
// analysis state.
Arg.InnerAM = nullptr;
}
- Result &operator=(Result &&RHS) {
- InnerAM = RHS.InnerAM;
- // We have to null out the analysis manager in the moved-from state
- // because we are taking ownership of the responsibilty to clear the
- // analysis state.
- RHS.InnerAM = nullptr;
- return *this;
- }
+
~Result() {
// InnerAM is cleared in a moved from state where there is nothing to do.
if (!InnerAM)
@@ -951,6 +960,15 @@ public:
InnerAM->clear();
}
+ Result &operator=(Result &&RHS) {
+ InnerAM = RHS.InnerAM;
+ // We have to null out the analysis manager in the moved-from state
+ // because we are taking ownership of the responsibilty to clear the
+ // analysis state.
+ RHS.InnerAM = nullptr;
+ return *this;
+ }
+
/// \brief Accessor for the analysis manager.
AnalysisManagerT &getManager() { return *InnerAM; }
@@ -988,6 +1006,7 @@ public:
private:
friend AnalysisInfoMixin<
InnerAnalysisManagerProxy<AnalysisManagerT, IRUnitT>>;
+
static AnalysisKey Key;
AnalysisManagerT *InnerAM;
@@ -998,8 +1017,8 @@ AnalysisKey
InnerAnalysisManagerProxy<AnalysisManagerT, IRUnitT, ExtraArgTs...>::Key;
/// Provide the \c FunctionAnalysisManager to \c Module proxy.
-typedef InnerAnalysisManagerProxy<FunctionAnalysisManager, Module>
- FunctionAnalysisManagerModuleProxy;
+using FunctionAnalysisManagerModuleProxy =
+ InnerAnalysisManagerProxy<FunctionAnalysisManager, Module>;
/// Specialization of the invalidate method for the \c
/// FunctionAnalysisManagerModuleProxy's result.
@@ -1097,6 +1116,7 @@ public:
private:
friend AnalysisInfoMixin<
OuterAnalysisManagerProxy<AnalysisManagerT, IRUnitT, ExtraArgTs...>>;
+
static AnalysisKey Key;
const AnalysisManagerT *AM;
@@ -1109,8 +1129,8 @@ AnalysisKey
extern template class OuterAnalysisManagerProxy<ModuleAnalysisManager,
Function>;
/// Provide the \c ModuleAnalysisManager to \c Function proxy.
-typedef OuterAnalysisManagerProxy<ModuleAnalysisManager, Function>
- ModuleAnalysisManagerFunctionProxy;
+using ModuleAnalysisManagerFunctionProxy =
+ OuterAnalysisManagerProxy<ModuleAnalysisManager, Function>;
/// \brief Trivial adaptor that maps from a module to its functions.
///
@@ -1274,6 +1294,6 @@ RepeatedPass<PassT> createRepeatedPass(int Count, PassT P) {
return RepeatedPass<PassT>(Count, std::move(P));
}
-}
+} // end namespace llvm
-#endif
+#endif // LLVM_IR_PASSMANAGER_H