Rat's Register Allocator

(hexrat.cc)

66 points | by mpweiher 2 days ago

2 comments

  • tonfa 1 day ago
    > The best assignment is NP-hard to find, so all practical allocators use heuristics.

    That said if you do the register allocation while the program is still in SSA form, it becomes polynomial (interference graph is a chordal graph).

    https://compilers.cs.uni-saarland.de/projects/ssara/

    • zarakshR 1 day ago
      Not quite, SSA form makes only the colouring pass polynomial time, optimal choice of spilling and coalescing is still NP-complete. cf. https://hal-lara.archives-ouvertes.fr/hal-02102286v1/documen...
      • Paul_Clayton 5 hours ago
        Do compilers use profile information to allocate compilation time (such as by using an extremely expensive but slightly better register allocator for a hot loop)?

        I got the impression that expensive register allocation is not an option. A 1% improvement in register allocation that results in a 0.1% local performance improvement and a 0.002% program performance improvement may be considered not to justify 1000x local compile time, but for frequently run stable-ish software the compile time and compiler development/maintenence time might be justified.

        (I am not a programmer, but I do like thinking and learning about such things.)

  • ndesaulniers 23 hours ago
    This is a great high level overview of some the techniques and problems encountered with developing a register allocator!

    LLVM 's FastRegAlloc also uses linear scan.