bolt/deps/llvm-18.1.8/flang/test/Fir/already-defined-free.fir
2025-02-14 19:21:04 +01:00

22 lines
714 B
Text

// Test that FIR codegen handles cases when free and malloc have
// already been defined in FIR (either by the user in Fortran via
// BIND(C) or by some FIR pass in between).
// RUN: fir-opt --fir-to-llvm-ir %s | FileCheck %s
func.func @already_declared_free_malloc() {
%c4 = arith.constant 4 : index
%0 = fir.call @malloc(%c4) : (index) -> !fir.heap<i32>
fir.call @free(%0) : (!fir.heap<i32>) -> ()
%1 = fir.allocmem i32
fir.freemem %1 : !fir.heap<i32>
return
}
// CHECK: llvm.call @malloc(%{{.*}})
// CHECK: llvm.call @free(%{{.*}})
// CHECK: llvm.call @malloc(%{{.*}})
// CHECK: llvm.call @free(%{{.*}})
func.func private @free(!fir.heap<i32>)
func.func private @malloc(index) -> !fir.heap<i32>