| 1 |
// Test that FIR codegen handles cases when free and malloc have |
| 2 |
// already been defined in FIR (either by the user in Fortran via |
| 3 |
// BIND(C) or by some FIR pass in between). |
| 4 |
// RUN: fir-opt --fir-to-llvm-ir %s | FileCheck %s |
| 5 |
|
| 6 |
|
| 7 |
func.func @already_declared_free_malloc() { |
| 8 |
%c4 = arith.constant 4 : index |
| 9 |
%0 = fir.call @malloc(%c4) : (index) -> !fir.heap<i32> |
| 10 |
fir.call @free(%0) : (!fir.heap<i32>) -> () |
| 11 |
%1 = fir.allocmem i32 |
| 12 |
fir.freemem %1 : !fir.heap<i32> |
| 13 |
return |
| 14 |
} |
| 15 |
|
| 16 |
// CHECK: llvm.call @malloc(%{{.*}}) |
| 17 |
// CHECK: llvm.call @free(%{{.*}}) |
| 18 |
// CHECK: llvm.call @malloc(%{{.*}}) |
| 19 |
// CHECK: llvm.call @free(%{{.*}}) |
| 20 |
|
| 21 |
func.func private @free(!fir.heap<i32>) |
| 22 |
func.func private @malloc(index) -> !fir.heap<i32> |