[Mlir-commits] [mlir] [mlir][spirv] Truncate Literal String size at max number words (PR #142916)

Jakub Kuderski llvmlistbot at llvm.org
Mon Jun 9 06:46:15 PDT 2025


================
@@ -67,8 +70,19 @@ uint32_t spirv::getPrefixedOpcode(uint32_t wordCount, spirv::Opcode opcode) {
 void spirv::encodeStringLiteralInto(SmallVectorImpl<uint32_t> &binary,
                                     StringRef literal) {
   // We need to encode the literal and the null termination.
-  auto encodingSize = literal.size() / 4 + 1;
-  auto bufferStartSize = binary.size();
+  size_t encodingSize = literal.size() / 4 + 1;
+  size_t sizeOfDataToCopy = literal.size();
+  if (encodingSize >= kMaxLiteralWordCount) {
+    // Reserve one word for the null termination
----------------
kuhar wrote:

```suggestion
    // Reserve one word for the null termination.
```

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


More information about the Mlir-commits mailing list