StrongerXi / soc

Compiler for a subset of OCaml
1 stars 0 forks source link

Add live_across information to liveness annotation. #45

Closed StrongerXi closed 3 years ago

StrongerXi commented 3 years ago

live_across != intersection(live_in, live_out) because a temp from live_in could be re-written and used after this instruction, but its old definition was "killed" by the instruction, e.g., T1 := T1 + 1.

The only place we're using this incorrect formula is register allocator, but fortunately (or unfortunately really) it never triggered any bug, because currently call instruction only writes to RAX, but RAX is not read by call instruction.

StrongerXi commented 3 years ago

While writing this PR, I realized that the caller-saved reg preservation can be implemented without exposing call instruction or caller-saved regs to register allocator -- just make call instruction write to all the caller-saved temps and pre-color those temps.

Validity of this idea is TBD.