GDC does.

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Wed May 21 03:21:20 PDT 2008


Sean Kelly wrote:
> == Quote from downs (default_357-line at yahoo.de)'s article
>> FWIW, GDC does inline ref-arg functions.
>> Proof:
>> gentoo-pc ~ $ cat test42.d && echo "----" && gdc test42.d -o test42 -O3 -frelease && ./test42
>> module test42;
>> import std.stdio;
>> void test() {
>>   void* foo; asm { mov foo, ESP; }
>>   writefln("SP: ", foo);
>> }
>> void rtest(ref int x) { x++; test(); }
>> void main() {
>>   int i = 0;
>>   test();
>>   rtest(i);
>> }
>> ----
>> SP: BFC57840
>> SP: BFC57840
> 
> It apparently inlines functions containing asm blocks as well.  Score
> two points for GDC.

Not necessarily. Inlining just 'rtest' will produce the same ESP value 
for both invocations of 'test' as well, even though it's not inlined. 
(since both invocations of test() have the same stack frame size they 
get decremented equally from the same base value).
To really test that, you'd need to also manually inline test() into main 
and compare against the other two results. I just tried this, and it 
seems test() is indeed NOT inlined (at least, on x86-64 with Ubuntu's GDC).
I seem to remember gcc's extended asm syntax being claimed to be more 
inlining-friendly. GDC is supposed to support it, so you could try that.



More information about the Digitalmars-d mailing list