On Sat, Jul 21, 2012 at 1:09 AM, Duncan Sands <span dir="ltr"><<a href="mailto:baldrick@free.fr" target="_blank" class="cremed">baldrick@free.fr</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">Hi Chandler, I think this is all about read-only functions that may do infinite<br>
loops.<br></blockquote><div><br></div><div>I'm firmly in the camp that infinite loops without side-effects should be deleted. It is easy to introduce a side-effect if that is so-desired.</div><div><br></div><div>That said, if you want infinite loops to be "observable", and not be deleted from the program, you should similarly not mark a function containing such a loop (or noreturn for any other reason) as 'readonly'. This shouldn't have anything to do with making the *call* have side-effects, it should be about making the *function* have side-effects, whether through calling an infinite loop a side-effect, or through a proper side-effect such as a volatile memory access or I/O operation.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Ciao, Duncan.<br>
<div class="im"><br>
On 21/07/12 09:32, Chandler Carruth wrote:<br>
> On Fri, Jul 20, 2012 at 10:05 AM, Richard Osborne <<a href="mailto:richard@xmos.com" class="cremed">richard@xmos.com</a><br>
</div><div><div class="h5">> <mailto:<a href="mailto:richard@xmos.com" class="cremed">richard@xmos.com</a>>> wrote:<br>
><br>
>     Currently at -O2 a call to a readonly noreturn function (e.g. a function<br>
>     consisting of while(1)) is replaced by unreachable, which seems somewhat nasty.<br>
><br>
><br>
> If it's readonly, it shouldn't be observable, and so it seems reasonable to<br>
> remove it.<br>
><br>
> If it has some special observable significance, it should read from a volatile<br>
> variable or otherwise cause itself to have a side-effect. This will in turn<br>
> cause the call to have the side-effect.<br>
><br>
>     The following sequence of transforms are responsible:<br>
><br>
>     1) prune-eh adds unreachable after the call (since it has the noreturn<br>
>     attribute)<br>
>     2) early-cse removes the call to the function (since it has the readonly<br>
>     attribute).<br>
><br>
>     This patch makes Instruction::hasSideEffect() return true for functions<br>
>     marked with the no return attribute avoid this.<br>
>     To be completely correct early-cse (and others) should be updated so that<br>
>     they only delete calls to functions that provably always return (or are<br>
>     marked as such) - see PR965. While this would be nice to fix it is also a<br>
>     much bigger slice of work.<br>
><br>
>     Does this patch seem reasonable?<br>
><br>
>     --<br>
>     Richard Osborne | XMOS<br>
>     <a href="http://www.xmos.com" target="_blank" class="cremed">http://www.xmos.com</a><br>
><br>
><br>
>     _______________________________________________<br>
>     llvm-commits mailing list<br>
</div></div>>     <a href="mailto:llvm-commits@cs.uiuc.edu" class="cremed">llvm-commits@cs.uiuc.edu</a> <mailto:<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>
<div class="HOEnZb"><div class="h5">><br>
><br>
><br>
><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>
<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>
</div></div></blockquote></div><br></div>