================ @@ -250,14 +420,26 @@ class OpenACCClauseCIREmitter final } void VisitAsyncClause(const OpenACCAsyncClause &clause) { + hasAsyncClause = true; if constexpr (isOneOfTypes<OpTy, mlir::acc::ParallelOp, mlir::acc::SerialOp, mlir::acc::KernelsOp, mlir::acc::DataOp>) { if (!clause.hasIntExpr()) operation.addAsyncOnly(builder.getContext(), lastDeviceTypeValues); - else - operation.addAsyncOperand(builder.getContext(), - createIntExpr(clause.getIntExpr()), + else { + + mlir::Value intExpr; + { + // Async int exprs can be referenced by the data operands, which means + // that the int-exprs have to appear before them. IF there is a data + // operand already, set the insertion point to 'before' it. + mlir::OpBuilder::InsertionGuard guardCase(builder); + if (!dataOperands.empty()) + builder.setInsertionPoint(dataOperands.front()); ---------------- erichkeane wrote:
I considered putting these at the beginning of the 'block', but that ends up moving them very far away, which made for less readable IR. Instead, I just make sure they are before the first data operation. https://github.com/llvm/llvm-project/pull/140304 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits