From 722b9b9e595027e76ab4255f13ad0eca539358ac Mon Sep 17 00:00:00 2001 From: Eduardo Sánchez Muñoz Date: Sat, 14 Jul 2018 01:12:23 +0200 Subject: codegen: Store returned value if type is 'handle_is_ptr' and function is not 'first_arg_ret'. Seems to fix #1230, includes test. --- src/codegen.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/codegen.cpp') diff --git a/src/codegen.cpp b/src/codegen.cpp index 3f54c120b4..0bcc211164 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -3166,6 +3166,10 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr return nullptr; } else if (first_arg_ret) { return instruction->tmp_ptr; + } else if (handle_is_ptr(src_return_type)) { + auto store_instr = LLVMBuildStore(g->builder, result, instruction->tmp_ptr); + LLVMSetAlignment(store_instr, LLVMGetAlignment(instruction->tmp_ptr)); + return instruction->tmp_ptr; } else { return result; } -- cgit v1.2.3