Re: Can I force gcc not to optimize calling to leaf functions with `-O2' option?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The optimization you described is called a "function tail merge". You
can disable that optimization without disabling the rest of -O2. I
forget the exact switch, but I expect a search for "tail merge" would
find it.

PRC wrote:
> 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
>
>
>   

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux