Skip to content

Commit

Permalink
stack2reg: Drain instead of only iterating
Browse files Browse the repository at this point in the history
  • Loading branch information
CohenArthur committed Aug 23, 2020
1 parent eb6df58 commit 5c8c75b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/optimize/stack2reg.rs
Expand Up @@ -316,15 +316,15 @@ fn remove_unused_stack_addr_and_stack_load(opt_ctx: &mut OptimizeContext<'_>) {
for stack_slot_users in opt_ctx.stack_slot_usage_map.values_mut() {
stack_slot_users
.stack_addr
.iter()
.drain()
.filter(|inst| stack_addr_load_insts_users.get(inst).map(|users| users.is_empty()).unwrap_or(true))
.for_each(|inst| StackSlotUsage::remove_unused_stack_addr(&mut func, *inst));
.for_each(|inst| StackSlotUsage::remove_unused_stack_addr(&mut func, inst));

stack_slot_users
.stack_load
.iter()
.drain()
.filter(|inst| stack_addr_load_insts_users.get(inst).map(|users| users.is_empty()).unwrap_or(true))
.for_each(|inst| StackSlotUsage::remove_unused_load(&mut func, *inst));
.for_each(|inst| StackSlotUsage::remove_unused_load(&mut func, inst));
}
}

Expand Down

0 comments on commit 5c8c75b

Please sign in to comment.