<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jun 10, 2011, at 1:16 AM, David Blaikie wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">      } else if (Operands[i].isFP()) {<br>
         OS << "f" << i;<br>
       } else {<br>
-        assert("Unknown operand kind!");<br>
-        abort();<br>
+        llvm_unreachable("Unknown operand kind!");<br>
       }<br>
       if (i + 1 != e)<br>
         OS << ", ";<br></blockquote><div><br></div><div>Just wondering about coding conventions - would it be more appropriate to change this from:<br>  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>You're correct in pointing out that most sanity checks should be written with asserts (e.g., <font class="Apple-style-span" 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 class="Apple-style-span" face="'Courier New'">assert(0 && "I should have never gotten here..");</font> it should be replaced with <font class="Apple-style-span" 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><br></div><div> Chad</div></body></html>