GDC does.

Sean Kelly sean at invisibleduck.org
Wed May 21 08:17:26 PDT 2008


Frits van Bommel wrote:
> 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).

Oops, you're right.

> 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.

Yes, I remember the same thing.  I had thought that perhaps GDC 
converted the asm code under the covers before GCCs inlining took place, 
but perhaps not.


Sean



More information about the Digitalmars-d mailing list