Skip to content

Commit 45a4a0f

Browse files
committed
Generic : More mega-hack for va / normal.
1 parent dc45177 commit 45a4a0f

File tree

4 files changed

+51
-14
lines changed

4 files changed

+51
-14
lines changed

gcc/calls.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,7 +1354,8 @@ initialize_argument_information (int num_actuals ATTRIBUTE_UNUSED,
13541354
with those made by function.c. */
13551355

13561356
/* See if this argument should be passed by invisible reference. */
1357-
function_arg_info arg (type, argpos < n_named_args);
1357+
function_arg_info arg (type, argpos < n_named_args,
1358+
argpos == n_named_args - 1);
13581359
if (pass_by_reference (args_so_far_pnt, arg))
13591360
{
13601361
const bool callee_copies
@@ -1528,7 +1529,8 @@ initialize_argument_information (int num_actuals ATTRIBUTE_UNUSED,
15281529
reg_parm_stack_space,
15291530
args[i].pass_on_stack ? 0 : args[i].partial,
15301531
fndecl, args_size, &args[i].locate,
1531-
argpos < n_named_args);
1532+
argpos < n_named_args,
1533+
argpos == n_named_args - 1);
15321534
#ifdef BLOCK_REG_PADDING
15331535
else
15341536
/* The argument is passed entirely in registers. See at which

gcc/calls.h

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,43 @@ class function_arg_info
3535
{
3636
public:
3737
function_arg_info ()
38-
: type (NULL_TREE), mode (VOIDmode), named (false),
38+
: type (NULL_TREE), mode (VOIDmode), named (false), last_named (false),
3939
pass_by_reference (false)
4040
{}
4141

4242
/* Initialize an argument of mode MODE, either before or after promotion. */
4343
function_arg_info (machine_mode mode, bool named)
44-
: type (NULL_TREE), mode (mode), named (named), pass_by_reference (false)
44+
: type (NULL_TREE), mode (mode), named (named), last_named (false),
45+
pass_by_reference (false)
46+
{}
47+
48+
function_arg_info (machine_mode mode, bool named, bool last_named)
49+
: type (NULL_TREE), mode (mode), named (named), last_named (last_named),
50+
pass_by_reference (false)
4551
{}
4652

4753
/* Initialize an unpromoted argument of type TYPE. */
4854
function_arg_info (tree type, bool named)
49-
: type (type), mode (TYPE_MODE (type)), named (named),
55+
: type (type), mode (TYPE_MODE (type)), named (named), last_named (false),
5056
pass_by_reference (false)
5157
{}
5258

59+
/* Initialize an unpromoted argument of type TYPE. */
60+
function_arg_info (tree type, bool named, bool last_named)
61+
: type (type), mode (TYPE_MODE (type)), named (named),
62+
last_named (last_named), pass_by_reference (false)
63+
{}
64+
5365
/* Initialize an argument with explicit properties. */
5466
function_arg_info (tree type, machine_mode mode, bool named)
55-
: type (type), mode (mode), named (named), pass_by_reference (false)
67+
: type (type), mode (mode), named (named), last_named (false),
68+
pass_by_reference (false)
69+
{}
70+
71+
/* Initialize an argument with explicit properties. */
72+
function_arg_info (tree type, machine_mode mode, bool named, bool last_named)
73+
: type (type), mode (mode), named (named), last_named (last_named),
74+
pass_by_reference (false)
5675
{}
5776

5877
/* Return true if the gimple-level type is an aggregate. */
@@ -105,6 +124,9 @@ class function_arg_info
105124
"..."). See also TARGET_STRICT_ARGUMENT_NAMING. */
106125
unsigned int named : 1;
107126

127+
/* True if this is the last named argument. */
128+
unsigned int last_named : 1;
129+
108130
/* True if we have decided to pass the argument by reference, in which case
109131
the function_arg_info describes a pointer to the original argument. */
110132
unsigned int pass_by_reference : 1;

gcc/function.c

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2445,7 +2445,10 @@ assign_parm_find_data_types (struct assign_parm_data_all *all, tree parm,
24452445
else if (DECL_CHAIN (parm))
24462446
data->arg.named = 1; /* Not the last non-variadic parm. */
24472447
else if (targetm.calls.strict_argument_naming (all->args_so_far))
2448-
data->arg.named = 1; /* Only variadic ones are unnamed. */
2448+
{
2449+
data->arg.named = 1; /* Only variadic ones are unnamed. */
2450+
data->arg.last_named = 1;
2451+
}
24492452
else
24502453
data->arg.named = 0; /* Treat as variadic. */
24512454

@@ -2502,6 +2505,7 @@ assign_parms_setup_varargs (struct assign_parm_data_all *all,
25022505

25032506
function_arg_info last_named_arg = data->arg;
25042507
last_named_arg.named = true;
2508+
last_named_arg.last_named = true;
25052509
targetm.calls.setup_incoming_varargs (all->args_so_far, last_named_arg,
25062510
&varargs_pretend_bytes, no_rtl);
25072511

@@ -2612,7 +2616,7 @@ assign_parm_find_entry_rtl (struct assign_parm_data_all *all,
26122616
all->reg_parm_stack_space,
26132617
entry_parm ? data->partial : 0, current_function_decl,
26142618
&all->stack_args_size, &data->locate,
2615-
data->arg.named);
2619+
data->arg.named, data->arg.last_named);
26162620

26172621
/* Update parm_stack_boundary if this parameter is passed in the
26182622
stack. */
@@ -3925,7 +3929,8 @@ gimplify_parameters (gimple_seq *cleanup)
39253929
if (data.arg.pass_by_reference)
39263930
{
39273931
tree type = TREE_TYPE (data.arg.type);
3928-
function_arg_info orig_arg (type, data.arg.named);
3932+
function_arg_info orig_arg (type, data.arg.named,
3933+
data.arg.last_named);
39293934
if (reference_callee_copied (&all.args_so_far_v, orig_arg))
39303935
{
39313936
tree local, t;
@@ -4031,7 +4036,7 @@ locate_and_pad_parm (machine_mode passed_mode, tree type, int in_regs,
40314036
tree fndecl ATTRIBUTE_UNUSED,
40324037
struct args_size *initial_offset_ptr,
40334038
struct locate_and_pad_arg_data *locate,
4034-
bool named_p)
4039+
bool named_p, bool last_named_p)
40354040
{
40364041
tree sizetree;
40374042
pad_direction where_pad;
@@ -4068,10 +4073,18 @@ locate_and_pad_parm (machine_mode passed_mode, tree type, int in_regs,
40684073
where_pad = targetm.calls.function_arg_padding (passed_mode, type);
40694074
boundary = targetm.calls.function_arg_boundary (passed_mode, type);
40704075
if (named_p)
4071-
round_boundary = targetm.calls.function_arg_round_boundary (passed_mode,
4072-
type);
4076+
{
4077+
round_boundary = targetm.calls.function_arg_round_boundary (passed_mode,
4078+
type);
4079+
if (last_named_p)
4080+
round_boundary = PARM_BOUNDARY;
4081+
}
40734082
else
4074-
round_boundary = PARM_BOUNDARY;
4083+
{
4084+
/* Force everything to be at least aligned to the parm boundary. */
4085+
boundary = MAX (boundary, PARM_BOUNDARY);
4086+
round_boundary = PARM_BOUNDARY;
4087+
}
40754088

40764089
locate->where_pad = where_pad;
40774090

gcc/function.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ extern gimple_seq gimplify_parameters (gimple_seq *);
663663
extern void locate_and_pad_parm (machine_mode, tree, int, int, int,
664664
tree, struct args_size *,
665665
struct locate_and_pad_arg_data *,
666-
bool named_p = true);
666+
bool named_p = true, bool last_named = false);
667667
extern void generate_setjmp_warnings (void);
668668

669669
/* Identify BLOCKs referenced by more than one NOTE_INSN_BLOCK_{BEG,END},

0 commit comments

Comments
 (0)