Debian Codegraph @

flang/test/Fir/alloc-32.fir

raw
1 // RUN: %flang_fc1 -triple i686 -emit-llvm %s -o - | FileCheck %s
2 // REQUIRES: x86-registered-target
3
4 // This is a check for calling malloc using i32 when on a 32-bit target (only).
5 // It doesn't contain the comprehensive tests that alloc.fir has, and
6 // that file should be used to exercise most code paths.
7
8 module attributes {
9 fir.defaultkind = "a1c4d8i4l4r4", fir.kindmap = "", llvm.target_triple = "i686"
10 } {
11
12 // CHECK-LABEL: define ptr @allocmem_scalar_nonchar(
13 // CHECK: call ptr @malloc(i32 4)
14 func.func @allocmem_scalar_nonchar() -> !fir.heap<i32> {
15 %1 = fir.allocmem i32
16 return %1 : !fir.heap<i32>
17 }
18
19 // CHECK-LABEL: define ptr @allocmem_scalar_dynchar(
20 // CHECK-SAME: i32 %[[len:.*]])
21 // CHECK: %[[mul1:.*]] = sext i32 %[[len]] to i64
22 // CHECK: %[[mul2:.*]] = mul i64 1, %[[mul1]]
23 // CHECK: %[[trunc:.*]] = trunc i64 %[[mul2]] to i32
24 // CHECK: call ptr @malloc(i32 %[[trunc]])
25 func.func @allocmem_scalar_dynchar(%l : i32) -> !fir.heap<!fir.char<1,?>> {
26 %1 = fir.allocmem !fir.char<1,?>(%l : i32)
27 return %1 : !fir.heap<!fir.char<1,?>>
28 }
29
30 }