The helper function in GPUFuncOp incorrectly assumed the workgroup
attribution attribute is always present. Instead, treat its absence as
if its value was zero, i.e., no workgroup attributions are specified.
Closes #58045.
Reviewed By: nicolasvasilache
Differential Revision: https://reviews.llvm.org/D134865
/// Returns the number of buffers located in the workgroup memory.
unsigned getNumWorkgroupAttributions() {
- return (*this)->getAttrOfType<IntegerAttr>(
- getNumWorkgroupAttributionsAttrName()).getInt();
+ auto attr = (*this)->getAttrOfType<IntegerAttr>(
+ getNumWorkgroupAttributionsAttrName());
+ return attr ? attr.getInt() : 0;
}
/// Returns a list of block arguments that correspond to buffers located in
return
}
}
+
+// Just check that this doesn't crash.
+gpu.module @module {
+ "gpu.func"() ({
+ gpu.return
+ }) {function_type = () -> (), sym_name = "func"} : () -> ()
+}