[m-rev.] for review: copy packed args all at once

Zoltan Somogyi zoltan.somogyi at runbox.com
Sun Jun 3 03:21:12 AEST 2018



On Sun, 3 Jun 2018 01:17:24 +1000 (AEST), Julien Fischer <jfischer at opturion.com> wrote:
> The diff looks fine otherwise.

I followed both your suggestions. Thanks for the review.

BTW, I now remember you asked earlier, when I posted the diff
creating ml_unused_assign.m, whether I planned to do the same
optimization for the LLDS grades. I thought about it, but it would
a *lot* of work. Basically, in the LLDS grades we have to make
lots of decisions that the MLDS backend does not have to worry about,
because the target language compiler takes care of them. One of
these is deciding which variables we store in which stack slots
across calls. The LLDS backend pass that makes that decision
executes *before* the code generator proper. That means
it won't reserve any space in stack frames for the saved-values-of-
words-from-cells that the code generator may want to use
to implement this optimization.

There are two ways to go from here. The first is relatively simple:
implement the optimization in the LLDS code generator in a manner
similar to ml_unify_gen.m, but restrict it so that between the save
of such a word and its use, there can be nothing but straight line
code (i.e. no calls, branches or labels). The save can be into a temp
variable, and the assignment can be deleted in a simple per-basic-block
backwards traversal if it is unused. This is the low hanging fruit.

The second is much more complex. It involves a new prepass
that marks up HLDS construction and deconstruction unifications
with a new annotation that says (a) what packed words of
a deconstruction unification makes available, and (b) what
packed words a construction unification can use, in both cases
recording what (allocated for this purpose) HLDS variable we
will use as a handle to refer to this word, then teaching the
stack slot allocation pass to handle these as it does other variables.

Zoltan.


More information about the reviews mailing list