<div dir="ltr"><div class="gmail_extra">On Sun, Apr 7, 2013 at 1:23 PM, Duncan Sands <span dir="ltr"><<a href="mailto:baldrick@free.fr" target="_blank">baldrick@free.fr</a>></span> wrote:<br><div class="gmail_quote">
<div>... </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">If you want a trap you are going to have to (IMO) output IR<br>
instructions rather than a constant expression.  For example you can output the<br>
equivalent of<br>
  if (x == 0)<br>
     llvm.trap() // or maybe some special trap routine<br>
  y = whatever/x<br>
  ... use y ...<br>
rather than the constant expression "whatever/x".  If the optimizers can prove<br>
that x is never zero then this will be sunk back into a constant expression (if<br>
"whatever" is a constant expression).<br></blockquote><div><br></div><div style>Ah, that's super interesting. I'll have to give it some more thought. Thanks for this, Duncan.</div><div style><br></div><div style>
My knee-jerk reaction is that emulating hardware behaviour in software should be avoided. At least in this specific case.</div><div style><br></div><div style>Thanks again,</div><div style>Cameron</div></div></div></div>