Page 1 of 1

GGC Sibling Calls Optimization

Posted: Mon Oct 29, 2018 5:12 am
by LIC
Hi,

I am currently trying to make a small OS kernel, but there is something I don't understand: what does GCC actually do when the -foptimize-sibling-calls option is on?
Because when I turn this option on then the kernel runs into General Protection fault.

I looked at the generated assembler code and saw some differences but does someone know what are actually theses differences doing?

Regards

Re: GGC Sibling Calls Optimization

Posted: Mon Oct 29, 2018 6:39 am
by Octocontrabass
It performs tail call elimination between two functions, as long as both functions have compatible signatures.

If optimizations are causing your code to crash, there's probably a bug in your code.

Re: GGC Sibling Calls Optimization

Posted: Wed Oct 31, 2018 7:49 am
by LIC
Ok thank you for your reply. But do you have any piece of advice to track bugs that are "optimization related" ?

Re: GGC Sibling Calls Optimization

Posted: Wed Oct 31, 2018 8:09 am
by davidv1992
Enable compiler warnings and fix them. This will not fix all such bugs, but will significantly reduce their number. Of the things that remain, my experience has been that they are typically related to some sort of data race between threads and/or missing indications of reordering restrictions and such on port access and memory mapped hardware accesses. Beyond that, bochs and its build in debugger can be really useful tools, as they allow you to observe code behaviour in fairly high detail without disturbing execution flow.

Re: GGC Sibling Calls Optimization

Posted: Thu Nov 01, 2018 4:03 am
by LIC
Ok thanks a lot for your reply, I'll try Bochs!