<div dir="ltr">The closest thing LLVM has to this is the invoke instruction used for exception handling. Using it requires reusing or building a lot of EH runtime support, though. invoke only supports a single alternative return destination (the landingpad), but you can use the selector value to switch over multiple language level alternative return destinations.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 31, 2017 at 11:57 PM, TONGARI J via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi folks,<div><br></div><div>I'm new to LLVM and non-expert in hardware architecture, so my question might be dumb.</div><div><br></div><div>I'm looking for the possibility to define/call a function with multi return path, it might look like this:<br><br>```<div>; Define a function with 1 alternate return path</div><div>define i32 @f(i1 %i) fork 1 {</div><div>  br i1 %i, label %noraml, label %alternate</div><div>noraml:</div><div>  ...</div><div>  setpath ret i32 42 ; take normal return path</div><div>  br %cleanup</div><div>alternate:</div><div>  ...</div><div>  setpath fork 0 ; take the alternate return path</div><div>  br %cleanup</div><div>cleanup: ; preds = %noraml, %alternate</div><div>  ...</div><div>  unwind ; return to the caller</div><div>}</div>```</div><div><br></div>And at the call side:<br>```<br><div>  %ret = call @f(i1 %i) fork [%otherwise]</div><div>  ...</div><div>otherwise:</div><div>  ...</div>```<div><br></div><div>Ideally, the callee sets the return address so it returns directly to the desired location in the caller w/o the caller taking extra switch.</div><div><br></div><div>The idea is to implement some non-local control flow w/o extra overhead at each call side.</div><div><br></div><div>I know LLVM doesn't have something like this currently, but is it possible to implement?</div></div>
<br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>