<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
<div>Yes, this is about infinite loops and it isn't me marking the function readonly - its the -functionattrs pass. Consider the following example:</div>
<div><br>
</div>
<div>void f() {</div>
<div>  while(1) {}</div>
<div>}</div>
<div><br>
</div>
<div>int main() {</div>
<div>  f();</div>
<div>  return 0;</div>
<div>}</div>
<div><br>
</div>
<div>I'm seeing the following sequence of transforms:</div>
<div><br>
</div>
<div>1) -prune-eh marks f() as noreturn</div>
<div>2) -prune-eh replaces the code after the call to f() in main with unreachable.</div>
<div>2) -functionattrs marks f() as readnone.</div>
<div>3) -early-cse deletes the call to f().</div>
<div><br>
</div>
<div>The net effect is more than just having the loop deleted - main ends up containing a single unreachable instruction and it crashes at runtime when execution falls through to whatever happens to be after main(). Using the fact that the loop is infinite
 to delete the code after the call and then ignoring the fact it is infinite to delete the call itself seems nasty to me.</div>
<br>
<div>
<div>On 21 Jul 2012, at 09:26, Chandler Carruth wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">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-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto; ">
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>
</div>
<br>
</body>
</html>