1 // RUN: fir-opt --memory-allocation-opt="dynamic-array-on-heap=true maximum-array-alloc-size=1024" %s | FileCheck %s
3 // Test for size of array being too big.
5 // CHECK-LABEL: func @_QPs1(
6 // CHECK: %[[mem:.*]] = fir.allocmem !fir.array<1000123xi32> {bindc_name = "array", uniq_name = "_QFs1Earray"}
7 // CHECK: fir.call @_QPs3(
8 // CHECK: fir.freemem %[[mem]]
12 %0 = fir.alloca !fir.array<1000123xi32> {bindc_name = "array", uniq_name = "_QFs1Earray"}
13 fir.call @_QPs3(%0) : (!fir.ref<!fir.array<1000123xi32>>) -> ()
17 // Test for dynamic array.
19 // CHECK-LABEL: func @_QPs2(
20 // CHECK: %[[mem:.*]] = fir.allocmem !fir.array<?xi32>, %{{[0-9]+}} {bindc_name = "array", uniq_name = "_QFs2Earray"}
21 // CHECK: fir.call @_QPs3(
22 // CHECK: fir.freemem %[[mem]]
25 func.func @_QPs2(%arg0: !fir.ref<i32>) {
26 %0 = fir.load %arg0 : !fir.ref<i32>
27 %1 = fir.convert %0 : (i32) -> index
28 %2 = fir.alloca !fir.array<?xi32>, %1 {bindc_name = "array", uniq_name = "_QFs2Earray"}
29 %3 = fir.convert %2 : (!fir.ref<!fir.array<?xi32>>) -> !fir.ref<!fir.array<1000123xi32>>
30 fir.call @_QPs3(%3) : (!fir.ref<!fir.array<1000123xi32>>) -> ()
33 func.func private @_QPs3(!fir.ref<!fir.array<1000123xi32>>)