[flang-commits] [flang] [flang] fix early free of allocatable function result in WHERE mask (PR #178691)

Eugene Epshteyn via flang-commits flang-commits at lists.llvm.org
Fri Jan 30 07:54:46 PST 2026


================
@@ -1973,17 +1983,24 @@ genUserCall(Fortran::lower::PreparedActualArguments &loweredActuals,
   if (!resultIsFinalized) {
     hlfir::Entity resultEntity = extendedValueToHlfirEntity(
         loc, builder, result, tempResultName, /*insertBefore=*/callOp);
+    // Allocatable result must be freed, other results are stack allocated.
+    const auto *allocatable = result.getBoxOf<fir::MutableBoxValue>();
+    bool mustFree = allocatable != nullptr;
----------------
eugeneepshteyn wrote:

The way it's used, could probably do `const bool`.

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


More information about the flang-commits mailing list