From: Robert Pengelly Date: Tue, 6 Oct 2026 04:05:36 +0000 (+0100) Subject: Fix address-of aggregate member arguments X-Git-Url: https://git.candlhat.org/?a=commitdiff_plain;h=81c6fe7c161abade102e35cfb4dd1a216ffe23ca;p=scc.git Fix address-of aggregate member arguments --- diff --git a/amd64.c b/amd64.c index 714f283..74319d6 100644 --- a/amd64.c +++ b/amd64.c @@ -20351,6 +20351,8 @@ static void emit_load_assignment_rhs_to_reg (const char *reg) { } + set_rhs_last_pointer_info (1, current_object_size); + free (name); return; @@ -25158,8 +25160,11 @@ static int emit_push_global_aggregate_argument_now (const char *name) { static void emit_call_pointer_in_reg_now (const char *fn_reg, const char *result_reg) { int argc = 0; - int arg_bytes; + + int arg_starts_address_of; int arg_is_floating; + int arg_bytes; + int i; int ch; @@ -25198,6 +25203,8 @@ static void emit_call_pointer_in_reg_now (const char *fn_reg, const char *result for (;;) { + arg_starts_address_of = tok.kind == TOK_AMPER; + arg_saved_ofp = 0; arg_tmp_ofp = 0; arg_is_floating = 0; @@ -25334,12 +25341,12 @@ static void emit_call_pointer_in_reg_now (const char *fn_reg, const char *result if (state->ofp) { - if (!arg_is_floating && postfix_member_seen && postfix_member_pointer_depth == 0 && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) { + if (!arg_is_floating && !arg_starts_address_of && !rhs_last_pointer_depth && postfix_member_seen && postfix_member_pointer_depth == 0 && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) { arg_bytes = postfix_member_size; emit_push_aggregate_from_addr_reg_now ("rax", arg_bytes); - } else if (!arg_is_floating && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) { + } else if (!arg_is_floating && !arg_starts_address_of && !rhs_last_pointer_depth && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) { arg_bytes = postfix_member_size; emit_push_aggregate_from_addr_reg_now ("rax", arg_bytes); @@ -27020,6 +27027,7 @@ static void emit_call_identifier_to_reg_now (const char *name, const char *reg, int total_arg_bytes = 0; int arg_is_floating, ch, i; + int arg_starts_address_of; int arg_bytes; int saved_arg_assignment32_stop_before_condition_operator; @@ -27120,6 +27128,8 @@ static void emit_call_identifier_to_reg_now (const char *name, const char *reg, for (;;) { + arg_starts_address_of = tok.kind == TOK_AMPER; + arg_saved_ofp = 0; arg_tmp_ofp = 0; @@ -27276,12 +27286,12 @@ static void emit_call_identifier_to_reg_now (const char *name, const char *reg, * slot according to the AMD64 calling convention. */ - } else if (!use_inline && !arg_is_floating && postfix_member_seen && postfix_member_pointer_depth == 0 && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) { + } else if (!use_inline && !arg_is_floating && !arg_starts_address_of && !rhs_last_pointer_depth && postfix_member_seen && postfix_member_pointer_depth == 0 && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) { arg_bytes = postfix_member_size; emit_push_aggregate_from_addr_reg_now ("rax", arg_bytes); - } else if (!use_inline && !arg_is_floating && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) { + } else if (!use_inline && !arg_is_floating && !arg_starts_address_of && !rhs_last_pointer_depth && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) { arg_bytes = postfix_member_size; emit_push_aggregate_from_addr_reg_now ("rax", arg_bytes); diff --git a/i386.c b/i386.c index 9851bce..fbf3bf2 100644 --- a/i386.c +++ b/i386.c @@ -19109,6 +19109,8 @@ static void emit_load_assignment_rhs_to_reg (const char *reg) { } + set_rhs_last_pointer_info (1, current_object_size); + free (name); return; @@ -23714,10 +23716,13 @@ static void emit_call_pointer_in_reg_now (const char *fn_reg, const char *result enum token_kind saved_calling_convention = postfix_member_calling_convention; - int argc = 0; int total_arg_bytes = 0; - int arg_bytes; + int argc = 0; + + int arg_starts_address_of; int arg_is_floating; + int arg_bytes; + int i; int ch; @@ -23746,6 +23751,8 @@ static void emit_call_pointer_in_reg_now (const char *fn_reg, const char *result for (;;) { + arg_starts_address_of = tok.kind == TOK_AMPER; + arg_saved_ofp = 0; arg_tmp_ofp = 0; @@ -23837,12 +23844,12 @@ static void emit_call_pointer_in_reg_now (const char *fn_reg, const char *result emit_push_reg_now ("edx"); emit_push_reg_now ("eax"); - } else if (!arg_is_floating && postfix_member_seen && postfix_member_pointer_depth == 0 && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) { + } else if (!arg_is_floating && !arg_starts_address_of && !rhs_last_pointer_depth && postfix_member_seen && postfix_member_pointer_depth == 0 && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) { arg_bytes = postfix_member_size; emit_push_aggregate_from_addr_reg_now ("eax", arg_bytes); - } else if (!arg_is_floating && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) { + } else if (!arg_is_floating && !arg_starts_address_of && !rhs_last_pointer_depth && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) { arg_bytes = postfix_member_size; emit_push_aggregate_from_addr_reg_now ("eax", arg_bytes); @@ -24235,6 +24242,7 @@ static void emit_call_identifier_to_reg_now (const char *name, const char *reg, int total_arg_bytes = 0; int arg_is_floating, ch, i; + int arg_starts_address_of; int arg_bytes; int saved_arg_assignment32_stop_before_condition_operator; @@ -24325,6 +24333,8 @@ static void emit_call_identifier_to_reg_now (const char *name, const char *reg, for (;;) { + arg_starts_address_of = tok.kind == TOK_AMPER; + arg_saved_ofp = 0; arg_tmp_ofp = 0; @@ -24495,12 +24505,12 @@ static void emit_call_identifier_to_reg_now (const char *name, const char *reg, emit_push_reg_now ("edx"); emit_push_reg_now ("eax"); - } else if (!use_inline && !arg_is_floating && postfix_member_seen && postfix_member_pointer_depth == 0 && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) { + } else if (!use_inline && !arg_is_floating && !arg_starts_address_of && !rhs_last_pointer_depth && postfix_member_seen && postfix_member_pointer_depth == 0 && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) { arg_bytes = postfix_member_size; emit_push_aggregate_from_addr_reg_now ("eax", arg_bytes); - } else if (!use_inline && !arg_is_floating && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) { + } else if (!use_inline && !arg_is_floating && !arg_starts_address_of && !rhs_last_pointer_depth && !postfix_value_is_array && postfix_member_size > (DATA_PTR & 0x1f)) { arg_bytes = postfix_member_size; emit_push_aggregate_from_addr_reg_now ("eax", arg_bytes);