[llvm-branch-commits] [mlir] 7d746b3 - [mlir][PDL] Forward captured single entity constraint functions instead of copy-capture
River Riddle via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Dec 1 21:13:58 PST 2020
Author: River Riddle
Date: 2020-12-01T21:08:34-08:00
New Revision: 7d746b390c6e3b9b4eded3eb84e5973a1b689775
URL: https://github.com/llvm/llvm-project/commit/7d746b390c6e3b9b4eded3eb84e5973a1b689775
DIFF: https://github.com/llvm/llvm-project/commit/7d746b390c6e3b9b4eded3eb84e5973a1b689775.diff
LOG: [mlir][PDL] Forward captured single entity constraint functions instead of copy-capture
Added:
Modified:
mlir/include/mlir/IR/PatternMatch.h
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/PatternMatch.h b/mlir/include/mlir/IR/PatternMatch.h
index 4fdc0878c590..0bbb2216ee7b 100644
--- a/mlir/include/mlir/IR/PatternMatch.h
+++ b/mlir/include/mlir/IR/PatternMatch.h
@@ -355,12 +355,14 @@ class PDLPatternModule {
std::enable_if_t<!llvm::is_invocable<SingleEntityFn, ArrayRef<PDLValue>,
ArrayAttr, PatternRewriter &>::value>
registerConstraintFunction(StringRef name, SingleEntityFn &&constraintFn) {
- registerConstraintFunction(name, [=](ArrayRef<PDLValue> values,
- ArrayAttr constantParams,
- PatternRewriter &rewriter) {
- assert(values.size() == 1 && "expected values to have a single entity");
- return constraintFn(values[0], constantParams, rewriter);
- });
+ registerConstraintFunction(
+ name, [constraintFn = std::forward<SingleEntityFn>(constraintFn)](
+ ArrayRef<PDLValue> values, ArrayAttr constantParams,
+ PatternRewriter &rewriter) {
+ assert(values.size() == 1 &&
+ "expected values to have a single entity");
+ return constraintFn(values[0], constantParams, rewriter);
+ });
}
/// Register a creation function.
More information about the llvm-branch-commits
mailing list