OT: on IDEs and code writing on steroids

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Wed May 20 03:29:18 PDT 2009

Denis Koroskin wrote:
> On Wed, 20 May 2009 13:09:37 +0400, Kagamin <spam at here.lot> wrote:
>> BCS Wrote:
>>> smaller object code? OTOH a good implementation will noice when I can  
>>> fold
>>> together several template expansions
>> That's the difference. You can't fold templates because they're binary  
>> incompatible as opposite to generics.
> You can fold /some/ templates. I believe LLVM already does merging of identical functions (including templates, virtual functions etc) as a part of optimization process. Not sure about LDC, though.

LLVM has a function merging pass, but LDC doesn't run it by default at any 
optimization level. (You can pass -mergefunc to run it explicitly, as with any 
LLVM pass)
It has some limitations though. Since it runs on IR, it matters what LLVM type 
values have. That means it might merge Templ!(int) and Templ!(uint) since int 
and uint are both an i32 to LLVM, but it normally wouldn't merge Templ!(int*) 
and Templ(short*) even if the template compiles down to "return cast(T) 
somefunc(cast(void*) arg);" because the types are still different (i32* vs i16*).
To do the latter transformation, the pass would need to be reimplemented to run 
when the code is closer to machine code.

More information about the Digitalmars-d mailing list