https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111643

--- Comment #9 from Lukas Grätz <lukas.gra...@tu-darmstadt.de> ---
Thanks for everything, it seemed to be a misunderstanding from my side anyway
and the documentation fix should help others.

I am sorry for being silent, I was sick for a few days. As for my original
problem, I am thinking of opening a new report, because I realized there could
be another solution without flatten. To explain a bit more, we have
bar_original() and bar_new(), the latter should behave identical to the former
except one additional statement, the "instrumentation". Since the
instrumentation can be done in two assembler instructions only, the overhead of
bar_new() calling bar_original() is not negligible.

int bar_original (int x) { /* CODE */ }

unsigned int trace_buffer[512];
uint8_t trace_pos;

#define FUNCTION_NUMBER_bar     0x686
int bar_new (int x) {
    trace_buffer[trace_pos++] = 0x686; // instrumentation
    return bar_original(x);
}

My idea: Do not touch the stack inside bar_new() and replace the call in
bar_new() with a jump or better a fall-through to bar_original(). This is
possible, because both functions have the same signature. It could save around
4 instructions and some stack memory. I have a lot of such functions after my
instrumentation step.

I also wondered whether

int bar_alias (void) { return bar_original(); }

could be a portable alternative to attribute alias. Except that current GCC
does not translate it that way.

Reply via email to