authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-04-01 15:55:31-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2020-04-01 15:55:31-04:00
log0f1f56bb69610ea424ac311db72510b474249095
treea485f9250d6a3e38af66b58fe93366392fbd6a81
parentc211b8f91df3ff7545a8cc3e93b58372eeccfe69
parentd33766e6c7289b79256b2e50d0dc2344729ff710
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #4896 from FireFox317/fix-arm32-stuff

fix some nullptr dereferences on arm-linux-musleabhif

6 files changed, 16 insertions(+), 7 deletions(-)

src/all_types.hpp+7-1
......@@ -1324,6 +1324,7 @@ struct ZigTypeFloat {
13241324 size_t bit_count;
13251325};
13261326
1327// Needs to have the same memory layout as ZigTypeVector
13271328struct ZigTypeArray {
13281329 ZigType *child_type;
13291330 uint64_t len;
......@@ -1512,12 +1513,17 @@ struct ZigTypeBoundFn {
15121513 ZigType *fn_type;
15131514};
15141515
1516// Needs to have the same memory layout as ZigTypeArray
15151517struct ZigTypeVector {
15161518 // The type must be a pointer, integer, bool, or float
15171519 ZigType *elem_type;
1518 uint32_t len;
1520 uint64_t len;
1521 size_t padding;
15191522};
15201523
1524// A lot of code is relying on ZigTypeArray and ZigTypeVector having the same layout/size
1525static_assert(sizeof(ZigTypeVector) == sizeof(ZigTypeArray), "Size of ZigTypeVector and ZigTypeArray do not match!");
1526
15211527enum ZigTypeId {
15221528 ZigTypeIdInvalid,
15231529 ZigTypeIdMetaType,
src/analyze.cpp+1
......@@ -5156,6 +5156,7 @@ ZigType *get_vector_type(CodeGen *g, uint32_t len, ZigType *elem_type) {
51565156 }
51575157 entry->data.vector.len = len;
51585158 entry->data.vector.elem_type = elem_type;
5159 entry->data.vector.padding = 0;
51595160
51605161 buf_resize(&entry->name, 0);
51615162 buf_appendf(&entry->name, "@Vector(%u, %s)", len, buf_ptr(&elem_type->name));
src/bigint.cpp+1-1
......@@ -1430,7 +1430,7 @@ void bigint_shr(BigInt *dest, const BigInt *op1, const BigInt *op2) {
14301430 uint64_t digit = op1_digits[op_digit_index];
14311431 size_t dest_digit_index = op_digit_index - digit_shift_count;
14321432 digits[dest_digit_index] = carry | (digit >> leftover_shift_count);
1433 carry = digit << (64 - leftover_shift_count);
1433 carry = (leftover_shift_count != 0) ? (digit << (64 - leftover_shift_count)) : 0;
14341434
14351435 if (dest_digit_index == 0) { break; }
14361436 op_digit_index -= 1;
src/codegen.cpp+1-1
......@@ -714,7 +714,7 @@ static LLVMValueRef get_arithmetic_overflow_fn(CodeGen *g, ZigType *operand_type
714714 };
715715
716716 if (operand_type->id == ZigTypeIdVector) {
717 sprintf(fn_name, "llvm.%s.with.overflow.v%" PRIu32 "i%" PRIu32, signed_str,
717 sprintf(fn_name, "llvm.%s.with.overflow.v%" PRIu64 "i%" PRIu32, signed_str,
718718 operand_type->data.vector.len, int_type->data.integral.bit_count);
719719
720720 LLVMTypeRef return_elem_types[] = {
src/ir.cpp+5-3
......@@ -15953,7 +15953,7 @@ static IrInstGen *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInst *source_i
1595315953 if (op1->value->type->id == ZigTypeIdVector && op2->value->type->id == ZigTypeIdVector) {
1595415954 if (op1->value->type->data.vector.len != op2->value->type->data.vector.len) {
1595515955 ir_add_error(ira, source_instr,
15956 buf_sprintf("vector length mismatch: %" PRIu32 " and %" PRIu32,
15956 buf_sprintf("vector length mismatch: %" PRIu64 " and %" PRIu64,
1595715957 op1->value->type->data.vector.len, op2->value->type->data.vector.len));
1595815958 return ira->codegen->invalid_inst_gen;
1595915959 }
......@@ -18982,7 +18982,7 @@ static IrInstGen *ir_analyze_async_call(IrAnalyze *ira, IrInst* source_instr, Zi
1898218982 if (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable) {
1898318983 return result_loc;
1898418984 }
18985 result_loc = ir_implicit_cast2(ira, &call_result_loc->source_instruction->base, result_loc,
18985 result_loc = ir_implicit_cast2(ira, source_instr, result_loc,
1898618986 get_pointer_to_type(ira->codegen, frame_type, false));
1898718987 if (type_is_invalid(result_loc->value->type))
1898818988 return ira->codegen->invalid_inst_gen;
......@@ -19967,14 +19967,16 @@ static IrInstGen *ir_analyze_call_extra(IrAnalyze *ira, IrInst* source_instr,
1996719967 return ira->codegen->invalid_inst_gen;
1996819968
1996919969 IrInstGen *stack = nullptr;
19970 IrInst *stack_src = nullptr;
1997019971 if (stack_is_non_null) {
1997119972 stack = ir_analyze_optional_value_payload_value(ira, source_instr, opt_stack, false);
1997219973 if (type_is_invalid(stack->value->type))
1997319974 return ira->codegen->invalid_inst_gen;
19975 stack_src = &stack->base;
1997419976 }
1997519977
1997619978 return ir_analyze_fn_call(ira, source_instr, fn, fn_type, fn_ref, first_arg_ptr, first_arg_ptr_src,
19977 modifier, stack, &stack->base, false, args_ptr, args_len, nullptr, result_loc);
19979 modifier, stack, stack_src, false, args_ptr, args_len, nullptr, result_loc);
1997819980}
1997919981
1998019982static IrInstGen *ir_analyze_instruction_call_extra(IrAnalyze *ira, IrInstSrcCallExtra *instruction) {
test/compile_errors.zig+1-1
......@@ -1188,7 +1188,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
11881188 \\ suspend;
11891189 \\}
11901190 , &[_][]const u8{
1191 "tmp.zig:3:5: error: expected type '*@Frame(bar)', found '*@Frame(foo)'",
1191 "tmp.zig:3:13: error: expected type '*@Frame(bar)', found '*@Frame(foo)'",
11921192 });
11931193
11941194 cases.add("@Frame() of generic function",