@@ -521,14 +521,21 @@ bool EmitVisitor::visit(SpirvSource *inst) {
521521 }
522522 }
523523
524- // Note: in order to improve performance and avoid multiple copies, we
525- // encode this (potentially large) string directly into the debugFileBinary.
526- const auto &words = string::encodeSPIRVString (firstSnippet.getValue ());
527- const auto numWordsInInstr = curInst.size () + words.size ();
528- curInst[0 ] |= static_cast <uint32_t >(numWordsInInstr) << 16 ;
529- debugFileBinary.insert (debugFileBinary.end (), curInst.begin (),
530- curInst.end ());
531- debugFileBinary.insert (debugFileBinary.end (), words.begin (), words.end ());
524+ if (firstSnippet.hasValue ()) {
525+ // Note: in order to improve performance and avoid multiple copies, we
526+ // encode this (potentially large) string directly into the
527+ // debugFileBinary.
528+ const auto &words = string::encodeSPIRVString (firstSnippet.getValue ());
529+ const auto numWordsInInstr = curInst.size () + words.size ();
530+ curInst[0 ] |= static_cast <uint32_t >(numWordsInInstr) << 16 ;
531+ debugFileBinary.insert (debugFileBinary.end (), curInst.begin (),
532+ curInst.end ());
533+ debugFileBinary.insert (debugFileBinary.end (), words.begin (), words.end ());
534+ } else {
535+ curInst[0 ] |= static_cast <uint32_t >(curInst.size ()) << 16 ;
536+ debugFileBinary.insert (debugFileBinary.end (), curInst.begin (),
537+ curInst.end ());
538+ }
532539 } else {
533540 curInst[0 ] |= static_cast <uint32_t >(curInst.size ()) << 16 ;
534541 debugFileBinary.insert (debugFileBinary.end (), curInst.begin (),
0 commit comments