On Monday, 17 February 2014 at 16:01:50 UTC, Kenji Hara wrote:
- Immediately called lambdas

enum x = (){ return some_sort_ctfe_calculartions; }; // lambda codegen
is unnecessary.

True but this is only one of many cases.

- modue private functions

  module a;
  private string foo() { ... }
  enum x = foo();
  // Compiler can elide codegen for 'foo', if other declarations
  // in module a don't use it for runtime code.

It is not that simple. Other declarations can also be templates or CTFE functions (but public) - compiler can't know if those will be used in runtime codegen in other modules. And being conservative will make optimization much less useful.

This is exactly why I am referencing WPO/LTO - doing this is plain optimization is theoretically possible but is huge effort to implement in somewhat reliable way. I'd like to have something simple that can help right now and turned into no-op later once compiler becomes clever enough.

Reply via email to