GDC and leaf functions

David Nadlinger see at klickverbot.at
Mon Mar 4 09:39:54 PST 2013


On Monday, 4 March 2013 at 15:25:43 UTC, Manu wrote:
> I'm doing a lot of experiments with GDC, and I'm noticing that 
> leaf
> functions are still generating a stack frame and doing 
> pointless work...
>
> int leaf() pure nothrow
> {
>   return 0;
> }
>
> compile with -frelease -finline -O3, etc
>
> I expect 2 opcodes, load immediate and return, but I get a 
> whole pointless
> function including memory access O_O
>
> Any ideas? Is this normal?

http://d.godbolt.org/#%7B%22version%22%3A3%2C%22filterAsm%22%3A%7B%22labels%22%3Atrue%2C%22directives%22%3Atrue%2C%22commentOnly%22%3Atrue%2C%22intel%22%3Atrue%7D%2C%22compilers%22%3A%5B%7B%22source%22%3A%22int%20leaf()%20pure%20nothrow%5Cn%7B%5Cn%20%20return%200%3B%5Cn%7D%22%2C%22compiler%22%3A%22%2Fusr%2Fbin%2Fgdc%22%2C%22options%22%3A%22-O3%20-march%3Dnative%22%7D%5D%7D

The rest is just code for registering the ModuleInfo of the given 
module in the global list.

David


More information about the Digitalmars-d mailing list