<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Jun 9, 2016 at 2:33 PM, Gor Nishanov <span dir="ltr"><<a href="mailto:gornishanov@gmail.com" target="_blank">gornishanov@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Lowering of coro.suspend number X:<br>
<br>
1) split block at coro.suspend, new block becomes jump point for resumption X<br>
2) RAUW coro.suspend with i1 true in resume clone i1 false in destroy clone<br>
3) replace coro.suspend with br %return.block in 'f', 'ret void' in clones<br>
<br>
Scratch the proposed corosuspend instruction. I think the intrinsic will work<br>
just fine!<span><font color="#888888"><br></font></span></blockquote><div><br></div><div class="gmail_quote">That sounds right.<br><br><br></div><div class="gmail_quote">If you're going down that route, that still leaves the question of the semantics of the fork intrinsic... thinking about it a bit more, I think you're going to run into problems with trying to keep around a return block through optimizations:<br><br>[...]<br>%first.return = call i1 @llvm.experimental.coro.fork()<br></div><div class="gmail_quote">%cmp = icmp eq i32 %x, 0<br></div><div class="gmail_quote">br i1 %cmp, label %block1, label %block2<br><br></div><div class="gmail_quote">block1:<br>[...]<br>br i1 %first.return, label %coro.return, label %coro.start<br><br></div><div class="gmail_quote">block2:<br>[...]<br></div><div class="gmail_quote">br i1 %first.return, label %coro.return, label %coro.start</div><div class="gmail_quote"><br>coro.return:<br></div><div class="gmail_quote">%xxx = phi i32 [ %a, %block1 ], [ %b, %block2 ]<br></div><div class="gmail_quote">call void @f(i32 %xxx)<br>ret i8* %frame<br></div><div class="gmail_quote"><br></div><div class="gmail_quote">(Now you can't trivially insert branches to the return block because of the PHI node.)<br></div><div class="gmail_quote"><br></div><div class="gmail_quote">-Eli<br></div></div></div></div>