[flang-commits] [flang] [flang] Do not honor -fstack-arrays inside offload regions (PR #227537)

Zhen Wang via flang-commits flang-commits at lists.llvm.org
Wed Sep 30 09:56:35 PDT 2026


================
@@ -207,12 +213,19 @@ void AllocationPlacementPass::runOnOperation() {
                : (allocmem.hasLenParams() || allocmem.hasShapeOperands());
     info.byteSize = getConstantByteSize(op, dl, kindMap);
 
+    // -fstack-arrays cannot be honored in an offload region either: like a
+    // device procedure, it runs on the device stack, which is far smaller than
+    // the host one. The size based part of the policy still applies.
+    fir::AllocationPolicy policy = basePolicy;
+    if (policy.stackArrays && cuf::isExecutingOnDevice(op))
+      policy.stackArrays = false;
----------------
wangzpgi wrote:

Agreed, that is a better solution. I am planning to do it as a follow-up change, and keep this one as is for now.

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


More information about the flang-commits mailing list