[flang-commits] [flang] [flang] Adapt PolymorphicOpConversion to run on all top level ops (PR #90597)

Renaud Kauffmann via flang-commits flang-commits at lists.llvm.org
Tue Apr 30 14:48:00 PDT 2024


================
@@ -229,7 +229,9 @@ class PolymorphicOpConversion
 
   void runOnOperation() override {
     auto *context = &getContext();
-    auto mod = getOperation()->getParentOfType<ModuleOp>();
+    auto mod = mlir::dyn_cast_or_null<mlir::ModuleOp>(getOperation());
----------------
Renaud-K wrote:

My plan was to make this pass a module pass and remove the mutex. The reason is that if there are going to be multiple instances of this pass running in parallel on, say, all functions, then the mutex will be effective at preventing races since each instance maintain its own. You would need a shared mutex for that. But a global mutex is not something MLIR allows:
https://mlir.llvm.org/docs/PassManagement/#operation-pass
```
Must not maintain any global mutable state, e.g. static variables within the source file. All mutable state should be maintained by an instance of the pass.
```

So, that was my plan.


https://github.com/llvm/llvm-project/pull/90597


More information about the flang-commits mailing list