From f0505534900bb1fcdee368136cd733aefd20ce39 Mon Sep 17 00:00:00 2001 From: River Riddle Date: Wed, 30 Sep 2020 17:23:11 -0700 Subject: [PATCH] [mlir] Split Dialect::addOperations into two functions The current implementation uses a fold expression to add all of the operations at once. This is really nice, but apparently the lifetime of each of the AbstractOperation instances is for the entire expression which may lead to a stack overflow for large numbers of operations. This splits the method in two to allow for the lifetime of the AbstractOperation to be properly scoped. --- mlir/include/mlir/IR/Dialect.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mlir/include/mlir/IR/Dialect.h b/mlir/include/mlir/IR/Dialect.h index 6395b33..5bd8a74 100644 --- a/mlir/include/mlir/IR/Dialect.h +++ b/mlir/include/mlir/IR/Dialect.h @@ -150,10 +150,11 @@ protected: /// This method is used by derived classes to add their operations to the set. /// template void addOperations() { - (void)std::initializer_list{ - 0, (addOperation(AbstractOperation::get(*this)), 0)...}; + (void)std::initializer_list{0, (addOperation(), 0)...}; + } + template void addOperation() { + addOperation(AbstractOperation::get(*this)); } - void addOperation(AbstractOperation opInfo); /// Register a set of type classes with this dialect. -- 2.7.4