RE: Function with multi return path?

Tongari,
Another possibility, if you don’t like the function returning an index
which is switched on, is that the function returns an address that you
do an IR ‘indirectbr’ (indirect branch) on. Note that the ‘indirectbr’
Instruction requires a list of all possible destination labels, or else the
Compiler can’t correctly optimize the surrounding code.

I think the possible return addresses will have to have been passed in to
the function as arguments, or else have been made available through global
variables (which would be way beyond ugly).

But if you actually modify the called function’s return address register the
optimizer won’t be able to construct an accurate control-flow-graph of the
calling function, and the optimizer will corrupt its code. To fix that would require
a new IR call instruction that incorporates the indirect-branch instruction’s
list of all possible destination labels, but I don’t think you’re going to get
much support for such a request.

Note that Fortran-77 has “alternate returns” which seem to be what you
are asking for, but AFAIK every Fortran-77 compiler inserts a “switch”
statement following the call, so that the optimizers know where all
the possible destination labels are.

Peter Lawrence.