/// templated adaptor.
template <typename CGSCCPassT>
ModuleToPostOrderCGSCCPassAdaptor
-createModuleToPostOrderCGSCCPassAdaptor(CGSCCPassT Pass) {
+createModuleToPostOrderCGSCCPassAdaptor(CGSCCPassT &&Pass) {
using PassModelT = detail::PassModel<LazyCallGraph::SCC, CGSCCPassT,
PreservedAnalyses, CGSCCAnalysisManager,
LazyCallGraph &, CGSCCUpdateResult &>;
return ModuleToPostOrderCGSCCPassAdaptor(
- std::make_unique<PassModelT>(std::move(Pass)));
+ std::make_unique<PassModelT>(std::forward<CGSCCPassT>(Pass)));
}
/// A proxy from a \c FunctionAnalysisManager to an \c SCC.
/// templated adaptor.
template <typename FunctionPassT>
CGSCCToFunctionPassAdaptor
-createCGSCCToFunctionPassAdaptor(FunctionPassT Pass) {
+createCGSCCToFunctionPassAdaptor(FunctionPassT &&Pass) {
using PassModelT =
detail::PassModel<Function, FunctionPassT, PreservedAnalyses,
FunctionAnalysisManager>;
return CGSCCToFunctionPassAdaptor(
- std::make_unique<PassModelT>(std::move(Pass)));
+ std::make_unique<PassModelT>(std::forward<FunctionPassT>(Pass)));
}
/// A helper that repeats an SCC pass each time an indirect call is refined to
/// A function to deduce a function pass type and wrap it in the
/// templated adaptor.
template <typename CGSCCPassT>
-DevirtSCCRepeatedPass createDevirtSCCRepeatedPass(CGSCCPassT Pass,
+DevirtSCCRepeatedPass createDevirtSCCRepeatedPass(CGSCCPassT &&Pass,
int MaxIterations) {
using PassModelT = detail::PassModel<LazyCallGraph::SCC, CGSCCPassT,
PreservedAnalyses, CGSCCAnalysisManager,
LazyCallGraph &, CGSCCUpdateResult &>;
- return DevirtSCCRepeatedPass(std::make_unique<PassModelT>(std::move(Pass)),
- MaxIterations);
+ return DevirtSCCRepeatedPass(
+ std::make_unique<PassModelT>(std::forward<CGSCCPassT>(Pass)),
+ MaxIterations);
}
// Clear out the debug logging macro.
template <typename PassT>
std::enable_if_t<!std::is_same<PassT, PassManager>::value>
- addPass(PassT Pass) {
+ addPass(PassT &&Pass) {
using PassModelT =
detail::PassModel<IRUnitT, PassT, PreservedAnalyses, AnalysisManagerT,
ExtraArgTs...>;
- Passes.emplace_back(new PassModelT(std::move(Pass)));
+ Passes.emplace_back(new PassModelT(std::forward<PassT>(Pass)));
}
/// When adding a pass manager pass that has the same type as this pass
/// templated adaptor.
template <typename FunctionPassT>
ModuleToFunctionPassAdaptor
-createModuleToFunctionPassAdaptor(FunctionPassT Pass) {
+createModuleToFunctionPassAdaptor(FunctionPassT &&Pass) {
using PassModelT =
detail::PassModel<Function, FunctionPassT, PreservedAnalyses,
FunctionAnalysisManager>;
return ModuleToFunctionPassAdaptor(
- std::make_unique<PassModelT>(std::move(Pass)));
+ std::make_unique<PassModelT>(std::forward<FunctionPassT>(Pass)));
}
/// A utility pass template to force an analysis result to be available.
template <typename PassT>
class RepeatedPass : public PassInfoMixin<RepeatedPass<PassT>> {
public:
- RepeatedPass(int Count, PassT P) : Count(Count), P(std::move(P)) {}
+ RepeatedPass(int Count, PassT &&P)
+ : Count(Count), P(std::forward<PassT>(P)) {}
template <typename IRUnitT, typename AnalysisManagerT, typename... Ts>
PreservedAnalyses run(IRUnitT &IR, AnalysisManagerT &AM, Ts &&... Args) {
};
template <typename PassT>
-RepeatedPass<PassT> createRepeatedPass(int Count, PassT P) {
- return RepeatedPass<PassT>(Count, std::move(P));
+RepeatedPass<PassT> createRepeatedPass(int Count, PassT &&P) {
+ return RepeatedPass<PassT>(Count, std::forward<PassT>(P));
}
} // end namespace llvm
/// passes in the pass manager later.
template <typename PassT>
std::enable_if_t<is_detected<HasRunOnLoopT, PassT>::value>
- addPass(PassT Pass) {
+ addPass(PassT &&Pass) {
using LoopPassModelT =
detail::PassModel<Loop, PassT, PreservedAnalyses, LoopAnalysisManager,
LoopStandardAnalysisResults &, LPMUpdater &>;
IsLoopNestPass.push_back(false);
- LoopPasses.emplace_back(new LoopPassModelT(std::move(Pass)));
+ LoopPasses.emplace_back(new LoopPassModelT(std::forward<PassT>(Pass)));
}
template <typename PassT>
std::enable_if_t<!is_detected<HasRunOnLoopT, PassT>::value>
- addPass(PassT Pass) {
+ addPass(PassT &&Pass) {
using LoopNestPassModelT =
detail::PassModel<LoopNest, PassT, PreservedAnalyses,
LoopAnalysisManager, LoopStandardAnalysisResults &,
LPMUpdater &>;
IsLoopNestPass.push_back(true);
- LoopNestPasses.emplace_back(new LoopNestPassModelT(std::move(Pass)));
+ LoopNestPasses.emplace_back(
+ new LoopNestPassModelT(std::forward<PassT>(Pass)));
}
// Specializations of `addPass` for `RepeatedPass`. These are necessary since
// detection of `HasRunOnLoopT`.
template <typename PassT>
std::enable_if_t<is_detected<HasRunOnLoopT, PassT>::value>
- addPass(RepeatedPass<PassT> Pass) {
+ addPass(RepeatedPass<PassT> &&Pass) {
using RepeatedLoopPassModelT =
detail::PassModel<Loop, RepeatedPass<PassT>, PreservedAnalyses,
LoopAnalysisManager, LoopStandardAnalysisResults &,
template <typename PassT>
std::enable_if_t<!is_detected<HasRunOnLoopT, PassT>::value>
- addPass(RepeatedPass<PassT> Pass) {
+ addPass(RepeatedPass<PassT> &&Pass) {
using RepeatedLoopNestPassModelT =
detail::PassModel<LoopNest, RepeatedPass<PassT>, PreservedAnalyses,
LoopAnalysisManager, LoopStandardAnalysisResults &,
template <typename LoopPassT>
inline std::enable_if_t<is_detected<HasRunOnLoopT, LoopPassT>::value,
FunctionToLoopPassAdaptor>
-createFunctionToLoopPassAdaptor(LoopPassT Pass, bool UseMemorySSA = false,
+createFunctionToLoopPassAdaptor(LoopPassT &&Pass, bool UseMemorySSA = false,
bool UseBlockFrequencyInfo = false) {
using PassModelT =
detail::PassModel<Loop, LoopPassT, PreservedAnalyses, LoopAnalysisManager,
LoopStandardAnalysisResults &, LPMUpdater &>;
return FunctionToLoopPassAdaptor(
- std::make_unique<PassModelT>(std::move(Pass)), UseMemorySSA,
+ std::make_unique<PassModelT>(std::forward<LoopPassT>(Pass)), UseMemorySSA,
UseBlockFrequencyInfo, false);
}
template <typename LoopNestPassT>
inline std::enable_if_t<!is_detected<HasRunOnLoopT, LoopNestPassT>::value,
FunctionToLoopPassAdaptor>
-createFunctionToLoopPassAdaptor(LoopNestPassT Pass, bool UseMemorySSA = false,
+createFunctionToLoopPassAdaptor(LoopNestPassT &&Pass, bool UseMemorySSA = false,
bool UseBlockFrequencyInfo = false) {
LoopPassManager LPM;
- LPM.addPass(std::move(Pass));
+ LPM.addPass(std::forward<LoopNestPassT>(Pass));
using PassModelT =
detail::PassModel<Loop, LoopPassManager, PreservedAnalyses,
LoopAnalysisManager, LoopStandardAnalysisResults &,
/// be in loop-nest mode if the pass manager contains only loop-nest passes.
template <>
inline FunctionToLoopPassAdaptor
-createFunctionToLoopPassAdaptor<LoopPassManager>(LoopPassManager LPM,
+createFunctionToLoopPassAdaptor<LoopPassManager>(LoopPassManager &&LPM,
bool UseMemorySSA,
bool UseBlockFrequencyInfo) {
// Check if LPM contains any loop pass and if it does not, returns an adaptor