From 7b27fdbf5439a9a05c603e10f49c9374a8e06223 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 9 Nov 2018 15:13:42 -0800 Subject: [PATCH] Avoid cloning an `InstructionData` when it isn't needed. --- lib/codegen/src/simple_gvn.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/codegen/src/simple_gvn.rs b/lib/codegen/src/simple_gvn.rs index 54d1040e9d..d60bdb6899 100644 --- a/lib/codegen/src/simple_gvn.rs +++ b/lib/codegen/src/simple_gvn.rs @@ -110,10 +110,8 @@ pub fn do_simple_gvn(func: &mut Function, domtree: &mut DominatorTree) { continue; } - let inst_data = func.dfg[inst].clone(); - // These are split up to separate concerns. - if is_load_and_not_readonly(&inst_data) { + if is_load_and_not_readonly(&func.dfg[inst]) { continue; } @@ -123,9 +121,8 @@ pub fn do_simple_gvn(func: &mut Function, domtree: &mut DominatorTree) { ty: ctrl_typevar, pos: &pos, }; - let entry = visible_values.entry(key); use scoped_hash_map::Entry::*; - match entry { + match visible_values.entry(key) { Occupied(entry) => { debug_assert!(domtree.dominates(*entry.get(), inst, &func.layout)); // If the redundant instruction is representing the current