Thread overview
Re: GDC and leaf functions
Mar 04, 2013
Iain Buclaw
Mar 04, 2013
David Nadlinger
Mar 04, 2013
Manu
Mar 04, 2013
Iain Buclaw
March 04, 2013
On Mar 4, 2013 3:27 PM, "Manu" <turkeyman@gmail.com> 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?

I'd expect so.  Leaf functions in C require explicit attributes to mark them.  Now that we've integrated UDA attributes into gcc attributes, we need to start building on what is needed to be implemented.   :)

import gcc.attributes;
@attribute ("leaf") int leaf;

Regards
-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';


March 04, 2013
On Monday, 4 March 2013 at 17:35:45 UTC, Iain Buclaw wrote:
> On Mar 4, 2013 3:27 PM, "Manu" <turkeyman@gmail.com> 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?
>
> I'd expect so.

?!

I think you are seriously underestimating GCC here... ;)

David
March 04, 2013
Yeah, I've certainly never had to mark leaf's before...
Turns out it was my bad, wrong options, although SH4 is broken, which is
what started me scratching my head in the first place.


On 5 March 2013 03:40, David Nadlinger <see@klickverbot.at> wrote:

> On Monday, 4 March 2013 at 17:35:45 UTC, Iain Buclaw wrote:
>
>> On Mar 4, 2013 3:27 PM, "Manu" <turkeyman@gmail.com> 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?
>>>
>>
>> I'd expect so.
>>
>
> ?!
>
> I think you are seriously underestimating GCC here... ;)
>
> David
>


March 04, 2013
On Mar 4, 2013 5:46 PM, "David Nadlinger" <see@klickverbot.at> wrote:
>
> On Monday, 4 March 2013 at 17:35:45 UTC, Iain Buclaw wrote:
>>
>> On Mar 4, 2013 3:27 PM, "Manu" <turkeyman@gmail.com> 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?
>>
>>
>> I'd expect so.
>
>
> ?!
>
> I think you are seriously underestimating GCC here... ;)
>

I usually do.  :p

Regards
-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';