[llvm-branch-commits] [flang] [flang][hlfir] optimize hlfir.eval_in_mem bufferization (PR #118069)

Tom Eccles via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Nov 29 04:05:31 PST 2024


================
@@ -1108,6 +1108,113 @@ class ReductionMaskConversion : public mlir::OpRewritePattern<Op> {
   }
 };
 
+class EvaluateIntoMemoryAssignBufferization
+    : public mlir::OpRewritePattern<hlfir::EvaluateInMemoryOp> {
+
+public:
+  using mlir::OpRewritePattern<hlfir::EvaluateInMemoryOp>::OpRewritePattern;
+
+  llvm::LogicalResult
+  matchAndRewrite(hlfir::EvaluateInMemoryOp,
+                  mlir::PatternRewriter &rewriter) const override;
+};
+
+static bool mayReadOrWrite(mlir::Region &region, mlir::Value var) {
----------------
tblah wrote:

Please could you add documentation explaining that the side effects you are interested in cannot be modeled by `mlir::MemoryEffectOpInterface`. Without that information this function is surprising because it is checking mlir memory effect interfaces but without using the read or write effects from that interface (instead using the alias analysis to determine memory effects).

Maybe we need something in the name to make is clear this uses the high-cost high-precision model as a fallback when more precision is needed than just querying the mlir memory effects. Perhaps `mayReadOrWriteAA`.

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


More information about the llvm-branch-commits mailing list