Debian Codegraph @

flang/test/Lower/OpenMP/cfg-conversion-omp.private.f90

raw
1 ! Tests that CFG & LLVM conversion is applied to `omp.private` ops.
2
3 ! RUN: split-file %s %t && cd %t
4
5 ! RUN: %flang_fc1 -emit-hlfir -fopenmp -mmlir --openmp-enable-delayed-privatization \
6 ! RUN: -o - test.f90 2>&1 | \
7 ! RUN: fir-opt --cfg-conversion -o test.cfg-conv.mlir
8 ! RUN: FileCheck --input-file=test.cfg-conv.mlir %s --check-prefix="CFGConv"
9
10 ! RUN: fir-opt --convert-hlfir-to-fir --cg-rewrite --fir-to-llvm-ir test.cfg-conv.mlir -o - | \
11 ! RUN: FileCheck %s --check-prefix="LLVMDialect"
12
13 !--- test.f90
14 subroutine delayed_privatization_allocatable
15 implicit none
16 integer, allocatable :: var1
17
18 !$omp parallel private(var1)
19 var1 = 10
20 !$omp end parallel
21 end subroutine
22
23 ! CFGConv-LABEL: omp.private {type = private}
24 ! CFGConv-SAME: @[[PRIVATIZER_SYM:.*]] : [[TYPE:!fir.ref<!fir.box<!fir.heap<i32>>>]] alloc {
25
26 ! CFGConv-NEXT: ^bb0(%[[PRIV_ARG:.*]]: [[TYPE]]):
27
28 ! CFGConv-NEXT: %[[PRIV_ALLOC:.*]] = fir.alloca !fir.box<!fir.heap<i32>> {bindc_name = "var1", pinned, uniq_name = "_QFdelayed_privatization_allocatableEvar1"}
29
30 ! CFGConv-NEXT: %[[PRIV_ARG_VAL:.*]] = fir.load %[[PRIV_ARG]] : !fir.ref<!fir.box<!fir.heap<i32>>>
31 ! CFGConv-NEXT: %[[PRIV_ARG_BOX:.*]] = fir.box_addr %[[PRIV_ARG_VAL]] : (!fir.box<!fir.heap<i32>>) -> !fir.heap<i32>
32 ! CFGConv-NEXT: %[[PRIV_ARG_ADDR:.*]] = fir.convert %[[PRIV_ARG_BOX]] : (!fir.heap<i32>) -> i64
33 ! CFGConv-NEXT: %[[C0:.*]] = arith.constant 0 : i64
34 ! CFGConv-NEXT: %[[ALLOC_COND:.*]] = arith.cmpi ne, %[[PRIV_ARG_ADDR]], %[[C0]] : i64
35 ! CFGConv-NEXT: cf.cond_br %[[ALLOC_COND]], ^[[ALLOC_MEM_BB:.*]], ^[[ZERO_MEM_BB:.*]]
36 ! CFGConv-NEXT: ^[[ALLOC_MEM_BB]]:
37 ! CFGConv: fir.allocmem
38 ! CFGConv: cf.br ^[[DECL_BB:.*]]
39 ! CFGConv: ^[[ZERO_MEM_BB]]:
40 ! CFGConv-NEXT: fir.zero_bits
41 ! CFGConv: cf.br ^[[DECL_BB:.*]]
42 ! CFGConv-NEXT: ^[[DECL_BB]]:
43 ! CFGConv-NEXT: hlfir.declare
44 ! CFGConv-NEXT: omp.yield
45
46
47 ! LLVMDialect-LABEL: omp.private {type = private}
48 ! LLVMDialect-SAME: @[[PRIVATIZER_SYM:.*]] : [[TYPE:!llvm.ptr]] alloc {
49
50 ! LLVMDialect-NEXT: ^bb0(%[[PRIV_ARG:.*]]: [[TYPE]]):
51 ! LLVMDialect: llvm.alloca
52 ! LLVMDialect: llvm.call @malloc
53
54 ! LLVMDialect-NOT: hlfir.declare