From 395b5303877601ff0752baf0ca1489c652358248 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Wed, 22 Apr 2020 12:52:24 +0200 Subject: [PATCH] stage1: Another hack for the C ABI compatibility Applying the wrong ABI is slightly better than using the Zig ABI, the whole thing is so wrong it should be burned to the ground. --- src/analyze.cpp | 2 +- src/codegen.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/analyze.cpp b/src/analyze.cpp index ef23e896e3..89ad5aca74 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -9044,7 +9044,7 @@ static void resolve_llvm_types_fn_type(CodeGen *g, ZigType *fn_type) { FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id; bool first_arg_return = want_first_arg_sret(g, fn_type_id); bool is_async = fn_type_id->cc == CallingConventionAsync; - bool is_c_abi = fn_type_id->cc == CallingConventionC; + bool is_c_abi = !calling_convention_allows_zig_types(fn_type_id->cc); bool prefix_arg_error_return_trace = g->have_err_ret_tracing && fn_type_can_fail(fn_type_id); // +1 for maybe making the first argument the return value // +1 for maybe first argument the error return trace diff --git a/src/codegen.cpp b/src/codegen.cpp index dad8e4768a..730f2695e0 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -2071,7 +2071,7 @@ var_ok: void walk_function_params(CodeGen *g, ZigType *fn_type, FnWalk *fn_walk) { CallingConvention cc = fn_type->data.fn.fn_type_id.cc; - if (cc == CallingConventionC) { + if (!calling_convention_allows_zig_types(cc)) { size_t src_i = 0; for (;;) { if (!iter_function_params_c_abi(g, fn_type, fn_walk, src_i)) @@ -7862,7 +7862,7 @@ static void do_code_gen(CodeGen *g) { FnTypeId *fn_type_id = &fn_table_entry->type_entry->data.fn.fn_type_id; CallingConvention cc = fn_type_id->cc; - bool is_c_abi = cc == CallingConventionC; + bool is_c_abi = !calling_convention_allows_zig_types(cc); bool want_sret = want_first_arg_sret(g, fn_type_id); LLVMValueRef fn = fn_llvm_value(g, fn_table_entry);