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

Slava Zakharin via flang-commits flang-commits at lists.llvm.org
Wed Nov 8 13:21:19 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>(
----------------
vzakhari wrote:

Got it! Thanks!

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


More information about the flang-commits mailing list