[llvm-dev] Function with multi return path?
TONGARI J via llvm-dev
llvm-dev at lists.llvm.org
Wed May 31 20:57:20 PDT 2017
Hi folks,
I'm new to LLVM and non-expert in hardware architecture, so my question
might be dumb.
I'm looking for the possibility to define/call a function with multi return
path, it might look like this:
```
; Define a function with 1 alternate return path
define i32 @f(i1 %i) fork 1 {
br i1 %i, label %noraml, label %alternate
noraml:
...
setpath ret i32 42 ; take normal return path
br %cleanup
alternate:
...
setpath fork 0 ; take the alternate return path
br %cleanup
cleanup: ; preds = %noraml, %alternate
...
unwind ; return to the caller
}
```
And at the call side:
```
%ret = call @f(i1 %i) fork [%otherwise]
...
otherwise:
...
```
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.
The idea is to implement some non-local control flow w/o extra overhead at
each call side.
I know LLVM doesn't have something like this currently, but is it possible
to implement?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170601/ebbf065a/attachment.html>
More information about the llvm-dev
mailing list