From 98dae86d214226b2d9bf400bae39f040f279821b Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 4 May 2019 16:15:20 +0200 Subject: [PATCH] Update cranelift --- Cargo.lock | 20 ++++++++++---------- src/constant.rs | 9 +++++---- src/lib.rs | 6 ++++-- src/trap.rs | 2 +- src/vtable.rs | 1 + 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 21ab665f3ae4..19ef265e754a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,7 +114,7 @@ dependencies = [ [[package]] name = "cranelift" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" +source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-frontend 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "cranelift-bforest" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" +source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -131,7 +131,7 @@ dependencies = [ [[package]] name = "cranelift-codegen" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" +source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968" dependencies = [ "cranelift-bforest 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen-meta 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -145,7 +145,7 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" +source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968" dependencies = [ "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", ] @@ -153,12 +153,12 @@ dependencies = [ [[package]] name = "cranelift-entity" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" +source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968" [[package]] name = "cranelift-faerie" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" +source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" +source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -181,7 +181,7 @@ dependencies = [ [[package]] name = "cranelift-module" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" +source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", @@ -192,7 +192,7 @@ dependencies = [ [[package]] name = "cranelift-native" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" +source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -202,7 +202,7 @@ dependencies = [ [[package]] name = "cranelift-simplejit" version = "0.30.0" -source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" +source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968" dependencies = [ "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", diff --git a/src/constant.rs b/src/constant.rs index 87056f679a62..282f429d74de 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -179,7 +179,7 @@ fn trans_const_place<'a, 'tcx: 'a>( fn data_id_for_alloc_id(module: &mut Module, alloc_id: AllocId) -> DataId { module - .declare_data(&format!("__alloc_{}", alloc_id.0), Linkage::Local, false) + .declare_data(&format!("__alloc_{}", alloc_id.0), Linkage::Local, false, None) .unwrap() } @@ -190,15 +190,16 @@ fn data_id_for_static<'a, 'tcx: 'a, B: Backend>( linkage: Linkage, ) -> DataId { let symbol_name = tcx.symbol_name(Instance::mono(tcx, def_id)).as_str(); + let ty = tcx.type_of(def_id); let is_mutable = if tcx.is_mutable_static(def_id) { true } else { - !tcx.type_of(def_id) - .is_freeze(tcx, ParamEnv::reveal_all(), DUMMY_SP) + !ty.is_freeze(tcx, ParamEnv::reveal_all(), DUMMY_SP) }; + let align = tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap().align.pref.bytes(); let data_id = module - .declare_data(&*symbol_name, linkage, is_mutable) + .declare_data(&*symbol_name, linkage, is_mutable, Some(align.try_into().unwrap())) .unwrap(); if linkage == Linkage::Preemptible { diff --git a/src/lib.rs b/src/lib.rs index 562f9e5e5683..95eb75c22c82 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -57,6 +57,7 @@ mod vtable; mod prelude { pub use std::any::Any; pub use std::collections::{HashMap, HashSet}; + pub use std::convert::TryInto; pub use syntax::ast::{FloatTy, IntTy, UintTy}; pub use syntax::source_map::{Pos, Span, DUMMY_SP}; @@ -213,7 +214,8 @@ impl CodegenBackend for CraneliftCodegenBackend { }; if std::env::var("SHOULD_RUN").is_ok() { - let mut jit_module: Module = Module::new(SimpleJITBuilder::new()); + let mut jit_module: Module = + Module::new(SimpleJITBuilder::new(cranelift_module::default_libcall_names())); assert_eq!(pointer_ty(tcx), jit_module.target_config().pointer_type()); let sig = Signature { @@ -263,7 +265,7 @@ impl CodegenBackend for CraneliftCodegenBackend { build_isa(tcx.sess), name + ".o", FaerieTrapCollection::Disabled, - FaerieBuilder::default_libcall_names(), + cranelift_module::default_libcall_names(), ) .unwrap(), ); diff --git a/src/trap.rs b/src/trap.rs index f492bcf4b1eb..925d59ac255e 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -12,7 +12,7 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, ms let msg_bytes = format!("trap at {:?} ({}): {}\0", fx.instance, symbol_name, msg).into_bytes().into_boxed_slice(); let mut data_ctx = DataContext::new(); data_ctx.define(msg_bytes); - let msg_id = fx.module.declare_data(&(symbol_name.as_str().to_string() + msg), Linkage::Local, false).unwrap(); + let msg_id = fx.module.declare_data(&(symbol_name.as_str().to_string() + msg), Linkage::Local, false, None).unwrap(); // Ignore DuplicateDefinition error, as the data will be the same let _ = fx.module.define_data(msg_id, &data_ctx); diff --git a/src/vtable.rs b/src/vtable.rs index 5c3d62e22bb4..a19b6b458c40 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -136,6 +136,7 @@ fn build_vtable<'a, 'tcx: 'a>( &format!("vtable.{:?}.for.{:?}", trait_ref, ty), Linkage::Local, false, + Some(fx.tcx.data_layout.pointer_align.pref.bytes().try_into().unwrap()) ) .unwrap();