[PATCH] D80766: [mlir][gpu] Fix logic error in D79508 computing number of private attributions.
Wen-Heng (Jack) Chung via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 28 15:59:15 PDT 2020
whchung created this revision.
whchung added a project: MLIR.
Herald added subscribers: llvm-commits, jurahul, Kayjukh, frgossen, grosul1, Joonsoo, stephenneuendorffer, liufengdb, lucyrfox, mgester, arpith-jacob, csigg, nicolasvasilache, antiagainst, shauheen, jpienaar, rriddle, mehdi_amini.
Herald added a reviewer: herhut.
Herald added a project: LLVM.
Fix logic error in D79508 <https://reviews.llvm.org/D79508>. The old logic would make the first check in
`GPUFuncOp::verifyBody` always pass.
Add additional logic in `GPUFuncOp::verifyBody` to ensure the numbers got match
actual attributions.
Since `workgroup_attributions` is added while parsing `gpu.func` op, it's not
possible to come up with a unit test which deliberately populate incorrect
number of `workgroup_attributions` therefore no unit test is added in this
patch.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D80766
Files:
mlir/include/mlir/Dialect/GPU/GPUOps.td
mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
Index: mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
===================================================================
--- mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
+++ mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
@@ -693,6 +693,12 @@
<< blockArgType;
}
+ if (getWorkgroupAttributions().size() != getNumWorkgroupAttributions())
+ return emitOpError() << "number of workgroup attributions do not match";
+
+ if (getPrivateAttributions().size() != getNumPrivateAttributions())
+ return emitOpError() << "number of private attributions do not match";
+
if (failed(verifyAttributions(getOperation(), getWorkgroupAttributions(),
GPUDialect::getWorkgroupAddressSpace())) ||
failed(verifyAttributions(getOperation(), getPrivateAttributions(),
Index: mlir/include/mlir/Dialect/GPU/GPUOps.td
===================================================================
--- mlir/include/mlir/Dialect/GPU/GPUOps.td
+++ mlir/include/mlir/Dialect/GPU/GPUOps.td
@@ -200,7 +200,7 @@
/// Returns the number of buffers located in the private memory.
unsigned getNumPrivateAttributions() {
- return getOperation()->getNumOperands() - getType().getNumInputs() -
+ return getBody().front().getNumArguments() - getType().getNumInputs() -
getNumWorkgroupAttributions();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80766.267064.patch
Type: text/x-patch
Size: 1352 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200528/cc5bdbb9/attachment.bin>
More information about the llvm-commits
mailing list