[flang-commits] [flang] [flang][openacc] Split OpenACC context from function context (PR #71591)

Valentin Clement バレンタイン クレメン via flang-commits flang-commits at lists.llvm.org
Wed Nov 8 13:19:14 PST 2023


================
@@ -3093,23 +3085,38 @@ genDeclareInFunction(Fortran::lower::AbstractConverter &converter,
     }
   }
 
-  if (declareOp) {
-    declareOp.getDataClauseOperandsMutable().append(dataClauseOperands);
-    builder.setInsertionPointToEnd(&declareOp.getRegion().back());
+  mlir::func::FuncOp funcOp = builder.getFunction();
+  auto ops = funcOp.getOps<mlir::acc::DeclareEnterOp>();
+  if (ops.empty()) {
+    builder.create<mlir::acc::DeclareEnterOp>(loc, dataClauseOperands);
   } else {
-    declareOp = builder.create<mlir::acc::DeclareOp>(loc, dataClauseOperands);
-    builder.createBlock(&declareOp.getRegion(), declareOp.getRegion().end(), {},
-                        {});
-    builder.setInsertionPointToEnd(&declareOp.getRegion().back());
+    auto declareOp = *ops.begin();
+    auto newDeclareOp = builder.create<mlir::acc::DeclareEnterOp>(
----------------
clementval wrote:

The operation needs to be moved to the current builder position because of the instantiation of the variable that can appear between two declare directives 

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


More information about the flang-commits mailing list