================
@@ -208,7 +208,12 @@ class BoxedProcedurePass
       mlir::IRRewriter rewriter(context);
       BoxprocTypeRewriter typeConverter(mlir::UnknownLoc::get(context));
       mlir::Dialect *firDialect = context->getLoadedDialect("fir");
-      getModule().walk([&](mlir::Operation *op) {
+      llvm::SmallVector<mlir::Operation *> operations;
+
+      getModule().walk([&](mlir::Operation *op) { operations.push_back(op); });
----------------
jeanPerier wrote:

Are you sure it is invalid to erase IR in the walk? I understand why 
`opIsValid` is needed and that it was bad to go through the region of erased 
ops, but I think a walk in post order is supposed to allow erasing operations:  
https://github.com/llvm/llvm-project/blob/881df557501d339c7a14b16d68e43da5c732b424/mlir/include/mlir/IR/Operation.h#L767

Is there still a sanitizer issue when introducing `opIsValid` without creating 
the `operations` vector?

I am a bit concerned with copying the pointer of all the module operations into 
a SmallVector. On big Fortran applications with hundred of thousands of line in 
one file, the module will contain millions of operations (I doubt this go above 
the ~500 millions element capacity of the SmallVector), but it may be overkill 
for a pass that is not expected to modify a lot of IR (procedure pointers and 
dummy procedures are usually not all over the place).

https://github.com/llvm/llvm-project/pull/84376
_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to