<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/59231>59231</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Flang] Add support for `-fstack-arrays` option
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang:ir
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
            tblah
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          kiranchandramohan
      </td>
    </tr>
</table>

<pre>
    The stack-arrays option is enabled by `gfortran` at `Ofast`. While some of the allocations happen on the stack by default in llvm/flang, in some cases like array-assignments, the memory is allocated in the heap.

Stack arrays has the following definition in the gfortran option help.
```
-fstack-arrays
Adding this option will make the Fortran compiler put all arrays of unknown size and array temporaries onto stack memory. If your program uses very large local arrays it is possible that you will have to extend your runtime limits for stack memory on some operating systems. This flag is enabled by default at optimization level -Ofast unless -fmax-stack-var-size is specified.
```

Note: This came out of the discussion regarding `Ofast` in https://discourse.llvm.org/t/rfc-the-meaning-of-ofast/66554
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxtk0-PmzAQxT8NXCwQ_0KSA4e0q0i9tIeu1PMAA0xjbGSb7GY_fcdA0t3VSgSCgTfPv3lT6_ZWPQ8orIPmEoExcLNCT460EmQFKqgltqK-iaBM-k4bZ0DxXwHOr_zqwDq-xuLPQJJl9IhCd8KxJEipG_BKVgwwTagEi7p7Ma_ZYgezdIKUkPI6Btm5k6D6IPvulxaxBixaIenCgt5dBNZSr0ZUzvr3vN6IozY373eryY5pLTUgTHGQPAXJaT3_XmpvGx3ALm91mr97IdV7R6Ro3f6qcN_0ncqA8qFYJtux3Ebde4rr2qltvawb6IH1haQUI_CGvPx5U2_0ODFBI6bZ-W3cLTLMWV2UfmEe9MYQVLs-Eg7HSRswxHy0cnrDusKIxY9O3PTMekb3BkYxe45XZE4STI_Cg3pUIefpTZrZcr_ZGLeXv169DnDlJS3w1SFXX1TNrBxxeySN5CwDNB_K-06vWZjQcAYYgb1Zdmxj8exZcJ_7TwG7h4FLe1IjvS3hERKvKEW0RI1ZSLRWRN0Ir9GK-womWtCwnJ2woY6w_bpD6_mndhjkp9VIA94lM99S25JtZsbAhQ32YJb2vUu6j8Xg3GRZgfPKh_-CkViMfYZjbTi_Z8c_0zURS0YjgmKVSHd8eJXsXJa7XRFilZblscyLtDiGbZW3x_wIoSMnsQp2387LLOyeBIdI2HnibruFNNv4lDX2taYrnI2sPvrryQ1zHXPA-GYbM3-JOBl_sfF2yNoZeZzOu2OWp-FQJW3RZHVel2ldpN0-gXZfJMdDCW2dp_uiDSXUKK13GWTZOrT5iQzfsOGQqizJsjTNDmma7oo8TtNDXWNzTLLmsNs3dVAkOALJB7LQVIuneu4tP5Rknf3_cJ15xK2eqyUMWymY3aBNdSEeombg6eCsa76Gy56qZUP_ABoZq3U">