https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64950
Bug ID: 64950 Summary: postpone expanding va_arg till pass_stdarg Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: vries at gcc dot gnu.org pass_stdarg optimizes cfun->va_list_gpr/fpr_size by detecting va_args. However, va_args are expanded at gimple level, so pass_stdarg detects them by matching what the expansion of va_arg looks like after running through the passes between gimplification and pass_stdarg. This is known to be fragile (see f.i. PR 41089). It makes more sense to do the pass_stdarg optimization while va_arg is still intact. And we want to run optimization passes before pass_stdarg to be able to eliminate some unwanted va_args. So, it makes sense to postpone expansion of va_arg untill pass_stdarg. Michael Matz posted a prototype patch ( https://gcc.gnu.org/ml/gcc/2015-01/msg00304.html ). Latest version availabe at vries/expand-va-arg-at-pass-stdarg. Testing status of latest version available at https://gcc.gnu.org/ml/gcc/2015-02/msg00020.html .