Skip to content

Commit aa002b4

Browse files
author
Scott Manley
committed
[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.
1 parent fd59fd5 commit aa002b4

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3144,7 +3144,8 @@ LogicalResult acc::DataOp::verify() {
31443144
"must appear on the data operation");
31453145

31463146
for (mlir::Value operand : getDataClauseOperands())
3147-
if (!mlir::isa<acc::AttachOp, acc::CopyinOp, acc::CopyoutOp, acc::CreateOp,
3147+
if (isa<BlockArgument>(operand) ||
3148+
!mlir::isa<acc::AttachOp, acc::CopyinOp, acc::CopyoutOp, acc::CreateOp,
31483149
acc::DeleteOp, acc::DetachOp, acc::DevicePtrOp,
31493150
acc::GetDevicePtrOp, acc::NoCreateOp, acc::PresentOp>(
31503151
operand.getDefiningOp()))

mlir/test/Dialect/OpenACC/invalid.mlir

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,3 +840,11 @@ func.func @verify_declare_enter(%arg0 : memref<i32>) {
840840
acc.declare_exit token(%0) dataOperands(%arg0 : memref<i32>)
841841
return
842842
}
843+
844+
func.func @verify_data(%arg0 : memref<i32>) {
845+
// expected-error @below {{expect data entry/exit operation or acc.getdeviceptr as defining op}}
846+
acc.data dataOperands(%arg0 : memref<i32>) {
847+
acc.terminator
848+
}
849+
return
850+
}

0 commit comments

Comments
 (0)