[flang-commits] [flang] [flang] Do not honor -fstack-arrays inside offload regions (PR #227537)
via flang-commits
flang-commits at lists.llvm.org
Wed Sep 30 02:07:34 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;
----------------
jeanPerier wrote:
I think it would be more future proof if this logic was under `fir::shouldAllocateOnStack` so that it also impacts other places that may use it to chose between stack and heap in the future.
Right now the op is not always set inside info when called from inlineHLFIRCopy for instance because there is no previous allocation. Maybe fir::AllocationInfo should take a variant of an op to replace or an insertion point where the alloc will be inserted in order to be able to do this kind of context specific overrides.
If this is not straightforward, your solution looks OK to me as this is the only place where -fstack-arrays currently matters.
https://github.com/llvm/llvm-project/pull/227537
More information about the flang-commits
mailing list