<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div style="word-wrap:break-word"><div><div class="h5"><div><blockquote type="cite"><div class="gmail_quote">
<div>Just wondering about coding conventions - would it be more appropriate to change this from:</div><div>  else if (cond) { ... } else { /* unreachable */ }<br>
to:<br>  else { assert(cond); ... };<br>This would be marginally more efficient in release builds, potentially. </div></div><br>
</blockquote></div><br></div></div><div>You're correct in pointing out that most sanity checks should be written with asserts (e.g., <font face="'Courier New'">assert (cond && "msg")</font>).  However, in the case of unreachable code we know that doom and gloom are sure to follow and thus we should gracefully abort and notify the user accordingly.  There's no performance to be gained because if we've reached this state the game is already over.</div>
<div><br></div><div>In general, if you see something like <font face="'Courier New'">assert(0 && "I should have never gotten here..");</font> it should be replaced with <font face="'Courier New'">llvm_unreachable("I should have never gotten here..")</font>.  Notice that the condition is hardcoded to zero and thus the assert will always fire.</div>
</div></blockquote><div><br></div><div>Right - but that's my point, there's performance to be gained by not at all checking 'cond' in retail builds - whereas the code as you have it now will check it unnecessarily & then go to llvm_unreachable if it's false. The perf gain would be that retail builds would never check the condition because it should never be false. That sounds like an assert to me, or am I missing something?</div>
<div><br></div><div>Perhaps my example was oversimplified/unclear, what I meant was from this:</div><div><br></div><div><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">      } else if (Operands[i].isFP()) {<br>
        OS << "ConstantFP *f" << i;<br>      } else {<br>        llvm_unreachable("Unknown operand kind!");<br>      }</span></div><div><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; "><br>
</span></div><div><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">to this:</span></div><div><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; "><br>
</span></div><div><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">      } else {</span></div><div><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">        assert(Operands[i].isFP() && "Unknown operator kind!");<br>
        OS << "ConstantFP *f" << i;<br>      }</span></div></div>