From 7c4498ec52be94e406da4701d0894bb2ff3649bc Mon Sep 17 00:00:00 2001 From: Julian Hartl Date: Fri, 29 Mar 2024 12:11:39 +0100 Subject: [PATCH] Rebase via merge. 'ir/fix-register-allocation' rebased on 'origin/main'. --- ir/crates/back/src/codegen/machine/function/builder.rs | 2 +- ir/crates/back/src/codegen/machine/function/cfg.rs | 8 ++++---- ir/crates/back/src/codegen/selection_dag/builder.rs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ir/crates/back/src/codegen/machine/function/builder.rs b/ir/crates/back/src/codegen/machine/function/builder.rs index e396861..26678c0 100644 --- a/ir/crates/back/src/codegen/machine/function/builder.rs +++ b/ir/crates/back/src/codegen/machine/function/builder.rs @@ -102,7 +102,7 @@ impl FunctionBuilder { } PseudoOp::Phi(dest, operands) => { self.function.basic_blocks[mbb_id].add_phi(*dest, operands.iter().map( - |(reg, bb)| (*reg, self.bb_mapping[bb]) + |(reg, bb)| (*reg, self.bb_mapping[bb]) ).collect()); } PseudoOp::Def(reg) => { diff --git a/ir/crates/back/src/codegen/machine/function/cfg.rs b/ir/crates/back/src/codegen/machine/function/cfg.rs index 6c8505f..2f1d6b1 100644 --- a/ir/crates/back/src/codegen/machine/function/cfg.rs +++ b/ir/crates/back/src/codegen/machine/function/cfg.rs @@ -85,25 +85,25 @@ impl Cfg { } /// Traverses the cfg using a post order depth first traversal - pub fn dfs_postorder(&self) -> impl Iterator + '_ { + pub fn dfs_postorder(&self) -> impl Iterator + '_ { DfsPostOrder::new(&self.graph, self.entry_node()) .iter(&self.graph) .map(|node| self.node_to_block_map[&node]) } - pub fn bfs(&self) -> impl Iterator + '_ { + pub fn bfs(&self) -> impl Iterator + '_ { Bfs::new(&self.graph, self.entry_node()) .iter(&self.graph) .map(|node| self.node_to_block_map[&node]) } - pub fn predecessors(&self, bb: BasicBlockId) -> impl Iterator + '_ { + pub fn predecessors(&self, bb: BasicBlockId) -> impl Iterator + '_ { self.graph .neighbors_directed(self.block_to_node_map[&bb], Direction::Incoming) .map(|node| self.node_to_block_map[&node]) } - pub fn successors(&self, bb: BasicBlockId) -> impl Iterator + '_ { + pub fn successors(&self, bb: BasicBlockId) -> impl Iterator + '_ { self.graph .neighbors(self.block_to_node_map[&bb]) .map(|node| self.node_to_block_map[&node]) diff --git a/ir/crates/back/src/codegen/selection_dag/builder.rs b/ir/crates/back/src/codegen/selection_dag/builder.rs index e41530b..9f15ca2 100644 --- a/ir/crates/back/src/codegen/selection_dag/builder.rs +++ b/ir/crates/back/src/codegen/selection_dag/builder.rs @@ -146,7 +146,7 @@ impl<'func, TM: TargetMachine> Builder<'func, TM> { let mapped = self.map_vreg(reg, func); // Ensure that the temp reg and arg reg will be placed in the same location => we can trivially remove the phi instruction later on self.function.tie_vreg(mapped, mapped_arg); - // Using defined_in here is fine, because the reg that we use here is always defined in the immediate pred of bb_id + // Using defined_in here is fine, because the reg that we use here is always defined in the immediate pred of bb_id (Register::Virtual(mapped), func.cfg.vreg(reg).defined_in) }) .collect_vec();