authorgravatar for vasyapulopapik@gmail.comKleshzz <vasyapulopapik@gmail.com> 2026-07-22 09:34:43+02:00
committergravatar for alichraghi@noreply.codeberg.orgAli Cheraghi <alichraghi@noreply.codeberg.org> 2026-07-22 09:34:43+02:00
log2b1c6633aaf1d59d4affd88e87a507a02836c478
treec1046dac1a105a1df1ee21e97ebb6c31f5fb7d61
parentf22d73386441714d59ea080f165979e18204a09d

spirv: fix ICEs when indexing slices, emitting large instructions (#36253)

Fixes #36229 Reviewed-on: https://codeberg.org/ziglang/zig/pulls/36253 Reviewed-by: Ali Cheraghi <alichraghi@noreply.codeberg.org>

1 files changed, 6 insertions(+), 3 deletions(-)

src/codegen/spirv/Section.zig+6-3
......@@ -49,8 +49,9 @@ pub fn emitRaw(
4949 operand_words: usize,
5050) !void {
5151 const word_count = 1 + operand_words;
52 if (word_count > std.math.maxInt(u16)) return error.OutOfMemory;
5253 try section.instructions.ensureUnusedCapacity(allocator, word_count);
53 section.writeWord((@as(Word, @intCast(word_count << 16))) | @backingInt(opcode));
54 section.writeWord((@as(Word, @intCast(word_count)) << 16) | @backingInt(opcode));
5455}
5556
5657/// Write an entire instruction, including all operands
......@@ -70,7 +71,8 @@ pub fn emitAssumeCapacity(
7071 operands: opcode.Operands(),
7172) !void {
7273 const word_count = instructionSize(opcode, operands);
73 section.writeWord(@as(Word, @intCast(word_count << 16)) | @backingInt(opcode));
74 if (word_count > std.math.maxInt(u16)) return error.OutOfMemory;
75 section.writeWord((@as(Word, @intCast(word_count)) << 16) | @backingInt(opcode));
7476 section.writeOperands(opcode.Operands(), operands);
7577}
7678
......@@ -81,8 +83,9 @@ pub fn emit(
8183 operands: opcode.Operands(),
8284) !void {
8385 const word_count = instructionSize(opcode, operands);
86 if (word_count > std.math.maxInt(u16)) return error.OutOfMemory;
8487 try section.instructions.ensureUnusedCapacity(allocator, word_count);
85 section.writeWord(@as(Word, @intCast(word_count << 16)) | @backingInt(opcode));
88 section.writeWord((@as(Word, @intCast(word_count)) << 16) | @backingInt(opcode));
8689 section.writeOperands(opcode.Operands(), operands);
8790}
8891