| ... | @@ -10475,11 +10475,14 @@ pub const FuncGen = struct { | ... | @@ -10475,11 +10475,14 @@ pub const FuncGen = struct { |
| 10475 | const slice_ty = self.typeOfIndex(inst); | 10475 | const slice_ty = self.typeOfIndex(inst); |
| 10476 | const slice_llvm_ty = try o.lowerType(pt, slice_ty); | 10476 | const slice_llvm_ty = try o.lowerType(pt, slice_ty); |
| 10477 | | 10477 | |
| | 10478 | // If operand is small (e.g. `u8`), then signedness becomes a problem -- GEP always treats the index as signed. |
| | 10479 | const extended_operand = try self.wip.conv(.unsigned, operand, try o.lowerType(pt, .usize), ""); |
| | 10480 | |
| 10478 | const error_name_table_ptr = try self.getErrorNameTable(); | 10481 | const error_name_table_ptr = try self.getErrorNameTable(); |
| 10479 | const error_name_table = | 10482 | const error_name_table = |
| 10480 | try self.wip.load(.normal, .ptr, error_name_table_ptr.toValue(&o.builder), .default, ""); | 10483 | try self.wip.load(.normal, .ptr, error_name_table_ptr.toValue(&o.builder), .default, ""); |
| 10481 | const error_name_ptr = | 10484 | const error_name_ptr = |
| 10482 | try self.wip.gep(.inbounds, slice_llvm_ty, error_name_table, &.{operand}, ""); | 10485 | try self.wip.gep(.inbounds, slice_llvm_ty, error_name_table, &.{extended_operand}, ""); |
| 10483 | return self.wip.load(.normal, slice_llvm_ty, error_name_ptr, .default, ""); | 10486 | return self.wip.load(.normal, slice_llvm_ty, error_name_ptr, .default, ""); |
| 10484 | } | 10487 | } |
| 10485 | | 10488 | |