CSE for join points
Join points are hazardous for CSE:
join j = e in ... f e ...
The temptation is of course to rewrite to
join j = e in ... f (jump j) ...
which doesn't typecheck because you can't have a jump in an argument.
join j x = e in let y = (... join j2 x = e in ...) in ...
can't be rewritten to
join j x = e in let y = (... join j2 x = jump j x ...) in ...
because you can't jump out of a value binding.
This doesn't seem to come up very often (took a long time for me to trip over it). The simple solution is simply to ignore CSE for join points. That's what we do at the moment. But this is saddening in some cases:
join j x = e in join j2 x = e in ...
can perfectly well become
join j x = e in join j2 x = jump j x in ...
We just need to track which join points are still currently valid.