[Mlir-commits] [mlir] [mlir][spirv] Support function argument decorations for ptr in the PhysicalStorageBuffer (PR #76353)

Lei Zhang llvmlistbot at llvm.org
Thu Jan 4 10:16:14 PST 2024


================
@@ -369,6 +370,32 @@ LogicalResult spirv::Deserializer::processMemberName(ArrayRef<uint32_t> words) {
   return success();
 }
 
+void spirv::Deserializer::setArgAttrs(uint32_t argID) {
+  if (!decorations.contains(argID)) {
+    argAttrs.push_back(DictionaryAttr::get(context, {}));
----------------
antiagainst wrote:

Hmm, this assumes we always process `argID` in increasing order, which is the case for now. But not guaranteed. It's better to use `resize` if `argID >= argAttrs.size()`.

Also as it's implemented right now, we have `argAttrs` in the class directly. So this will just continuously grow if we process more than one functions. So it would be nice to add one more test in the serialization tests, where we have at least two functions, and each function has more than one arguments:

```
spirv.func @fn1(%arg0: i32, %arg1: !spirv.ptr<..> {spirv.decoration = ...})
spirv.func @fn2(%arg0: !spirv.ptr<..> {spirv.decoration = ...}, %arg1: !spirv.ptr<..> {spirv.decoration = ...})
```

https://github.com/llvm/llvm-project/pull/76353


More information about the Mlir-commits mailing list