ocaml-flambda / flambda-backend

The Flambda backend project for OCaml
105 stars 76 forks source link

IRC & LS followup #758

Open gretay-js opened 2 years ago

gretay-js commented 2 years ago

A few items of followup after merging https://github.com/ocaml-flambda/flambda-backend/pull/678

xclerc commented 2 years ago

Also, from the PR TODO list:

xclerc commented 2 years ago

~~Not strictly IRC-related, but the spilling costs should not include any use by a probe.~~ See https://github.com/ocaml-flambda/flambda-backend/pull/945

xclerc commented 2 years ago

Stack operands: revisit https://github.com/ocaml-flambda/flambda-backend/pull/771#discussion_r967049882

xclerc commented 2 years ago

~~Not IRC-specific, but part of the pipeline: consider moving to dynamic arrays or doubly linked list for the layout.~~ See https://github.com/ocaml-flambda/flambda-backend/pull/1124

xclerc commented 1 year ago

Move could probably accept a stack operand here.

gretay-js commented 1 year ago

In cfg_stack_operands.ml allow stack operands for Valueofint and Intofvalue and maybe Opaque. See comment in https://github.com/ocaml-flambda/flambda-backend/pull/855

xclerc commented 1 year ago

There are likely missed opportunities for stack operands in IRC because of aliasing. Indeed, the functions rewriting arg/res to use stack operands do get a map of spilled registers, but that map does not include aliases.

xclerc commented 1 year ago

Other missed opportunities for stack operands are related to float operations - See upstream's version.

xclerc commented 1 year ago

Port upstream's improvement to LS heuristics. note: https://github.com/ocaml-flambda/flambda-backend/pull/1464 is possibly equivalent while applying to all CFG-based allocators

xclerc commented 1 year ago

There are no compilers hooks on the IRC pipeline. While we do not have spill/split there (yet), we could have a hook for liveness. The compiler hook for CFG is also not called on the IRC pipeline.

xclerc commented 1 year ago

The IRC pipeline does not have an equivalent of Available_regs. See https://github.com/ocaml-flambda/flambda-backend/pull/1748

xclerc commented 1 year ago

Remove the calls to Profile.record introduced by https://github.com/ocaml-flambda/flambda-backend/pull/1095 and https://github.com/ocaml-flambda/flambda-backend/pull/1123. See https://github.com/ocaml-flambda/flambda-backend/pull/1290

xclerc commented 1 year ago

~~Revisit the CR introduced by https://github.com/ocaml-flambda/flambda-backend/pull/1292, that is: ensure optimality of stack frame sizes.~~ See https://github.com/ocaml-flambda/flambda-backend/pull/1464

xclerc commented 1 year ago

Split/rename preprocessing phase (i.e. https://github.com/ocaml-flambda/flambda-backend/pull/1442 and follow-ups):

xclerc commented 1 year ago

~~In rewrite_gen (Regalloc_rewrite module), the calls to Array.map are not necessary since the arrays are no longer shared. (It means that the condition might also not be necessary.)~~ See https://github.com/ocaml-flambda/flambda-backend/pull/1544

xclerc commented 1 year ago

~Get rid of the STACK_SLOTS_OPTIM parameter introduced by https://github.com/ocaml-flambda/flambda-backend/pull/1464.~ See https://github.com/ocaml-flambda/flambda-backend/pull/1545

xclerc commented 1 year ago

After https://github.com/ocaml-flambda/flambda-backend/pull/1441, Regalloc_utils.insert_block accepts to insert an empty block. Double check whether it is actually necessary, or we can avoid ever inserting empty blocks.

xclerc commented 1 year ago

In https://github.com/ocaml-flambda/flambda-backend/pull/1442, consider more destruction points, as mentioned in the CR-soons in proc.ml.

xclerc commented 1 year ago

Get rid of Instruction.dummy (and others) once we have nullable types.

xclerc commented 1 year ago

In RemoveDominatedSpillsForConstants, consider whether it would be better to compute num_sets through a forward dataflow analysis. Also reconsider the status of a missing key in this table:

xclerc commented 1 year ago

As noted in https://github.com/ocaml-flambda/flambda-backend/pull/1741, the various optimizations can result in empty sets in the map. Double check whether the corresponding mappings can be safely be removed.

xclerc commented 1 year ago

Not urgent since we currently only support amd64, but IRC current ignores the Proc.rotate_registers variable (unlike Coloring).

gretay-js commented 1 year ago

amd64/reload.ml has important comments about instruction set constraints on locations and sharing of registers. We should preserve this information when moving to the CFG pipeline, perhaps as part of the next version of stack operands.