Skip to content

Commit

Permalink
chore: remove dead code from SSA optimization passes (#2800)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench authored Sep 25, 2023
1 parent feaf70e commit 373325d
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 14 deletions.
5 changes: 1 addition & 4 deletions compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ struct Branch {
condition: ValueId,
last_block: BasicBlockId,
store_values: HashMap<ValueId, Store>,
local_allocations: HashSet<ValueId>,
}

fn flatten_function_cfg(function: &mut Function) {
Expand Down Expand Up @@ -661,7 +660,6 @@ impl<'f> Context<'f> {
// block arguments, it is safe to use the jmpif block here.
last_block: jmpif_block,
store_values: HashMap::default(),
local_allocations: HashSet::new(),
}
} else {
self.push_condition(jmpif_block, new_condition);
Expand All @@ -685,13 +683,12 @@ impl<'f> Context<'f> {
self.conditions.pop();

let stores_in_branch = std::mem::replace(&mut self.store_values, old_stores);
let local_allocations = std::mem::replace(&mut self.local_allocations, old_allocations);
self.local_allocations = old_allocations;

Branch {
condition: new_condition,
last_block: final_block,
store_values: stores_in_branch,
local_allocations,
}
}
}
Expand Down
4 changes: 0 additions & 4 deletions compiler/noirc_evaluator/src/ssa/opt/inlining.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ struct PerFunctionContext<'function> {
/// block.
blocks: HashMap<BasicBlockId, BasicBlockId>,

/// Maps InstructionIds from the function being inlined to the function being inlined into.
instructions: HashMap<InstructionId, InstructionId>,

/// True if we're currently working on the entry point function.
inlining_entry: bool,
}
Expand Down Expand Up @@ -191,7 +188,6 @@ impl<'function> PerFunctionContext<'function> {
context,
source_function,
blocks: HashMap::default(),
instructions: HashMap::default(),
values: HashMap::default(),
inlining_entry: false,
}
Expand Down
4 changes: 0 additions & 4 deletions compiler/noirc_evaluator/src/ssa/opt/mem2reg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ use crate::ssa::{
ir::{
basic_block::BasicBlockId,
cfg::ControlFlowGraph,
dom::DominatorTree,
function::Function,
function_inserter::FunctionInserter,
instruction::{Instruction, InstructionId, TerminatorInstruction},
Expand Down Expand Up @@ -100,7 +99,6 @@ impl Ssa {
struct PerFunctionContext<'f> {
cfg: ControlFlowGraph,
post_order: PostOrder,
dom_tree: DominatorTree,

blocks: BTreeMap<BasicBlockId, Block>,

Expand All @@ -117,12 +115,10 @@ impl<'f> PerFunctionContext<'f> {
fn new(function: &'f mut Function) -> Self {
let cfg = ControlFlowGraph::with_function(function);
let post_order = PostOrder::with_function(function);
let dom_tree = DominatorTree::with_cfg_and_post_order(&cfg, &post_order);

PerFunctionContext {
cfg,
post_order,
dom_tree,
inserter: FunctionInserter::new(function),
blocks: BTreeMap::new(),
instructions_to_remove: BTreeSet::new(),
Expand Down
2 changes: 0 additions & 2 deletions compiler/noirc_evaluator/src/ssa/opt/unrolling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ struct Loops {
yet_to_unroll: Vec<Loop>,
modified_blocks: HashSet<BasicBlockId>,
cfg: ControlFlowGraph,
dom_tree: DominatorTree,
}

/// Find a loop in the program by finding a node that dominates any predecessor node.
Expand Down Expand Up @@ -109,7 +108,6 @@ fn find_all_loops(function: &Function) -> Loops {
yet_to_unroll: loops,
modified_blocks: HashSet::new(),
cfg,
dom_tree,
}
}

Expand Down

0 comments on commit 373325d

Please sign in to comment.