This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
How about marking the singleton containing the call to the initializer as always_inline, but not the initializer itself?
The compiler can then infer that initialized is set on the first inlined call and optimize away subsequent tests and initializer calls (call_some_function_that_may_modify_memory).
int& i_wrap()
{
if (i_init) i_init();
return i;
}int& i_wrap()
{
if (i_init && !i_initialized) { i_initialized = true; i_init(); }
return i;
}| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |