From 9d4e23d8940f85e07f1dac466b5d8c7f0be2f7a0 Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Thu, 11 May 2017 11:03:18 -0700 Subject: [PATCH] Propagate a few more LiveRange properties to LiveValue. The live value tracker goes through the trouble of looking up the live range for each value it tracks. We can cache a few more interesting properties from the live range in the LiveValue struct. --- .../src/regalloc/live_value_tracker.rs | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/cretonne/src/regalloc/live_value_tracker.rs b/lib/cretonne/src/regalloc/live_value_tracker.rs index 4ef7df8d3a..76e2fcb0d7 100644 --- a/lib/cretonne/src/regalloc/live_value_tracker.rs +++ b/lib/cretonne/src/regalloc/live_value_tracker.rs @@ -11,6 +11,7 @@ use ir::{Inst, Ebb, Value, DataFlowGraph, ProgramOrder, ExpandedProgramPoint}; use partition_slice::partition_slice; use regalloc::affinity::Affinity; use regalloc::liveness::Liveness; +use regalloc::liverange::LiveRange; use std::collections::HashMap; @@ -45,6 +46,12 @@ pub struct LiveValue { /// This value is simply a copy of the affinity stored in the live range. We copy it because /// almost all users of `LiveValue` need to look at it. pub affinity: Affinity, + + /// The live range for this value never leaves its EBB. + pub is_local: bool, + + /// This value is dead - the live range ends immediately. + pub is_dead: bool, } struct LiveValueVec { @@ -66,13 +73,15 @@ impl LiveValueVec { } } - /// Add a new live value to `values`. - fn push(&mut self, value: Value, endpoint: Inst, affinity: Affinity) { + /// Add a new live value to `values`. Copy some properties from `lr`. + fn push(&mut self, value: Value, endpoint: Inst, lr: &LiveRange) { self.values .push(LiveValue { value, endpoint, - affinity, + affinity: lr.affinity, + is_local: lr.is_local(), + is_dead: lr.is_dead(), }); } @@ -175,7 +184,7 @@ impl LiveValueTracker { // Check if this value is live-in here. if let Some(endpoint) = lr.livein_local_end(ebb, program_order) { - self.live.push(value, endpoint, lr.affinity); + self.live.push(value, endpoint, lr); } } } @@ -189,7 +198,7 @@ impl LiveValueTracker { assert_eq!(lr.def(), ebb.into()); match lr.def_local_end().into() { ExpandedProgramPoint::Inst(endpoint) => { - self.live.push(value, endpoint, lr.affinity); + self.live.push(value, endpoint, lr); } ExpandedProgramPoint::Ebb(local_ebb) => { // This is a dead EBB argument which is not even live into the first @@ -248,7 +257,7 @@ impl LiveValueTracker { assert_eq!(lr.def(), inst.into()); match lr.def_local_end().into() { ExpandedProgramPoint::Inst(endpoint) => { - self.live.push(value, endpoint, lr.affinity); + self.live.push(value, endpoint, lr); } ExpandedProgramPoint::Ebb(ebb) => { panic!("Instruction result live range can't end at {}", ebb);