[Mlir-commits] [mlir] [mlir][gpu] Guard negative workgroup_attributions in GPU ops (PR #174409)
Fabian Mora
llvmlistbot at llvm.org
Sat Jan 10 11:57:59 PST 2026
================
@@ -886,12 +886,20 @@ LogicalResult LaunchOp::verify() {
}
LogicalResult LaunchOp::verifyRegions() {
+ int64_t numWorkgroupAttributions = 0;
+ if (auto attr = (*this)->getAttrOfType<IntegerAttr>(
+ getNumWorkgroupAttributionsAttrName())) {
+ numWorkgroupAttributions = attr.getInt();
+ if (numWorkgroupAttributions < 0)
+ return emitOpError() << "expected non-negative workgroup_attributions";
+ }
+
// Kernel launch takes kNumConfigOperands leading operands for grid/block
// sizes and transforms them into kNumConfigRegionAttributes region arguments
// for block/thread identifiers and grid/block sizes.
if (!getBody().empty()) {
if (getBody().getNumArguments() <
- kNumConfigRegionAttributes + getNumWorkgroupAttributions())
+ kNumConfigRegionAttributes + numWorkgroupAttributions)
----------------
fabianmcg wrote:
I think this is not an error, but an assertion. As the only way one can get negative values is if one purposefully messed with the internal state of the operation.
So, let;s change from an error to:
assert(getNumWorkgroupAttributions() >= 0 && "Invalid attribution").
https://github.com/llvm/llvm-project/pull/174409
More information about the Mlir-commits
mailing list