TC-9 FAQ

Why does Codegen::rewrite_program need the created_temps argument ?

created_temps is a set storing all the new temporaries generated during the program’s rewrite. This set is then used by Color::select_spill to avoid spilling these temporaries.

Spilling the generated temporaries could potentially lead to an infinite loop because it does not reduce the number of conflicts.

For instance the following example produces an infinite loop if no check is done:

simple_add.tig
let
    var a0 := 0
    var a1 := 1
    var a2 := 2
    var a3 := 3
in
    print_int(0
            +  a0 + a0
            +  a1 + a1
            +  a2 + a2
            +  a3 + a3
            )
end
$ tc --callee-save=0 --caller-save=2 -eS simple_add.tig