brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.8 KiB · 0ee9230 Raw
74 lines · plain
1// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s2 3llvm.func @alloc_foo_1(!llvm.ptr)4llvm.func @dealloc_foo_1(!llvm.ptr)5 6omp.private {type = private} @box.heap_privatizer : !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)> init {7^bb0(%arg0: !llvm.ptr, %arg1 : !llvm.ptr):8  llvm.call @alloc_foo_1(%arg0) : (!llvm.ptr) -> ()9  omp.yield(%arg1 : !llvm.ptr)10} dealloc {11// There is no reason for the dealloc region here to have two blocks.12// But a multi-block test is useful in checking that the OMPIRBuilder13// has updated the InsertPoint properly after translating the dealloc14// region to LLVMIR.15// See https://github.com/llvm/llvm-project/issues/129202 for more16// context17^bb0(%arg0: !llvm.ptr):18  llvm.br ^bb119^bb1:20  llvm.call @dealloc_foo_1(%arg0) : (!llvm.ptr) -> ()21  omp.yield22}23 24llvm.func @target_allocatable_(%arg0: !llvm.ptr {fir.bindc_name = "lb"}, %arg1: !llvm.ptr {fir.bindc_name = "ub"}, %arg2: !llvm.ptr {fir.bindc_name = "l"}) attributes {fir.internal_name = "_QPtarget_allocatable"} {25  %0 = llvm.mlir.constant(1 : i32) : i3226  %1 = llvm.alloca %0 x !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)> {alignment = 8 : i64} : (i32) -> !llvm.ptr27  %3 = llvm.alloca %0 x !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)> {alignment = 8 : i64} : (i32) -> !llvm.ptr28  %4 = llvm.mlir.constant(1 : i64) : i6429  %5 = llvm.alloca %4 x f32 {bindc_name = "real_var"} : (i64) -> !llvm.ptr30  %7 = llvm.alloca %4 x i32 {bindc_name = "mapped_var"} : (i64) -> !llvm.ptr31  %9 = llvm.alloca %4 x !llvm.struct<(f32, f32)> {bindc_name = "comp_var"} : (i64) -> !llvm.ptr32  %11 = llvm.alloca %0 x !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)> {alignment = 8 : i64} : (i32) -> !llvm.ptr33  %13 = llvm.alloca %4 x !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)> {bindc_name = "alloc_var"} : (i64) -> !llvm.ptr34  %39 = llvm.load %arg2 : !llvm.ptr -> i6435  %52 = llvm.alloca %39 x f32 {bindc_name = "real_arr"} : (i64) -> !llvm.ptr36  %53 = omp.map.info var_ptr(%7 : !llvm.ptr, i32) map_clauses(implicit, exit_release_or_enter_alloc) capture(ByCopy) -> !llvm.ptr {name = "mapped_var"}37  %54 = omp.map.info var_ptr(%13 : !llvm.ptr, !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)>) map_clauses(to) capture(ByRef) -> !llvm.ptr38  omp.target map_entries(%53 -> %arg3, %54 -> %arg4 : !llvm.ptr, !llvm.ptr) private(@box.heap_privatizer %13 -> %arg5 [map_idx=1] : !llvm.ptr) {39    llvm.call @use_private_var(%arg5) : (!llvm.ptr) -> ()40    omp.terminator41  }42  llvm.return43}44 45llvm.func @use_private_var(!llvm.ptr) -> ()46 47llvm.func @_FortranAAssign(!llvm.ptr, !llvm.ptr, !llvm.ptr, i32) -> !llvm.struct<()> attributes {fir.runtime, sym_visibility = "private"}48 49// The first set of checks ensure that we are calling the offloaded function50// with the right arguments, especially the second argument which needs to51// be a memory reference to the descriptor for the privatized allocatable52// CHECK: define void @target_allocatable_53// CHECK-NOT: define internal void54// CHECK: %[[DESC_ALLOC:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8 }, i64 155// CHECK: call void @__omp_offloading_[[OFFLOADED_FUNCTION:.*]](ptr {{[^,]+}},56// CHECK-SAME: ptr %[[DESC_ALLOC]])57 58// The second set of checks ensure that to allocate memory for the59// allocatable, we are, in fact, using the memory reference of the descriptor60// passed as the second argument to the offloaded function.61// CHECK: define internal void @__omp_offloading_[[OFFLOADED_FUNCTION]]62// CHECK-SAME: (ptr {{[^,]+}}, ptr %[[DESCRIPTOR_ARG:.*]]) {63// CHECK: %[[DESC_TO_DEALLOC:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8 }64// CHECK: call void @alloc_foo_1(ptr %[[DESCRIPTOR_ARG]])65 66 67// CHECK: call void @use_private_var(ptr %[[DESC_TO_DEALLOC]]68 69// Now, check the deallocation of the private var.70// CHECK:  call void @dealloc_foo_1(ptr %[[DESC_TO_DEALLOC]])71// CHECK-NEXT: br label %[[CONT_BLOCK:.*]]72// CHECK: [[CONT_BLOCK]]:73// CHECK-NEXT: ret void74