[all-commits] [llvm/llvm-project] 2a6bd2: [flang][cuda] do not honor -fstack-arrays in devic...
Zhen Wang via All-commits
all-commits at lists.llvm.org
Mon Sep 14 10:31:28 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 2a6bd296a0e90bd579ec1874c964781916ec26e9
https://github.com/llvm/llvm-project/commit/2a6bd296a0e90bd579ec1874c964781916ec26e9
Author: Zhen Wang <zhenw at nvidia.com>
Date: 2026-09-14 (Mon, 14 Sep 2026)
Changed paths:
M flang/include/flang/Optimizer/Support/AllocationPolicy.h
M flang/lib/Lower/CallInterface.cpp
M flang/lib/Optimizer/Support/AllocationPolicy.cpp
M flang/lib/Optimizer/Transforms/AllocationPlacement.cpp
M flang/lib/Optimizer/Transforms/StackArrays.cpp
M flang/test/Lower/CUDA/cuda-allocatable.cuf
A flang/test/Lower/CUDA/cuda-allocation-policy.cuf
M flang/test/Lower/CUDA/cuda-atomicadd.cuf
M flang/test/Lower/CUDA/cuda-cdevloc.cuf
M flang/test/Lower/CUDA/cuda-cluster.cuf
M flang/test/Lower/CUDA/cuda-device-proc.cuf
M flang/test/Lower/CUDA/cuda-mod.cuf
M flang/test/Lower/CUDA/cuda-module-use.cuf
M flang/test/Lower/CUDA/cuda-proc-attribute.cuf
M flang/test/Lower/CUDA/cuda-shared.cuf
M flang/test/Lower/CUDA/cuda-synchronization.cuf
M flang/test/Transforms/allocation-policy-precedence.fir
A flang/test/Transforms/stack-arrays-policy-opt-out.fir
Log Message:
-----------
[flang][cuda] do not honor -fstack-arrays in device procedures (#223040)
The device stack is far smaller than the host one, so an automatic array
that fits the host stack easily overflows it. With `-fstack-arrays`
(implied by `-Ofast`) automatic arrays in CUDA Fortran `global` and
`device` procedures were kept on the device stack and overflowed it at
runtime.
Lowering now records a `fir.allocation_policy` with `stack_arrays`
disabled on those procedures, and `getAllocationPolicy` honors a policy
on the enclosing function instead of only the one on the module. The
size based part of the policy is unchanged, so small constant size
arrays still go on the device stack. Host procedures, including the host
copy of `attributes(host,device)`, are unaffected.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list