[flang-commits] [flang] [OpenMP][Flang] Add "IsolatedFromAbove" trait to omp.target (PR #67164)

Akash Banerjee via flang-commits flang-commits at lists.llvm.org
Mon Oct 16 10:28:13 PDT 2023


================
@@ -1144,14 +1144,13 @@ def DataBoundsOp : OpenMP_Op<"bounds",
 }
 
 def MapInfoOp : OpenMP_Op<"map_info", [AttrSizedOperandSegments]> {
-  let arguments = (ins OpenMP_PointerLikeType:$var_ptr,
-                       Optional<OpenMP_PointerLikeType>:$var_ptr_ptr,
+  let arguments = (ins AnyTypeOf<[IntLikeType, Index, OpenMP_PointerLikeType]>:$var_ptr,
----------------
TIFitis wrote:

Sorry this is not resolved, please consider the following C code.

```
void foo(int n){
  int a[n][1024];
  #pragma omp target
  {
    a[11][22] = 33;
  }
  return;
}
```

For the above code Clang maps both `a` and `n`.
In C/Clang, they array is simply created with size `n x 1024`.

But in FIR/HLFIR we wrap `n` with the following guard: `n>0 ? n:0`.

This means `n` only appears as a `select` op/instruction:

```
%0 = fir.load %arg0 : !fir.ref<i32>
%1 = fir.convert %0 : (i32) -> i64
%2 = fir.convert %1 : (i64) -> index
%c0 = arith.constant 0 : index
%3 = arith.cmpi sgt, %2, %c0 : index
%4 = arith.select %3, %2, %c0 : index
```

As a result, we would like to map `%4` here instead of `%arg0` as that is what gets used inside the region.

@kiranchandramohan @agozillon @clementval @razvanlupusoru Any idea how we do so while continuing to use `OpenMP_PointerLikeType` for `map_entries`?

https://github.com/llvm/llvm-project/pull/67164


More information about the flang-commits mailing list