Also return live-through values from process_inst().

The coloring algorithm will need to look at the live-through values to
check if they interfere with fixed-register outputs for calls etc.
This commit is contained in:
Jakob Stoklund Olesen
2017-05-08 13:57:39 -07:00
parent f8a3a01f96
commit 402e437a4a
2 changed files with 16 additions and 7 deletions

View File

@@ -276,7 +276,7 @@ impl<'a> Context<'a> {
locations: &mut EntityMap<Value, ValueLoc>) { locations: &mut EntityMap<Value, ValueLoc>) {
// First update the live value tracker with this instruction. // First update the live value tracker with this instruction.
// Get lists of values that are killed and defined by `inst`. // Get lists of values that are killed and defined by `inst`.
let (kills, defs) = tracker.process_inst(inst, dfg, self.liveness); let (_throughs, kills, defs) = tracker.process_inst(inst, dfg, self.liveness);
// Get the operand constraints for `inst` that we are trying to satisfy. // Get the operand constraints for `inst` that we are trying to satisfy.
let constraints = self.encinfo let constraints = self.encinfo

View File

@@ -139,7 +139,7 @@ impl LiveValueTracker {
/// This depends on the stored live value set at `ebb`'s immediate dominator, so that must have /// This depends on the stored live value set at `ebb`'s immediate dominator, so that must have
/// been visited first. /// been visited first.
/// ///
/// Returns `(liveins, args)` as a pair or slices. The first slice is the set of live-in values /// Returns `(liveins, args)` as a pair of slices. The first slice is the set of live-in values
/// from the immediate dominator. The second slice is the set of `ebb` arguments that are live. /// from the immediate dominator. The second slice is the set of `ebb` arguments that are live.
/// Dead arguments with no uses are ignored and not added to the set. /// Dead arguments with no uses are ignored and not added to the set.
pub fn ebb_top<PO: ProgramOrder>(&mut self, pub fn ebb_top<PO: ProgramOrder>(&mut self,
@@ -209,9 +209,16 @@ impl LiveValueTracker {
/// Determine the set of already live values that are killed by `inst`, and add the new defined /// Determine the set of already live values that are killed by `inst`, and add the new defined
/// values to the tracked set. /// values to the tracked set.
/// ///
/// Returns `(kills, defs)` as a pair of slices. The `defs` slice is guaranteed to be in the /// Returns `(throughs, kills, defs)` as a tuple of slices:
/// same order as `inst`'s results, and includes dead defines. The order of `kills` is ///
/// arbitrary. /// 1. The `throughs` slice is the set of live-through values that are neither defined nor
/// killed by the instruction.
/// 2. The `kills` slice is the set of values that were live before the instruction and are
/// killed at the instruction. This does not include dead defs.
/// 3. The `defs` slice is guaranteed to be in the same order as `inst`'s results, and includes
/// dead defines.
///
/// The order of `throughs` and `kills` is arbitrary.
/// ///
/// The `drop_dead()` method must be called next to actually remove the dead values from the /// The `drop_dead()` method must be called next to actually remove the dead values from the
/// tracked set after the two returned slices are no longer needed. /// tracked set after the two returned slices are no longer needed.
@@ -219,7 +226,7 @@ impl LiveValueTracker {
inst: Inst, inst: Inst,
dfg: &DataFlowGraph, dfg: &DataFlowGraph,
liveness: &Liveness) liveness: &Liveness)
-> (&[LiveValue], &[LiveValue]) { -> (&[LiveValue], &[LiveValue], &[LiveValue]) {
// Save a copy of the live values before any branches or jumps that could be somebody's // Save a copy of the live values before any branches or jumps that could be somebody's
// immediate dominator. // immediate dominator.
match dfg[inst].analyze_branch(&dfg.value_lists) { match dfg[inst].analyze_branch(&dfg.value_lists) {
@@ -249,7 +256,9 @@ impl LiveValueTracker {
} }
} }
(&self.live.values[first_kill..first_def], &self.live.values[first_def..]) (&self.live.values[0..first_kill],
&self.live.values[first_kill..first_def],
&self.live.values[first_def..])
} }
/// Drop the values that are now dead after moving past `inst`. /// Drop the values that are now dead after moving past `inst`.