[flang-commits] [flang] [flang][MLIR][OpenMP] Extend delayed privatization for scalar allocatables (PR #84740)

Kareem Ergawy via flang-commits flang-commits at lists.llvm.org
Tue Mar 12 01:45:34 PDT 2024


================
@@ -1060,15 +1058,16 @@ class FirConverter : public Fortran::lower::AbstractConverter {
                const Fortran::lower::SymbolBox &rhs_sb) {
     mlir::Location loc = genLocation(sym.name());
     if (lowerToHighLevelFIR())
-      copyVarHLFIR(loc, lhs_sb.getAddr(), rhs_sb.getAddr());
+      copyVarHLFIR(loc, lhs_sb, rhs_sb);
     else
       copyVarFIR(loc, sym, lhs_sb, rhs_sb);
   }
 
-  void copyVarHLFIR(mlir::Location loc, mlir::Value dst, mlir::Value src) {
+  void copyVarHLFIR(mlir::Location loc, Fortran::lower::SymbolBox dst,
+                    Fortran::lower::SymbolBox src) {
----------------
ergawy wrote:

With delayed privatization, the address that the `dst` box is not anymore a `FortranVariableOpInterface` value. It is rather a block argument to the `copy` region of the delayed privatizer:

```
omp.private {type = firstprivate} @_QF... : !fir.ref<!fir.box<!fir.heap<i32>>> alloc {
  ^bb0(%arg0: !fir.ref<!fir.box<!fir.heap<i32>>>):
  ...
  } copy {
  ^bb0(%arg0: !fir.ref<!fir.box<!fir.heap<i32>>>, %arg1: !fir.ref<!fir.box<!fir.heap<i32>>>):
  ...
  }
```

`%arg1` in the above snippet is the `dst` value. So we don't have access to the `fortran_attrs` attributes attached to the original value anymore. However, the `SymbolBox` still has that information since it directly checks the type of the address.

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


More information about the flang-commits mailing list