From 05680008445564d3b43fd720723c86b526ff97c3 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 17 Jun 2019 17:12:06 -0400 Subject: [PATCH] fix function calls --- src/ir.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/ir.cpp b/src/ir.cpp index 95b181918e..22fbc688c1 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -15482,6 +15482,13 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source return result; } +static void mark_inferred_ptr_runtime(IrInstruction *ptr) { + ir_assert(ptr->value.type->id == ZigTypeIdPointer, ptr); + if (ptr->value.data.x_ptr.mut == ConstPtrMutInfer) { + ptr->value.special = ConstValSpecialRuntime; + } +} + static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *call_instruction, ZigFn *fn_entry, ZigType *fn_type, IrInstruction *fn_ref, IrInstruction *first_arg_ptr, bool comptime_fn_call, FnInline fn_inline) @@ -15926,7 +15933,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) { return result_loc; } - call_instruction->result_loc->written = true; + mark_inferred_ptr_runtime(result_loc); } else { result_loc = nullptr; } @@ -16047,7 +16054,7 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)) { return result_loc; } - call_instruction->result_loc->written = true; + mark_inferred_ptr_runtime(result_loc); } else { result_loc = nullptr; } @@ -24820,9 +24827,6 @@ ZigType *ir_analyze(CodeGen *codegen, IrExecutable *old_exec, IrExecutable *new_ continue; } - if (ira->codegen->verbose_ir) { - fprintf(stderr, "analyze #%zu\n", old_instruction->debug_id); - } IrInstruction *new_instruction = ir_analyze_instruction_base(ira, old_instruction); if (new_instruction != nullptr) { ir_assert(new_instruction->value.type != nullptr || new_instruction->value.type != nullptr, old_instruction);