<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2014-02-18 0:48 GMT+09:00 Dicebot <span dir="ltr"><<a href="mailto:public@dicebot.lv" target="_blank">public@dicebot.lv</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="">On Monday, 17 February 2014 at 14:51:20 UTC, Kenji Hara wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
If a function is only used for CTFE, compiler can elide its codegen. It's<br>
in the scope of optimization.<br>
</blockquote>
<br></div>
It can't know for sure it without some sort of WPO / LTO - and those won't happen any time soon. I propose a simple workaround that can be done right now (it can be optional compiler-specific addition)<br>
</blockquote></div><br></div><div class="gmail_extra">In some case it would be possible without WPO/LTO:</div><div class="gmail_extra"><br></div><div class="gmail_extra">- Immediately called lambdas</div><div class="gmail_extra">
<br></div><div class="gmail_extra">  enum x = (){ return some_sort_ctfe_calculartions; };   // lambda codegen is unnecessary.</div><div class="gmail_extra"><br></div><div class="gmail_extra">- modue private functions</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">  module a;</div><div class="gmail_extra">  private string foo() { ... }</div><div class="gmail_extra">  enum x = foo();</div><div class="gmail_extra">  // Compiler can elide codegen for 'foo', if other declarations</div>
<div class="gmail_extra">  // in module a don't use it for runtime code.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Kenji Hara</div><div class="gmail_extra"><br></div></div>