diff options
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index a53367a324..35ef2b98e2 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -1668,7 +1668,7 @@ static IrInstruction *ir_build_resize_slice(IrAnalyze *ira, IrInstruction *sourc instruction->result_loc = result_loc; ir_ref_instruction(operand, ira->new_irb.current_basic_block); - ir_ref_instruction(result_loc, ira->new_irb.current_basic_block); + if (result_loc != nullptr) ir_ref_instruction(result_loc, ira->new_irb.current_basic_block); return &instruction->base; } @@ -11297,7 +11297,10 @@ static ZigFn *ir_resolve_fn(IrAnalyze *ira, IrInstruction *fn_value) { if (!const_val) return nullptr; - assert(const_val->data.x_ptr.special == ConstPtrSpecialFunction); + // May be a ConstPtrSpecialHardCodedAddr + if (const_val->data.x_ptr.special != ConstPtrSpecialFunction) + return nullptr; + return const_val->data.x_ptr.data.fn.fn_entry; } @@ -16737,9 +16740,8 @@ static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionC return ir_finish_anal(ira, cast_instruction); } else if (fn_ref->value.type->id == ZigTypeIdFn) { ZigFn *fn_table_entry = ir_resolve_fn(ira, fn_ref); - if (fn_table_entry == nullptr) - return ira->codegen->invalid_instruction; - return ir_analyze_fn_call(ira, call_instruction, fn_table_entry, fn_table_entry->type_entry, + ZigType *fn_type = fn_table_entry ? fn_table_entry->type_entry : fn_ref->value.type; + return ir_analyze_fn_call(ira, call_instruction, fn_table_entry, fn_type, fn_ref, nullptr, is_comptime, call_instruction->fn_inline); } else if (fn_ref->value.type->id == ZigTypeIdBoundFn) { assert(fn_ref->value.special == ConstValSpecialStatic); @@ -16756,7 +16758,7 @@ static IrInstruction *ir_analyze_instruction_call(IrAnalyze *ira, IrInstructionC if (fn_ref->value.type->id == ZigTypeIdFn) { return ir_analyze_fn_call(ira, call_instruction, nullptr, fn_ref->value.type, - fn_ref, nullptr, false, FnInlineAuto); + fn_ref, nullptr, false, call_instruction->fn_inline); } else { ir_add_error_node(ira, fn_ref->source_node, buf_sprintf("type '%s' not a function", buf_ptr(&fn_ref->value.type->name))); @@ -21798,7 +21800,8 @@ static IrInstruction *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstructi return ira->codegen->invalid_instruction; } - if (instr_is_comptime(casted_ptr) && instr_is_comptime(casted_cmp_value) && instr_is_comptime(casted_new_value)) { + if (instr_is_comptime(casted_ptr) && casted_ptr->value.data.x_ptr.mut != ConstPtrMutRuntimeVar && + instr_is_comptime(casted_cmp_value) && instr_is_comptime(casted_new_value)) { zig_panic("TODO compile-time execution of cmpxchg"); } @@ -22948,12 +22951,20 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction if (parent_ptr == nullptr) return ira->codegen->invalid_instruction; - array_val = const_ptr_pointee(ira, ira->codegen, parent_ptr, instruction->base.source_node); - if (array_val == nullptr) - return ira->codegen->invalid_instruction; - rel_end = child_array_type->data.array.len; - abs_offset = 0; + if (parent_ptr->special == ConstValSpecialUndef) { + array_val = nullptr; + abs_offset = 0; + rel_end = SIZE_MAX; + ptr_is_undef = true; + } else { + array_val = const_ptr_pointee(ira, ira->codegen, parent_ptr, instruction->base.source_node); + if (array_val == nullptr) + return ira->codegen->invalid_instruction; + + rel_end = child_array_type->data.array.len; + abs_offset = 0; + } } else { array_val = const_ptr_pointee(ira, ira->codegen, &ptr_ptr->value, instruction->base.source_node); if (array_val == nullptr) |
