File tree Expand file tree Collapse file tree 1 file changed +12
-15
lines changed Expand file tree Collapse file tree 1 file changed +12
-15
lines changed Original file line number Diff line number Diff line change @@ -312,22 +312,19 @@ fn remove_unused_stack_addr_and_stack_load(opt_ctx: &mut OptimizeContext<'_>) {
312
312
}
313
313
314
314
// Replace all unused stack_addr and stack_load instructions with nop.
315
+ let mut func = & mut opt_ctx. ctx . func ;
315
316
for stack_slot_users in opt_ctx. stack_slot_usage_map . values_mut ( ) {
316
- for & inst in stack_slot_users. stack_addr . clone ( ) . iter ( ) {
317
- if stack_addr_load_insts_users. get ( & inst) . map ( |users| users. is_empty ( ) ) . unwrap_or ( true ) {
318
- StackSlotUsage :: remove_unused_stack_addr ( & mut opt_ctx. ctx . func , inst) ;
319
- stack_slot_users. stack_addr . remove ( & inst) ;
320
- }
321
- }
322
-
323
- /*
324
- for &inst in stack_slot_users.stack_load.clone().iter() {
325
- if stack_addr_load_insts_users.get(&inst).map(|users| users.is_empty()).unwrap_or(true) {
326
- StackSlotUsage::remove_unused_load(&mut opt_ctx.ctx.func, inst);
327
- stack_slot_users.stack_load.remove(&inst);
328
- }
329
- }
330
- */
317
+ stack_slot_users
318
+ . stack_addr
319
+ . iter ( )
320
+ . filter ( |inst| stack_addr_load_insts_users. get ( inst) . map ( |users| users. is_empty ( ) ) . unwrap_or ( true ) )
321
+ . for_each ( |inst| StackSlotUsage :: remove_unused_stack_addr ( & mut func, * inst) ) ;
322
+
323
+ stack_slot_users
324
+ . stack_load
325
+ . iter ( )
326
+ . filter ( |inst| stack_addr_load_insts_users. get ( inst) . map ( |users| users. is_empty ( ) ) . unwrap_or ( true ) )
327
+ . for_each ( |inst| StackSlotUsage :: remove_unused_load ( & mut func, * inst) ) ;
331
328
}
332
329
}
333
330
You can’t perform that action at this time.
0 commit comments