| ... | ... | @@ -7933,6 +7933,11 @@ static ErrorMsg *ir_add_error(IrAnalyze *ira, IrInstruction *source_instruction, |
| 7933 | 7933 | return ir_add_error_node(ira, source_instruction->source_node, msg); |
| 7934 | 7934 | } |
| 7935 | 7935 | |
| 7936 | static void ir_assert(bool ok, IrInstruction *source_instruction) { |
| 7937 | if (ok) return; |
| 7938 | src_assert(ok, source_instruction->source_node); |
| 7939 | } |
| 7940 | |
| 7936 | 7941 | // This function takes a comptime ptr and makes the child const value conform to the type |
| 7937 | 7942 | // described by the pointer. |
| 7938 | 7943 | static Error eval_comptime_ptr_reinterpret(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, |
| ... | ... | @@ -13944,11 +13949,12 @@ IrInstruction *ir_get_implicit_allocator(IrAnalyze *ira, IrInstruction *source_i |
| 13944 | 13949 | zig_unreachable(); |
| 13945 | 13950 | } |
| 13946 | 13951 | |
| 13947 | | static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCall *call_instruction, ZigFn *fn_entry, ZigType *fn_type, |
| 13948 | | IrInstruction *fn_ref, IrInstruction **casted_args, size_t arg_count, IrInstruction *async_allocator_inst) |
| 13952 | static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCall *call_instruction, ZigFn *fn_entry, |
| 13953 | ZigType *fn_type, IrInstruction *fn_ref, IrInstruction **casted_args, size_t arg_count, |
| 13954 | IrInstruction *async_allocator_inst) |
| 13949 | 13955 | { |
| 13950 | 13956 | Buf *realloc_field_name = buf_create_from_str(ASYNC_REALLOC_FIELD_NAME); |
| 13951 | | assert(async_allocator_inst->value.type->id == ZigTypeIdPointer); |
| 13957 | ir_assert(async_allocator_inst->value.type->id == ZigTypeIdPointer, &call_instruction->base); |
| 13952 | 13958 | ZigType *container_type = async_allocator_inst->value.type->data.pointer.child_type; |
| 13953 | 13959 | IrInstruction *field_ptr_inst = ir_analyze_container_field_ptr(ira, realloc_field_name, &call_instruction->base, |
| 13954 | 13960 | async_allocator_inst, container_type); |
| ... | ... | @@ -13956,7 +13962,7 @@ static IrInstruction *ir_analyze_async_call(IrAnalyze *ira, IrInstructionCall *c |
| 13956 | 13962 | return ira->codegen->invalid_instruction; |
| 13957 | 13963 | } |
| 13958 | 13964 | ZigType *ptr_to_realloc_fn_type = field_ptr_inst->value.type; |
| 13959 | | assert(ptr_to_realloc_fn_type->id == ZigTypeIdPointer); |
| 13965 | ir_assert(ptr_to_realloc_fn_type->id == ZigTypeIdPointer, &call_instruction->base); |
| 13960 | 13966 | |
| 13961 | 13967 | ZigType *realloc_fn_type = ptr_to_realloc_fn_type->data.pointer.child_type; |
| 13962 | 13968 | if (realloc_fn_type->id != ZigTypeIdFn) { |
| ... | ... | @@ -21227,10 +21233,10 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 21227 | 21233 | if (type_is_invalid(end_value->value.type)) |
| 21228 | 21234 | return ira->codegen->invalid_instruction; |
| 21229 | 21235 | |
| 21230 | | assert(start_value->value.type->id == ZigTypeIdErrorSet); |
| 21236 | ir_assert(start_value->value.type->id == ZigTypeIdErrorSet, &instruction->base); |
| 21231 | 21237 | uint32_t start_index = start_value->value.data.x_err_set->value; |
| 21232 | 21238 | |
| 21233 | | assert(end_value->value.type->id == ZigTypeIdErrorSet); |
| 21239 | ir_assert(end_value->value.type->id == ZigTypeIdErrorSet, &instruction->base); |
| 21234 | 21240 | uint32_t end_index = end_value->value.data.x_err_set->value; |
| 21235 | 21241 | |
| 21236 | 21242 | if (start_index != end_index) { |
| ... | ... | @@ -21755,7 +21761,7 @@ static Error buf_read_value_bytes_array(IrAnalyze *ira, CodeGen *codegen, AstNod |
| 21755 | 21761 | |
| 21756 | 21762 | static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *source_node, uint8_t *buf, ConstExprValue *val) { |
| 21757 | 21763 | Error err; |
| 21758 | | assert(val->special == ConstValSpecialStatic); |
| 21764 | src_assert(val->special == ConstValSpecialStatic, source_node); |
| 21759 | 21765 | switch (val->type->id) { |
| 21760 | 21766 | case ZigTypeIdInvalid: |
| 21761 | 21767 | case ZigTypeIdMetaType: |
| ... | ... | @@ -21805,7 +21811,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou |
| 21805 | 21811 | zig_panic("TODO buf_read_value_bytes enum packed"); |
| 21806 | 21812 | case ContainerLayoutExtern: { |
| 21807 | 21813 | ZigType *tag_int_type = val->type->data.enumeration.tag_int_type; |
| 21808 | | assert(tag_int_type->id == ZigTypeIdInt); |
| 21814 | src_assert(tag_int_type->id == ZigTypeIdInt, source_node); |
| 21809 | 21815 | bigint_read_twos_complement(&val->data.x_enum_tag, buf, tag_int_type->data.integral.bit_count, |
| 21810 | 21816 | codegen->is_big_endian, tag_int_type->data.integral.is_signed); |
| 21811 | 21817 | return ErrorNone; |
| ... | ... | @@ -21860,7 +21866,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou |
| 21860 | 21866 | bigint_read_twos_complement(&big_int, buf + offset, big_int_byte_count * 8, is_big_endian, false); |
| 21861 | 21867 | while (src_i < src_field_count) { |
| 21862 | 21868 | TypeStructField *field = &val->type->data.structure.fields[src_i]; |
| 21863 | | assert(field->gen_index != SIZE_MAX); |
| 21869 | src_assert(field->gen_index != SIZE_MAX, source_node); |
| 21864 | 21870 | if (field->gen_index != gen_i) |
| 21865 | 21871 | break; |
| 21866 | 21872 | ConstExprValue *field_val = &val->data.x_struct.fields[src_i]; |
| ... | ... | @@ -21936,10 +21942,10 @@ static IrInstruction *ir_analyze_bit_cast(IrAnalyze *ira, IrInstruction *source_ |
| 21936 | 21942 | Error err; |
| 21937 | 21943 | |
| 21938 | 21944 | ZigType *src_type = value->value.type; |
| 21939 | | assert(get_codegen_ptr_type(src_type) == nullptr); |
| 21940 | | assert(type_can_bit_cast(src_type)); |
| 21941 | | assert(get_codegen_ptr_type(dest_type) == nullptr); |
| 21942 | | assert(type_can_bit_cast(dest_type)); |
| 21945 | ir_assert(get_codegen_ptr_type(src_type) == nullptr, source_instr); |
| 21946 | ir_assert(type_can_bit_cast(src_type), source_instr); |
| 21947 | ir_assert(get_codegen_ptr_type(dest_type) == nullptr, source_instr); |
| 21948 | ir_assert(type_can_bit_cast(dest_type), source_instr); |
| 21943 | 21949 | |
| 21944 | 21950 | if ((err = type_resolve(ira->codegen, dest_type, ResolveStatusSizeKnown))) |
| 21945 | 21951 | return ira->codegen->invalid_instruction; |
| ... | ... | @@ -22029,8 +22035,8 @@ static IrInstruction *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstruct |
| 22029 | 22035 | static IrInstruction *ir_analyze_int_to_ptr(IrAnalyze *ira, IrInstruction *source_instr, IrInstruction *target, |
| 22030 | 22036 | ZigType *ptr_type) |
| 22031 | 22037 | { |
| 22032 | | assert(get_src_ptr_type(ptr_type) != nullptr); |
| 22033 | | assert(type_has_bits(ptr_type)); |
| 22038 | ir_assert(get_src_ptr_type(ptr_type) != nullptr, source_instr); |
| 22039 | ir_assert(type_has_bits(ptr_type), source_instr); |
| 22034 | 22040 | |
| 22035 | 22041 | IrInstruction *casted_int = ir_implicit_cast(ira, target, ira->codegen->builtin_types.entry_usize); |
| 22036 | 22042 | if (type_is_invalid(casted_int->value.type)) |
| ... | ... | @@ -22129,7 +22135,7 @@ static IrInstruction *ir_analyze_instruction_decl_ref(IrAnalyze *ira, |
| 22129 | 22135 | case TldIdFn: { |
| 22130 | 22136 | TldFn *tld_fn = (TldFn *)tld; |
| 22131 | 22137 | ZigFn *fn_entry = tld_fn->fn_entry; |
| 22132 | | assert(fn_entry->type_entry); |
| 22138 | ir_assert(fn_entry->type_entry, &instruction->base); |
| 22133 | 22139 | |
| 22134 | 22140 | if (tld_fn->extern_lib_name != nullptr) { |
| 22135 | 22141 | add_link_lib_symbol(ira, tld_fn->extern_lib_name, &fn_entry->symbol_name, instruction->base.source_node); |
| ... | ... | @@ -22327,7 +22333,7 @@ static IrInstruction *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstruct |
| 22327 | 22333 | ZigType *result_type = fn_type_id->param_info[arg_index].type; |
| 22328 | 22334 | if (result_type == nullptr) { |
| 22329 | 22335 | // Args are only unresolved if our function is generic. |
| 22330 | | assert(fn_type->data.fn.is_generic); |
| 22336 | ir_assert(fn_type->data.fn.is_generic, &instruction->base); |
| 22331 | 22337 | |
| 22332 | 22338 | ir_add_error(ira, arg_index_inst, |
| 22333 | 22339 | buf_sprintf("@ArgType could not resolve the type of arg %" ZIG_PRI_u64 " because '%s' is generic", |
| ... | ... | @@ -22413,7 +22419,7 @@ static IrInstruction *ir_analyze_instruction_coro_begin(IrAnalyze *ira, IrInstru |
| 22413 | 22419 | return ira->codegen->invalid_instruction; |
| 22414 | 22420 | |
| 22415 | 22421 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); |
| 22416 | | assert(fn_entry != nullptr); |
| 22422 | ir_assert(fn_entry != nullptr, &instruction->base); |
| 22417 | 22423 | IrInstruction *result = ir_build_coro_begin(&ira->new_irb, instruction->base.scope, instruction->base.source_node, |
| 22418 | 22424 | coro_id, coro_mem_ptr); |
| 22419 | 22425 | result->value.type = get_promise_type(ira->codegen, fn_entry->type_entry->data.fn.fn_type_id.return_type); |
| ... | ... | @@ -22651,7 +22657,7 @@ static IrInstruction *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstr |
| 22651 | 22657 | } |
| 22652 | 22658 | |
| 22653 | 22659 | if (ordering == AtomicOrderRelease || ordering == AtomicOrderAcqRel) { |
| 22654 | | assert(instruction->ordering != nullptr); |
| 22660 | ir_assert(instruction->ordering != nullptr, &instruction->base); |
| 22655 | 22661 | ir_add_error(ira, instruction->ordering, |
| 22656 | 22662 | buf_sprintf("@atomicLoad atomic ordering must not be Release or AcqRel")); |
| 22657 | 22663 | return ira->codegen->invalid_instruction; |
| ... | ... | @@ -22659,7 +22665,7 @@ static IrInstruction *ir_analyze_instruction_atomic_load(IrAnalyze *ira, IrInstr |
| 22659 | 22665 | |
| 22660 | 22666 | if (instr_is_comptime(casted_ptr)) { |
| 22661 | 22667 | IrInstruction *result = ir_get_deref(ira, &instruction->base, casted_ptr); |
| 22662 | | assert(result->value.type != nullptr); |
| 22668 | ir_assert(result->value.type != nullptr, &instruction->base); |
| 22663 | 22669 | return result; |
| 22664 | 22670 | } |
| 22665 | 22671 | |
| ... | ... | @@ -22689,7 +22695,7 @@ static IrInstruction *ir_analyze_instruction_await_bookkeeping(IrAnalyze *ira, I |
| 22689 | 22695 | return ira->codegen->invalid_instruction; |
| 22690 | 22696 | |
| 22691 | 22697 | ZigFn *fn_entry = exec_fn_entry(ira->new_irb.exec); |
| 22692 | | assert(fn_entry != nullptr); |
| 22698 | ir_assert(fn_entry != nullptr, &instruction->base); |
| 22693 | 22699 | |
| 22694 | 22700 | if (type_can_fail(promise_result_type)) { |
| 22695 | 22701 | fn_entry->calls_or_awaits_errorable_fn = true; |
| ... | ... | @@ -22705,9 +22711,9 @@ static IrInstruction *ir_analyze_instruction_merge_err_ret_traces(IrAnalyze *ira |
| 22705 | 22711 | if (type_is_invalid(coro_promise_ptr->value.type)) |
| 22706 | 22712 | return ira->codegen->invalid_instruction; |
| 22707 | 22713 | |
| 22708 | | assert(coro_promise_ptr->value.type->id == ZigTypeIdPointer); |
| 22714 | ir_assert(coro_promise_ptr->value.type->id == ZigTypeIdPointer, &instruction->base); |
| 22709 | 22715 | ZigType *promise_frame_type = coro_promise_ptr->value.type->data.pointer.child_type; |
| 22710 | | assert(promise_frame_type->id == ZigTypeIdStruct); |
| 22716 | ir_assert(promise_frame_type->id == ZigTypeIdStruct, &instruction->base); |
| 22711 | 22717 | ZigType *promise_result_type = promise_frame_type->data.structure.fields[1].type_entry; |
| 22712 | 22718 | |
| 22713 | 22719 | if (!type_can_fail(promise_result_type)) { |
| ... | ... | @@ -22799,7 +22805,7 @@ static IrInstruction *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstructionS |
| 22799 | 22805 | return result; |
| 22800 | 22806 | } |
| 22801 | 22807 | |
| 22802 | | assert(float_type->id == ZigTypeIdFloat); |
| 22808 | ir_assert(float_type->id == ZigTypeIdFloat, &instruction->base); |
| 22803 | 22809 | if (float_type->data.floating.bit_count != 16 && |
| 22804 | 22810 | float_type->data.floating.bit_count != 32 && |
| 22805 | 22811 | float_type->data.floating.bit_count != 64) { |
| ... | ... | @@ -23290,7 +23296,7 @@ static IrInstruction *ir_analyze_instruction_nocast(IrAnalyze *ira, IrInstructio |
| 23290 | 23296 | |
| 23291 | 23297 | static IrInstruction *ir_analyze_instruction(IrAnalyze *ira, IrInstruction *old_instruction) { |
| 23292 | 23298 | IrInstruction *new_instruction = ir_analyze_instruction_nocast(ira, old_instruction); |
| 23293 | | assert(new_instruction->value.type != nullptr); |
| 23299 | ir_assert(new_instruction->value.type != nullptr, old_instruction); |
| 23294 | 23300 | old_instruction->child = new_instruction; |
| 23295 | 23301 | return new_instruction; |
| 23296 | 23302 | } |