From 402e437a4aaf2d0fe551962d1d996e32dfcb5eb8 Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Mon, 8 May 2017 13:57:39 -0700 Subject: [PATCH] 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. --- lib/cretonne/src/regalloc/coloring.rs | 2 +- .../src/regalloc/live_value_tracker.rs | 21 +++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/cretonne/src/regalloc/coloring.rs b/lib/cretonne/src/regalloc/coloring.rs index a1b3899577..f664c43c48 100644 --- a/lib/cretonne/src/regalloc/coloring.rs +++ b/lib/cretonne/src/regalloc/coloring.rs @@ -276,7 +276,7 @@ impl<'a> Context<'a> { locations: &mut EntityMap) { // First update the live value tracker with this instruction. // 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. let constraints = self.encinfo diff --git a/lib/cretonne/src/regalloc/live_value_tracker.rs b/lib/cretonne/src/regalloc/live_value_tracker.rs index 78085564f7..4ef7df8d3a 100644 --- a/lib/cretonne/src/regalloc/live_value_tracker.rs +++ b/lib/cretonne/src/regalloc/live_value_tracker.rs @@ -139,7 +139,7 @@ impl LiveValueTracker { /// This depends on the stored live value set at `ebb`'s immediate dominator, so that must have /// 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. /// Dead arguments with no uses are ignored and not added to the set. pub fn ebb_top(&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 /// values to the tracked set. /// - /// Returns `(kills, defs)` as a pair of slices. The `defs` slice is guaranteed to be in the - /// same order as `inst`'s results, and includes dead defines. The order of `kills` is - /// arbitrary. + /// Returns `(throughs, kills, defs)` as a tuple of slices: + /// + /// 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 /// tracked set after the two returned slices are no longer needed. @@ -219,7 +226,7 @@ impl LiveValueTracker { inst: Inst, dfg: &DataFlowGraph, liveness: &Liveness) - -> (&[LiveValue], &[LiveValue]) { + -> (&[LiveValue], &[LiveValue], &[LiveValue]) { // Save a copy of the live values before any branches or jumps that could be somebody's // immediate dominator. 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`.