https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117387
--- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> --- (In reply to Andrew Pinski from comment #1) > But then later on it does: > /* Now possibly adjust the number of named args. > Normally, don't include the last named arg if anonymous args follow. > We do include the last named arg if > targetm.calls.strict_argument_naming() returns nonzero. > (If no anonymous args follow, the result of list_length is actually > one too large. This is harmless.) I am working on optimizing incoming integer argument promotion. I need to know exact the number of named args. For non-variadic function, n_named_args is one too large. How should I get precise n_named_args for non-variadic function? > > If targetm.calls.pretend_outgoing_varargs_named() returns > nonzero, and targetm.calls.strict_argument_naming() returns zero, > this machine will be able to place unnamed args that were passed > in registers into the stack. So treat all args as named. This > allows the insns emitting for a specific argument list to be > independent of the function declaration. > > If targetm.calls.pretend_outgoing_varargs_named() returns zero, > we do not have any reliable way to pass unnamed args in > registers, so we must force them into memory. */ > > if ((type_arg_types != 0 || TYPE_NO_NAMED_ARGS_STDARG_P (funtype)) > && targetm.calls.strict_argument_naming (args_so_far)) > ; > else if (type_arg_types != 0 > && ! targetm.calls.pretend_outgoing_varargs_named (args_so_far)) > /* Don't include the last named arg. */ > --n_named_args; > else if (TYPE_NO_NAMED_ARGS_STDARG_P (funtype) > && ! targetm.calls.pretend_outgoing_varargs_named (args_so_far)) > n_named_args = 0; > else > /* Treat all args as named. */ > n_named_args = num_actuals; > > /* Make a vector to hold all the information about each arg. */ > args = XCNEWVEC (struct arg_data, num_actuals); > > /* Build up entries in the ARGS array, compute the size of the > arguments into ARGS_SIZE, etc. */ > initialize_argument_information (num_actuals, args, &args_size, > n_named_args, exp, > structure_value_addr_value, fndecl, fntype, > args_so_far, reg_parm_stack_space, > &old_stack_level, &old_pending_adj, > &must_preallocate, &flags, > &try_tail_call, CALL_FROM_THUNK_P (exp));