[flang-commits] [flang] [flang][StackArrays] skip analysis of very large functions (PR #71047)

Kiran Chandramohan via flang-commits flang-commits at lists.llvm.org
Thu Nov 2 05:14:52 PDT 2023


================
@@ -411,6 +417,17 @@ void AllocationAnalysis::processOperation(mlir::Operation *op) {
 mlir::LogicalResult
 StackArraysAnalysisWrapper::analyseFunction(mlir::Operation *func) {
   assert(mlir::isa<mlir::func::FuncOp>(func));
+  size_t nAllocs = 0;
+  func->walk([&nAllocs](fir::AllocMemOp) { nAllocs++; });
+  // don't bother with the analysis if there are no heap allocations
+  if (nAllocs == 0)
+    return mlir::success();
+  if ((maxAllocsPerFunc != 0) && (nAllocs > maxAllocsPerFunc)) {
----------------
kiranchandramohan wrote:

If maxAllocsPerFunc is 0, should the pass run?

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


More information about the flang-commits mailing list