From 583487bfac14a26481a761f6cec812141a8f6cbd Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 31 Aug 2017 16:30:00 -0700 Subject: [PATCH] Refactor the non-local case of use_var into a separate function. --- lib/frontend/src/ssa.rs | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/frontend/src/ssa.rs b/lib/frontend/src/ssa.rs index 016d8f0ce7..6ec44c5f7a 100644 --- a/lib/frontend/src/ssa.rs +++ b/lib/frontend/src/ssa.rs @@ -225,9 +225,23 @@ where if let Some(val) = var_defs.get(&block) { return (*val, SideEffects::new()); } - }; - // At this point if we haven't returned it means that we have to search in the - // predecessors. + } + + // Otherwise, we have to do a non-local lookup. + self.use_var_nonlocal(dfg, layout, jts, var, ty, block) + } + + // The non-local case of use_var. Query each predecessor for a value and add branch + // arguments as needed to satisfy the use. + fn use_var_nonlocal( + &mut self, + dfg: &mut DataFlowGraph, + layout: &mut Layout, + jts: &mut JumpTables, + var: Variable, + ty: Type, + block: Block, + ) -> (Value, SideEffects) { let case = match self.blocks[block] { BlockData::EbbHeader(ref mut data) => { // The block has multiple predecessors so we append an Ebb argument that