From 6f58f94cdb12ba367c37a620e7f2f40228e691b1 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 26 Aug 2018 17:14:12 +0200 Subject: [PATCH] Add Caches to FunctionCx --- src/base.rs | 13 ++++++------- src/common.rs | 1 + 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/base.rs b/src/base.rs index 2783f330254..e6302684c54 100644 --- a/src/base.rs +++ b/src/base.rs @@ -16,8 +16,6 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( ccx: &mut crate::constant::ConstantCx, mono_item: MonoItem<'tcx>, ) { - let context = &mut caches.context; - match mono_item { MonoItem::Fn(inst) => { let _print_guard = PrintOnPanic(format!("{:?}", inst)); @@ -40,7 +38,7 @@ pub fn trans_mono_item<'a, 'tcx: 'a>( "target/out/mir/".to_string() + &format!("{:?}", inst.def_id()).replace('/', "@"); ::std::fs::write(mir_file_name, mir).unwrap(); - trans_fn(tcx, module, ccx, context, inst); + trans_fn(tcx, module, ccx, caches, inst); } MonoItem::Static(def_id) => { crate::constant::codegen_static(ccx, def_id); @@ -55,7 +53,7 @@ fn trans_fn<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, module: &mut Module, constants: &mut crate::constant::ConstantCx, - context: &mut Context, + caches: &mut Caches, instance: Instance<'tcx>, ) { // Step 1. Get mir @@ -94,6 +92,7 @@ fn trans_fn<'a, 'tcx: 'a>( local_map: HashMap::new(), comments: HashMap::new(), constants, + caches, top_nop: None, }; @@ -117,9 +116,9 @@ fn trans_fn<'a, 'tcx: 'a>( // Step 9. Define function // TODO: cranelift doesn't yet support some of the things needed if should_codegen(tcx.sess) { - context.func = func; - module.define_function(func_id, context).unwrap(); - context.clear(); + caches.context.func = func; + module.define_function(func_id, &mut caches.context).unwrap(); + caches.context.clear(); } } diff --git a/src/common.rs b/src/common.rs index 7a8cc53b8d5..8f0236fb7f0 100644 --- a/src/common.rs +++ b/src/common.rs @@ -427,6 +427,7 @@ pub struct FunctionCx<'a, 'tcx: 'a, B: Backend + 'a> { pub local_map: HashMap>, pub comments: HashMap, pub constants: &'a mut crate::constant::ConstantCx, + pub caches: &'a mut Caches, /// add_global_comment inserts a comment here pub top_nop: Option,