From aa002b43ba3d3807690088ff1e395c6e7f64c249 Mon Sep 17 00:00:00 2001 From: Scott Manley Date: Tue, 16 Sep 2025 11:34:19 -0700 Subject: [PATCH] [OpenACC] verify acc:DataOp operand not BlockArgument Similar to #158095, check that the operand of acc::DataOp is not a BlockArgument before trying to get its defining operation so it will not segfault and instead produce a clean error. --- mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp | 3 ++- mlir/test/Dialect/OpenACC/invalid.mlir | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp index b82ad20d8e194..70cbde7071551 100644 --- a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp +++ b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp @@ -3144,7 +3144,8 @@ LogicalResult acc::DataOp::verify() { "must appear on the data operation"); for (mlir::Value operand : getDataClauseOperands()) - if (!mlir::isa(operand) || + !mlir::isa( operand.getDefiningOp())) diff --git a/mlir/test/Dialect/OpenACC/invalid.mlir b/mlir/test/Dialect/OpenACC/invalid.mlir index 24ce9784393b0..26b63fbe182ea 100644 --- a/mlir/test/Dialect/OpenACC/invalid.mlir +++ b/mlir/test/Dialect/OpenACC/invalid.mlir @@ -840,3 +840,11 @@ func.func @verify_declare_enter(%arg0 : memref) { acc.declare_exit token(%0) dataOperands(%arg0 : memref) return } + +func.func @verify_data(%arg0 : memref) { +// expected-error @below {{expect data entry/exit operation or acc.getdeviceptr as defining op}} + acc.data dataOperands(%arg0 : memref) { + acc.terminator + } + return +}