From 13676cafd1dbee3bff3cd0879f799e8666969572 Mon Sep 17 00:00:00 2001 From: julian-seward1 Date: Tue, 8 Oct 2019 18:13:35 +0200 Subject: [PATCH] RedundantReloadRemover::run: use cached state rather than allocating it new for each function. (#1118) RedundantReloadRemover participates in the state-recycling machinery implemented in cranelift-codegen/src/context.rs, whose goal it is to cache per-pass state so it can be used for compilation of multiple functions without reallocation. Unfortunately RedundantReloadRemover::run simply ignores the cached state and reallocates it new for each function. This patch fixes that. This reduces the number of malloc'd blocks by about 2%. --- cranelift/codegen/src/redundant_reload_remover.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cranelift/codegen/src/redundant_reload_remover.rs b/cranelift/codegen/src/redundant_reload_remover.rs index 11f13f5256..b1928f03b8 100644 --- a/cranelift/codegen/src/redundant_reload_remover.rs +++ b/cranelift/codegen/src/redundant_reload_remover.rs @@ -887,7 +887,7 @@ impl RedundantReloadRemover { cur: EncCursor::new(func, isa), reginfo: isa.register_info(), cfg: cfg, - state: &mut RedundantReloadRemover::new(), + state: self, }; let mut total_regunits = 0; for rb in isa.register_info().banks {