Can I force gcc not to optimize calling to leaf functions with `-O2' option?
PRC
panruochen@gmail.com
Sat Mar 29 08:12:00 GMT 2008
Hi All,
I wonder if I can inform gcc not to optimize calling to leaf functions.
For example
-------------------
void say_hello()
{
printf("Hello\n");
}
void func()
{
say_hello();
}
with -O2 option, gcc will optimize
jal say_hello
...
jr ra
...
to
j say_hello
This is not what I want in some case. The start of the function can be located
by searching `addiu sp, XXXX' instruction, and the end of the function by
searching `jr ra', beginning with EPC when expctions arise, if all function calls
have their own exits. By this way, I can trace down the calling frames. But this
optimization breaks the rule and will confused the tracer. And the `-O2' option
is neccessary since some bugs are only exposed on `-O2'.
Is there an approach for this purpose?
Best Regards
PRC
Mar 29, 2008
More information about the Gcc-help
mailing list