[PATCH] D106148: [NewPM] Fix wrong perfect forwarding in createModuleToFunctionPassAdaptor
Victor Campos via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 16 06:35:50 PDT 2021
vhscampos created this revision.
Herald added a subscriber: dexonsmith.
vhscampos requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Due to missing '&&' in the function argument, it was always taken by
value after template instantiation.
This patch adds the double ampersand to introduce proper perfect
forwarding.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D106148
Files:
llvm/include/llvm/IR/PassManager.h
Index: llvm/include/llvm/IR/PassManager.h
===================================================================
--- llvm/include/llvm/IR/PassManager.h
+++ llvm/include/llvm/IR/PassManager.h
@@ -1206,13 +1206,13 @@
/// 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106148.359306.patch
Type: text/x-patch
Size: 806 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210716/8b62f26c/attachment.bin>
More information about the llvm-commits
mailing list