On 2016-11-03 04:43, Vladimir Panteleev wrote:

As it turns out, DMD will codegen all functions, even templated ones
when they're instantiated, whether they're called by something or not.
With metaprogramming-heavy code, it's easy to run into some optimizer
performance corner cases, however this may make an impact regardless.

I guess the compiler assumes that a function can end up in a library and be called by some other program. Sounds like a whole program analysis/optimization would be required. Or if the compiler is invoked as building an executable it can assume it can avoid generating code for unused functions?

To me it sounds like a @ctfe attribute would be useful. The compiler could enforce that functions annotated with @ctfe will only contain code that can be CTFE-able, can only be called in a CTFE context and will not generate any code.

--
/Jacob Carlborg

Reply via email to