This commit is contained in:
bjorn3
2018-08-13 18:04:39 +02:00
parent d331758f6d
commit c7ed1ce033
2 changed files with 12 additions and 10 deletions

View File

@@ -11,7 +11,11 @@ pub struct ConstantCx {
} }
impl ConstantCx { impl ConstantCx {
pub fn finalize<'a, 'tcx: 'a, B: Backend>(mut self, tcx: TyCtxt<'a, 'tcx, 'tcx>, module: &mut Module<B>) { pub fn finalize<'a, 'tcx: 'a, B: Backend>(
mut self,
tcx: TyCtxt<'a, 'tcx, 'tcx>,
module: &mut Module<B>,
) {
println!("todo allocs: {:?}", self.todo_allocs); println!("todo allocs: {:?}", self.todo_allocs);
define_all_allocs(tcx, module, &mut self); define_all_allocs(tcx, module, &mut self);
println!("done {:?}", self.done); println!("done {:?}", self.done);
@@ -111,11 +115,7 @@ fn trans_const_place<'a, 'tcx: 'a>(
let alloc = fx.tcx.const_value_to_allocation(const_); let alloc = fx.tcx.const_value_to_allocation(const_);
//println!("const value: {:?} allocation: {:?}", value, alloc); //println!("const value: {:?} allocation: {:?}", value, alloc);
let alloc_id = fx.tcx.alloc_map.lock().allocate(alloc); let alloc_id = fx.tcx.alloc_map.lock().allocate(alloc);
let data_id = get_global_for_alloc_id( let data_id = get_global_for_alloc_id(fx.module, fx.constants, alloc_id);
fx.module,
fx.constants,
alloc_id,
);
let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); let local_data_id = fx.module.declare_data_in_func(data_id, &mut fx.bcx.func);
// TODO: does global_value return a ptr of a val? // TODO: does global_value return a ptr of a val?
let global_ptr = fx.bcx.ins().global_value(types::I64, local_data_id); let global_ptr = fx.bcx.ins().global_value(types::I64, local_data_id);
@@ -143,7 +143,7 @@ fn get_global_for_alloc_id<'a, 'tcx: 'a, B: Backend + 'a>(
data_id data_id
} }
fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a> ( fn define_all_allocs<'a, 'tcx: 'a, B: Backend + 'a>(
tcx: TyCtxt<'a, 'tcx, 'tcx>, tcx: TyCtxt<'a, 'tcx, 'tcx>,
module: &mut Module<B>, module: &mut Module<B>,
cx: &mut ConstantCx, cx: &mut ConstantCx,

View File

@@ -68,7 +68,7 @@ mod prelude {
self, subst::Substs, FnSig, Instance, InstanceDef, ParamEnv, PolyFnSig, Ty, TyCtxt, self, subst::Substs, FnSig, Instance, InstanceDef, ParamEnv, PolyFnSig, Ty, TyCtxt,
TypeAndMut, TypeFoldable, TypeVariants, TypeAndMut, TypeFoldable, TypeVariants,
}; };
pub use rustc_data_structures::{indexed_vec::Idx, sync::Lrc, fx::FxHashMap}; pub use rustc_data_structures::{fx::FxHashMap, indexed_vec::Idx, sync::Lrc};
pub use rustc_mir::monomorphize::{collector, MonoItem}; pub use rustc_mir::monomorphize::{collector, MonoItem};
pub use syntax::ast::{FloatTy, IntTy, UintTy}; pub use syntax::ast::{FloatTy, IntTy, UintTy};
pub use syntax::codemap::DUMMY_SP; pub use syntax::codemap::DUMMY_SP;
@@ -258,7 +258,9 @@ impl CodegenBackend for CraneliftCodegenBackend {
let mut log = ::std::fs::File::create("../target/log.txt").unwrap(); let mut log = ::std::fs::File::create("../target/log.txt").unwrap();
let before = ::std::time::Instant::now(); let before = ::std::time::Instant::now();
let mono_items = collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Eager).0; let mono_items =
collector::collect_crate_mono_items(tcx, collector::MonoItemCollectionMode::Eager)
.0;
// TODO: move to the end of this function when compiling libcore doesn't have unimplemented stuff anymore // TODO: move to the end of this function when compiling libcore doesn't have unimplemented stuff anymore
save_incremental(tcx); save_incremental(tcx);