[flang-commits] [flang] [mlir] [flang][OpenMP] - Add `MapInfoOp` instances for target private variables when needed (PR #109862)
Kareem Ergawy via flang-commits
flang-commits at lists.llvm.org
Fri Oct 4 01:48:17 PDT 2024
================
@@ -0,0 +1,83 @@
+// RUN: fir-opt --split-input-file --omp-maps-for-privatized-symbols %s | FileCheck %s
+module attributes {omp.is_target_device = false} {
+ omp.private {type = private} @_QFtarget_simpleEsimple_var_private_ref_box_heap_i32 : !fir.ref<!fir.box<!fir.heap<i32>>> alloc {
+ ^bb0(%arg0: !fir.ref<!fir.box<!fir.heap<i32>>>):
+ %0 = fir.alloca !fir.box<!fir.heap<i32>> {bindc_name = "simple_var", pinned, uniq_name = "_QFtarget_simpleEsimple_var"}
+ %1 = fir.load %arg0 : !fir.ref<!fir.box<!fir.heap<i32>>>
+ %2 = fir.box_addr %1 : (!fir.box<!fir.heap<i32>>) -> !fir.heap<i32>
+ %3 = fir.convert %2 : (!fir.heap<i32>) -> i64
+ %c0_i64 = arith.constant 0 : i64
+ %4 = arith.cmpi ne, %3, %c0_i64 : i64
+ fir.if %4 {
+ %6 = fir.load %arg0 : !fir.ref<!fir.box<!fir.heap<i32>>>
+ %7 = fir.box_addr %6 : (!fir.box<!fir.heap<i32>>) -> !fir.heap<i32>
+ %8 = fir.allocmem i32 {fir.must_be_heap = true, uniq_name = "_QFtarget_simpleEsimple_var.alloc"}
+ %9 = fir.embox %8 : (!fir.heap<i32>) -> !fir.box<!fir.heap<i32>>
+ fir.store %9 to %0 : !fir.ref<!fir.box<!fir.heap<i32>>>
+ } else {
+ %6 = fir.zero_bits !fir.heap<i32>
+ %7 = fir.embox %6 : (!fir.heap<i32>) -> !fir.box<!fir.heap<i32>>
+ fir.store %7 to %0 : !fir.ref<!fir.box<!fir.heap<i32>>>
+ }
+ %5:2 = hlfir.declare %0 {fortran_attrs = #fir.var_attrs<allocatable>, uniq_name = "_QFtarget_simpleEsimple_var"} : (!fir.ref<!fir.box<!fir.heap<i32>>>) -> (!fir.ref<!fir.box<!fir.heap<i32>>>, !fir.ref<!fir.box<!fir.heap<i32>>>)
+ omp.yield(%5#0 : !fir.ref<!fir.box<!fir.heap<i32>>>)
+ } dealloc {
+ ^bb0(%arg0: !fir.ref<!fir.box<!fir.heap<i32>>>):
----------------
ergawy wrote:
nit: this region can be left empty to simplify the test.
https://github.com/llvm/llvm-project/pull/109862
More information about the flang-commits
mailing list