From efab6d0214f543e5f97782d9a53712f05c603b8e Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Tue, 14 Feb 2017 15:54:33 -0800 Subject: [PATCH] Return slices of live-ins and arguments from ebb_top(). The coloring algorithm needs to process these two types of live values differently, so we may as well provide the needed info. --- lib/cretonne/src/regalloc/live_value_tracker.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/cretonne/src/regalloc/live_value_tracker.rs b/lib/cretonne/src/regalloc/live_value_tracker.rs index 02af0969d1..cdbfebe286 100644 --- a/lib/cretonne/src/regalloc/live_value_tracker.rs +++ b/lib/cretonne/src/regalloc/live_value_tracker.rs @@ -129,12 +129,17 @@ 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 + /// 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, ebb: Ebb, dfg: &DataFlowGraph, liveness: &Liveness, program_order: &PO, - domtree: &DominatorTree) { + domtree: &DominatorTree) + -> (&[LiveValue], &[LiveValue]) { // Start over, compute the set of live values at the top of the EBB from two sources: // // 1. Values that were live before `ebb`'s immediate dominator, filtered for those that are @@ -165,6 +170,7 @@ impl LiveValueTracker { } // Now add all the live arguments to `ebb`. + let first_arg = self.live.values.len(); for value in dfg.ebb_args(ebb) { let lr = liveness.get(value).expect("EBB argument value has no live range"); assert_eq!(lr.def(), ebb.into()); @@ -181,6 +187,8 @@ impl LiveValueTracker { } } } + + self.live.values.split_at(first_arg) } /// Prepare to move past `inst`.