aboutsummaryrefslogtreecommitdiff
path: root/src/analyze.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-01-14 14:35:43 -0500
committerAndrew Kelley <superjoe30@gmail.com>2018-01-14 14:35:43 -0500
commitfa024f80924d35e4aac4b4edcac88193def03175 (patch)
tree7e5ad2c4b795a983d38b9a7c5c1b1e47fc7ea7ed /src/analyze.cpp
parent971a6fc5317b0e2d3a1f611702a4892f4aace942 (diff)
downloadzig-fa024f80924d35e4aac4b4edcac88193def03175.tar.gz
zig-fa024f80924d35e4aac4b4edcac88193def03175.zip
error return trace pointer prefixes other params
instead of being last. This increases the chances that it can remain in the same register between calls.
Diffstat (limited to 'src/analyze.cpp')
-rw-r--r--src/analyze.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp
index b52cb019d3..f7c0f832a2 100644
--- a/src/analyze.cpp
+++ b/src/analyze.cpp
@@ -925,7 +925,7 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
if (!skip_debug_info) {
bool first_arg_return = calling_convention_does_first_arg_return(fn_type_id->cc) &&
handle_is_ptr(fn_type_id->return_type);
- bool last_arg_error_return_trace = fn_type_id->return_type->id == TypeTableEntryIdErrorUnion ||
+ bool prefix_arg_error_return_trace = fn_type_id->return_type->id == TypeTableEntryIdErrorUnion ||
fn_type_id->return_type->id == TypeTableEntryIdPureError;
// +1 for maybe making the first argument the return value
// +1 for maybe last argument the error return trace
@@ -951,6 +951,14 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
}
fn_type->data.fn.gen_return_type = gen_return_type;
+ if (prefix_arg_error_return_trace) {
+ TypeTableEntry *gen_type = get_ptr_to_stack_trace_type(g);
+ gen_param_types[gen_param_index] = gen_type->type_ref;
+ gen_param_index += 1;
+ // after the gen_param_index += 1 because 0 is the return type
+ param_di_types[gen_param_index] = gen_type->di_type;
+ }
+
fn_type->data.fn.gen_param_info = allocate<FnGenParamInfo>(fn_type_id->param_count);
for (size_t i = 0; i < fn_type_id->param_count; i += 1) {
FnTypeParamInfo *src_param_info = &fn_type->data.fn.fn_type_id.param_info[i];
@@ -980,14 +988,6 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
}
}
- if (last_arg_error_return_trace) {
- TypeTableEntry *gen_type = get_ptr_to_stack_trace_type(g);
- gen_param_types[gen_param_index] = gen_type->type_ref;
- gen_param_index += 1;
- // after the gen_param_index += 1 because 0 is the return type
- param_di_types[gen_param_index] = gen_type->di_type;
- }
-
fn_type->data.fn.gen_param_count = gen_param_index;
fn_type->data.fn.raw_type_ref = LLVMFunctionType(gen_return_type->type_ref,