Record vreg classes explicitly during liverange pass. (#35)
This resolves an issue seen when the source program uses multiple regclasses (Int and Float): in some cases, the logic that grabs the vregs and retains them (with class) in `vreg_regs` missed a register and we had a class mismatch. This occurred because data structures were initialized assuming `Int` regclass at first. This PR instead removes the `vreg_regs` array, stores the class explicitly as an `Option<RegClass>` in the `VRegData`, and provides a `Env::vreg()` method that reconstitutes a `VReg` given its index and its observed class. We "observe" the class of every vreg seen during the liveness pass (and we assert that every occurrence of the vreg index has the same class). In this way, we still have a single source-of-truth for the vreg class (the mention of the vreg itself) and we explicitly represent the "not observed yet" state (and panic on attempting to use such a vreg) rather than implicitly taking the wrong class.
This commit is contained in:
@@ -57,7 +57,6 @@ impl<'a, F: Function> Env<'a, F> {
|
||||
ranges: Vec::with_capacity(4 * n),
|
||||
spillsets: Vec::with_capacity(n),
|
||||
vregs: Vec::with_capacity(n),
|
||||
vreg_regs: Vec::with_capacity(n),
|
||||
pregs: vec![],
|
||||
allocation_queue: PrioQueue::new(),
|
||||
safepoints: vec![],
|
||||
|
||||
Reference in New Issue
Block a user