Re: Question about JUMP and LINK
On 2012年03月16日 23:23, Dave Hylands wrote: > Hi Bill, > > On Thu, Mar 15, 2012 at 11:52 PM, bill4carson wrote: >> Hi, All >> >> The question is simple. >> >> func_a { >> >> call func_b >> } >> >> func_b { >> >> call func_c >> } >> >> func_c { >> >> return to func_a >> } >> >> >> The compiler I use let func_c to return func_a directly, IOW when func_b >> calls func_c, it use JUMP, other JUMP and LINK, and it's definitely not >> a question about inline or noinline. >> >> So can I ask why how to let the compiler use JUMP and LINK when func_b >> calls func_c? > > This is called Tail Optimization. See > http://c2.com/cgi/wiki?TailCallOptimization > > gcc (I'm using 4.4.4) with -O3 does this. > Thanks for the information. >> If it's not the right place to post this, sorry for the noise. > > The kernel newbies list is probably not the right place (since this > has nothing to do with the kernel). It also has nothing to do with > binutils. It's a gcc optimization, so picking a gcc list would > probably be more appropriate. > -- I am a slow learner but I will keep trying to fight for my dreams! --bill ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Question about JUMP and LINK
Hi Bill, On Thu, Mar 15, 2012 at 11:52 PM, bill4carson wrote: > Hi, All > > The question is simple. > > func_a { > > call func_b > } > > func_b { > > call func_c > } > > func_c { > > return to func_a > } > > > The compiler I use let func_c to return func_a directly, IOW when func_b > calls func_c, it use JUMP, other JUMP and LINK, and it's definitely not > a question about inline or noinline. > > So can I ask why how to let the compiler use JUMP and LINK when func_b > calls func_c? This is called Tail Optimization. See http://c2.com/cgi/wiki?TailCallOptimization gcc (I'm using 4.4.4) with -O3 does this. > If it's not the right place to post this, sorry for the noise. The kernel newbies list is probably not the right place (since this has nothing to do with the kernel). It also has nothing to do with binutils. It's a gcc optimization, so picking a gcc list would probably be more appropriate. -- Dave Hylands Shuswap, BC, Canada http://www.davehylands.com ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Question about JUMP and LINK
Hi, All The question is simple. func_a { call func_b } func_b { call func_c } func_c { return to func_a } The compiler I use let func_c to return func_a directly, IOW when func_b calls func_c, it use JUMP, other JUMP and LINK, and it's definitely not a question about inline or noinline. So can I ask why how to let the compiler use JUMP and LINK when func_b calls func_c? If it's not the right place to post this, sorry for the noise. thanks -- I am a slow learner but I will keep trying to fight for my dreams! --bill ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies