diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2025-08-12 22:58:52 +0100 |
|---|---|---|
| committer | mlugg <mlugg@mlugg.co.uk> | 2025-08-13 11:36:16 +0100 |
| commit | 38ba425b26312ea073c7082e576e8583913139d7 (patch) | |
| tree | 40fb6ec72a7482dd77ec7f55aa9c70a73c4d6981 /src/codegen | |
| parent | b8124d9c0b01e8ac7cd0daf93a0ed018da5f2352 (diff) | |
| download | zig-38ba425b26312ea073c7082e576e8583913139d7.tar.gz zig-38ba425b26312ea073c7082e576e8583913139d7.zip | |
llvm: support small error limits
Resolves: #23533
Diffstat (limited to 'src/codegen')
| -rw-r--r-- | src/codegen/llvm.zig | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index a46c2d0e76..bccb67ec3c 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -10475,11 +10475,14 @@ pub const FuncGen = struct { const slice_ty = self.typeOfIndex(inst); const slice_llvm_ty = try o.lowerType(pt, slice_ty); + // If operand is small (e.g. `u8`), then signedness becomes a problem -- GEP always treats the index as signed. + const extended_operand = try self.wip.conv(.unsigned, operand, try o.lowerType(pt, .usize), ""); + const error_name_table_ptr = try self.getErrorNameTable(); const error_name_table = try self.wip.load(.normal, .ptr, error_name_table_ptr.toValue(&o.builder), .default, ""); const error_name_ptr = - try self.wip.gep(.inbounds, slice_llvm_ty, error_name_table, &.{operand}, ""); + try self.wip.gep(.inbounds, slice_llvm_ty, error_name_table, &.{extended_operand}, ""); return self.wip.load(.normal, slice_llvm_ty, error_name_ptr, .default, ""); } |
