https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122260
Bug ID: 122260
Summary: fn_split and inlining of va_arg functions
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Blocks: 26163
Target Milestone: ---
Take:
```
#include <stdarg.h>
#include <stdio.h>
int global = 0;
#ifndef OPTIMIZED
static
void f(const char *i, ...)
{
if (!global) return;
va_list a;
va_start(a, i);
vprintf(i, a);
va_end(a);
}
#else
static
void f1(const char *i, ...)
{
va_list a;
va_start(a, i);
vprintf(i, a);
va_end(a);
}
__attribute__((always_inline))
static inline
void f(const char *i, ...)
{
if (!global) return;
f1(i, __builtin_va_arg_pack ());
}
#endif
void g()
{
f("printf %s", "char");
}
```
It would be nice if f could be split and then at !global and that part inlined.
Like when OPTIMIZED is defined.
This shows up in spec in libquantum IIRC.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=26163
[Bug 26163] [meta-bug] missed optimization in SPEC (2k17, 2k and 2k6 and 95)