On Fri, Jul 20, 2012 at 10:05 AM, Richard Osborne <span dir="ltr"><<a href="mailto:richard@xmos.com" target="_blank" class="cremed">richard@xmos.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Currently at -O2 a call to a readonly noreturn function (e.g. a function consisting of while(1)) is replaced by unreachable, which seems somewhat nasty.</blockquote>
<div><br></div><div>If it's readonly, it shouldn't be observable, and so it seems reasonable to remove it.</div><div><br></div><div>If it has some special observable significance, it should read from a volatile variable or otherwise cause itself to have a side-effect. This will in turn cause the call to have the side-effect.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> The following sequence of transforms are responsible:<br>
<br>
1) prune-eh adds unreachable after the call (since it has the noreturn attribute)<br>
2) early-cse removes the call to the function (since it has the readonly attribute).<br>
<br>
This patch makes Instruction::hasSideEffect() return true for functions marked with the no return attribute avoid this.<br>
To be completely correct early-cse (and others) should be updated so that they only delete calls to functions that provably always return (or are marked as such) - see PR965. While this would be nice to fix it is also a much bigger slice of work.<br>

<br>
Does this patch seem reasonable?<span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
Richard Osborne | XMOS<br>
<a href="http://www.xmos.com" target="_blank" class="cremed">http://www.xmos.com</a><br>
<br>
</font></span><br>_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" class="cremed">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank" class="cremed">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div><br></div>