[Mlir-commits] [mlir] f050553 - [mlir] Split Dialect::addOperations into two functions

River Riddle llvmlistbot at llvm.org
Wed Sep 30 18:03:23 PDT 2020


Author: River Riddle
Date: 2020-09-30T18:03:14-07:00
New Revision: f0505534900bb1fcdee368136cd733aefd20ce39

URL: https://github.com/llvm/llvm-project/commit/f0505534900bb1fcdee368136cd733aefd20ce39
DIFF: https://github.com/llvm/llvm-project/commit/f0505534900bb1fcdee368136cd733aefd20ce39.diff

LOG: [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.

Added: 
    

Modified: 
    mlir/include/mlir/IR/Dialect.h

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/Dialect.h b/mlir/include/mlir/IR/Dialect.h
index 6395b338bce5..5bd8a745edce 100644
--- a/mlir/include/mlir/IR/Dialect.h
+++ b/mlir/include/mlir/IR/Dialect.h
@@ -150,10 +150,11 @@ class Dialect {
   /// This method is used by derived classes to add their operations to the set.
   ///
   template <typename... Args> void addOperations() {
-    (void)std::initializer_list<int>{
-        0, (addOperation(AbstractOperation::get<Args>(*this)), 0)...};
+    (void)std::initializer_list<int>{0, (addOperation<Args>(), 0)...};
+  }
+  template <typename Arg> void addOperation() {
+    addOperation(AbstractOperation::get<Arg>(*this));
   }
-
   void addOperation(AbstractOperation opInfo);
 
   /// Register a set of type classes with this dialect.


        


More information about the Mlir-commits mailing list