* module/language/cps/rotate-loops.scm (rotate-loop): Instead of
restricting rotation to loops with just one exit node, restrict to
loops with just one exit successor.
* module/language/cps/slot-allocation.scm (compute-lazy-vars):
(compute-live-variables): Adapt to solve-flow-equations interface
change.
* module/language/cps/utils.scm (solve-flow-equations): Move here. Use
an init value instead of an init map.
* module/language/cps/intset.scm (intset-intersect): Remove new-leaf
procedure, inlining to single call site. An empty intersection
properly produces #f so that the set can be pruned.
* module/language/cps2/reify-primitives.scm (uniquify-receive):
(reify-primitives): Ensure that $kreceive conts can have only one
predecessor. Otherwise return shuffles are incorrectly allocated.
* module/language/cps2/utils.scm (compute-successors): kfun is
optional.
(compute-sorted-strongly-connected-components): New function, moved
from split-rec.scm. Doesn't assume that 0 is a free node identifier.
* module/language/cps2/split-rec.scm
(compute-sorted-strongly-connected-components): Remove, use utils.scm
version instead.
* module/language/cps2/closure-conversion.scm (intset-select): Remove
unused function.
* module/language/cps/intset.scm (intset-prev): New function.
(make-intset-folder): Add forward? argument like make-intmap-folder.
(intset-fold-right): New function.
* module/language/cps2/optimize.scm: Move comments here from
cps/compile-bytecode.scm.
* module/language/cps/compile-bytecode.scm: Remove optimization and
closure conversion calls, since CPS2 does this for us.
* module/language/cps2/compile-cps.scm (compile-cps): Use set! to save
memory at bootstrap-time. Optimize first-order CPS, to get rid of
strangeness introduced in closure conversion.
* module/language/cps2/dce.scm (compute-live-code): Use the live-labels
set to indicate function liveness. $closure and $callk mark their
associated functions as live.
(process-eliminations): Handle $closure.
* module/language/cps2/effects-analysis.scm (expression-effects): Handle
$closure.
* module/language/cps2/utils.scm (compute-reachable-functions): New
function.
* module/language/cps2/verify.scm (check-label-partition)
(compute-reachable-labels): Use the new function.
* module/language/cps2/simplify.scm (compute-singly-referenced-vars):
Allow $closure.
(compute-eta-reductions, compute-beta-reductions): Use
compute-reachable-functions, which besides being a simplification also
allows simplification to work on first-order CPS.
* module/language/cps2/closure-conversion.scm
(rewrite-shared-closure-calls): Fix to make shared closures call the
right label.
(closure-label): New helper.
(prune-free-vars): If a shared closure is not well-known, don't use
the alias optimization.
(convert-one): Fix for shared closures with one not-well-known
closure.
* module/language/cps/compile-bytecode.scm (compile-bytecode): Only
convert closures if the #:cps2-convert? option is not passed.
* module/language/cps2/compile-cps.scm (conts->fun*, compile-cps): Add
support for CPS2 closure conversion, disabled by default.
* module/language/cps2/verify.scm: New diagnostic pass.
* module/Makefile.am: Add verify.scm.
* module/language/cps2/optimize.scm: Wire up verification pass.
Always run the pass at the end, and if a variable is set run it
between passes too.
* module/language/cps2/self-references.scm: New pass, ported from CPS.
* module/language/cps2/optimize.scm: Wire up the self references pass.
* module/Makefile.am: Add new file.
* module/language/cps2/simplify.scm (compute-singly-referenced-vars):
New helper.
(compute-eta-reductions): Turns out, eta conversion on a graph
doesn't work the same way that it works on nested terms -- since
uses and defs are computed using the flow graph and not nested
terms, we need to check additionally that the vars are singly-used.
* module/language/cps/slot-allocation.scm (allocate-slots): Even if an
expression does not define a live value, it might need a place to
put its value. In that case we should stop scanning for hints,
otherwise e.g. an (current-module) primcall whose value isn't used
could clobber a hinted variable.