authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-04-22 12:52:24+02:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-04-22 12:52:24+02:00
log395b5303877601ff0752baf0ca1489c652358248
tree47208f74fc92dfb0b9fbb58c825899d00f35c4e6
parentaca6b7018443bfc012f39be486f848d6e62c532c

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.

2 files changed, 3 insertions(+), 3 deletions(-)

src/analyze.cpp+1-1
...@@ -9044,7 +9044,7 @@ static void resolve_llvm_types_fn_type(CodeGen *g, ZigType *fn_type) {...@@ -9044,7 +9044,7 @@ static void resolve_llvm_types_fn_type(CodeGen *g, ZigType *fn_type) {
9044 FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id;9044 FnTypeId *fn_type_id = &fn_type->data.fn.fn_type_id;
9045 bool first_arg_return = want_first_arg_sret(g, fn_type_id);9045 bool first_arg_return = want_first_arg_sret(g, fn_type_id);
9046 bool is_async = fn_type_id->cc == CallingConventionAsync;9046 bool is_async = fn_type_id->cc == CallingConventionAsync;
9047 bool is_c_abi = fn_type_id->cc == CallingConventionC;9047 bool is_c_abi = !calling_convention_allows_zig_types(fn_type_id->cc);
9048 bool prefix_arg_error_return_trace = g->have_err_ret_tracing && fn_type_can_fail(fn_type_id);9048 bool prefix_arg_error_return_trace = g->have_err_ret_tracing && fn_type_can_fail(fn_type_id);
9049 // +1 for maybe making the first argument the return value9049 // +1 for maybe making the first argument the return value
9050 // +1 for maybe first argument the error return trace9050 // +1 for maybe first argument the error return trace
src/codegen.cpp+2-2
...@@ -2071,7 +2071,7 @@ var_ok:...@@ -2071,7 +2071,7 @@ var_ok:
20712071
2072void walk_function_params(CodeGen *g, ZigType *fn_type, FnWalk *fn_walk) {2072void walk_function_params(CodeGen *g, ZigType *fn_type, FnWalk *fn_walk) {
2073 CallingConvention cc = fn_type->data.fn.fn_type_id.cc;2073 CallingConvention cc = fn_type->data.fn.fn_type_id.cc;
2074 if (cc == CallingConventionC) {2074 if (!calling_convention_allows_zig_types(cc)) {
2075 size_t src_i = 0;2075 size_t src_i = 0;
2076 for (;;) {2076 for (;;) {
2077 if (!iter_function_params_c_abi(g, fn_type, fn_walk, src_i))2077 if (!iter_function_params_c_abi(g, fn_type, fn_walk, src_i))
...@@ -7862,7 +7862,7 @@ static void do_code_gen(CodeGen *g) {...@@ -7862,7 +7862,7 @@ static void do_code_gen(CodeGen *g) {
78627862
7863 FnTypeId *fn_type_id = &fn_table_entry->type_entry->data.fn.fn_type_id;7863 FnTypeId *fn_type_id = &fn_table_entry->type_entry->data.fn.fn_type_id;
7864 CallingConvention cc = fn_type_id->cc;7864 CallingConvention cc = fn_type_id->cc;
7865 bool is_c_abi = cc == CallingConventionC;7865 bool is_c_abi = !calling_convention_allows_zig_types(cc);
7866 bool want_sret = want_first_arg_sret(g, fn_type_id);7866 bool want_sret = want_first_arg_sret(g, fn_type_id);
78677867
7868 LLVMValueRef fn = fn_llvm_value(g, fn_table_entry);7868 LLVMValueRef fn = fn_llvm_value(g, fn_table_entry);