Update cranelift

This commit is contained in:
bjorn3 2019-05-04 16:15:20 +02:00
parent 8598a34e45
commit 98dae86d21
5 changed files with 21 additions and 17 deletions

20
Cargo.lock generated
View File

@ -114,7 +114,7 @@ dependencies = [
[[package]] [[package]]
name = "cranelift" name = "cranelift"
version = "0.30.0" version = "0.30.0"
source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968"
dependencies = [ dependencies = [
"cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)",
"cranelift-frontend 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]] [[package]]
name = "cranelift-bforest" name = "cranelift-bforest"
version = "0.30.0" version = "0.30.0"
source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968"
dependencies = [ dependencies = [
"cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)",
] ]
@ -131,7 +131,7 @@ dependencies = [
[[package]] [[package]]
name = "cranelift-codegen" name = "cranelift-codegen"
version = "0.30.0" version = "0.30.0"
source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968"
dependencies = [ dependencies = [
"cranelift-bforest 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "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)", "cranelift-codegen-meta 0.30.0 (git+https://github.com/CraneStation/cranelift.git)",
@ -145,7 +145,7 @@ dependencies = [
[[package]] [[package]]
name = "cranelift-codegen-meta" name = "cranelift-codegen-meta"
version = "0.30.0" version = "0.30.0"
source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968"
dependencies = [ dependencies = [
"cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-entity 0.30.0 (git+https://github.com/CraneStation/cranelift.git)",
] ]
@ -153,12 +153,12 @@ dependencies = [
[[package]] [[package]]
name = "cranelift-entity" name = "cranelift-entity"
version = "0.30.0" version = "0.30.0"
source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968"
[[package]] [[package]]
name = "cranelift-faerie" name = "cranelift-faerie"
version = "0.30.0" version = "0.30.0"
source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968"
dependencies = [ dependencies = [
"cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)",
"cranelift-module 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]] [[package]]
name = "cranelift-frontend" name = "cranelift-frontend"
version = "0.30.0" version = "0.30.0"
source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968"
dependencies = [ dependencies = [
"cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "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)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -181,7 +181,7 @@ dependencies = [
[[package]] [[package]]
name = "cranelift-module" name = "cranelift-module"
version = "0.30.0" version = "0.30.0"
source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968"
dependencies = [ dependencies = [
"cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)",
"cranelift-entity 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]] [[package]]
name = "cranelift-native" name = "cranelift-native"
version = "0.30.0" version = "0.30.0"
source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968"
dependencies = [ dependencies = [
"cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "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)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -202,7 +202,7 @@ dependencies = [
[[package]] [[package]]
name = "cranelift-simplejit" name = "cranelift-simplejit"
version = "0.30.0" version = "0.30.0"
source = "git+https://github.com/CraneStation/cranelift.git#c0ee30f9a95bd80bd6485c21bad7e8e0b8c5caf0" source = "git+https://github.com/CraneStation/cranelift.git#a1d8fbc8dda7984edcf334c8e3d0e4ecd6c04968"
dependencies = [ dependencies = [
"cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-codegen 0.30.0 (git+https://github.com/CraneStation/cranelift.git)",
"cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-module 0.30.0 (git+https://github.com/CraneStation/cranelift.git)",

View File

@ -179,7 +179,7 @@ fn trans_const_place<'a, 'tcx: 'a>(
fn data_id_for_alloc_id<B: Backend>(module: &mut Module<B>, alloc_id: AllocId) -> DataId { fn data_id_for_alloc_id<B: Backend>(module: &mut Module<B>, alloc_id: AllocId) -> DataId {
module module
.declare_data(&format!("__alloc_{}", alloc_id.0), Linkage::Local, false) .declare_data(&format!("__alloc_{}", alloc_id.0), Linkage::Local, false, None)
.unwrap() .unwrap()
} }
@ -190,15 +190,16 @@ fn data_id_for_static<'a, 'tcx: 'a, B: Backend>(
linkage: Linkage, linkage: Linkage,
) -> DataId { ) -> DataId {
let symbol_name = tcx.symbol_name(Instance::mono(tcx, def_id)).as_str(); 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) { let is_mutable = if tcx.is_mutable_static(def_id) {
true true
} else { } else {
!tcx.type_of(def_id) !ty.is_freeze(tcx, ParamEnv::reveal_all(), DUMMY_SP)
.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 let data_id = module
.declare_data(&*symbol_name, linkage, is_mutable) .declare_data(&*symbol_name, linkage, is_mutable, Some(align.try_into().unwrap()))
.unwrap(); .unwrap();
if linkage == Linkage::Preemptible { if linkage == Linkage::Preemptible {

View File

@ -57,6 +57,7 @@ mod vtable;
mod prelude { mod prelude {
pub use std::any::Any; pub use std::any::Any;
pub use std::collections::{HashMap, HashSet}; pub use std::collections::{HashMap, HashSet};
pub use std::convert::TryInto;
pub use syntax::ast::{FloatTy, IntTy, UintTy}; pub use syntax::ast::{FloatTy, IntTy, UintTy};
pub use syntax::source_map::{Pos, Span, DUMMY_SP}; 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() { if std::env::var("SHOULD_RUN").is_ok() {
let mut jit_module: Module<SimpleJITBackend> = Module::new(SimpleJITBuilder::new()); let mut jit_module: Module<SimpleJITBackend> =
Module::new(SimpleJITBuilder::new(cranelift_module::default_libcall_names()));
assert_eq!(pointer_ty(tcx), jit_module.target_config().pointer_type()); assert_eq!(pointer_ty(tcx), jit_module.target_config().pointer_type());
let sig = Signature { let sig = Signature {
@ -263,7 +265,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
build_isa(tcx.sess), build_isa(tcx.sess),
name + ".o", name + ".o",
FaerieTrapCollection::Disabled, FaerieTrapCollection::Disabled,
FaerieBuilder::default_libcall_names(), cranelift_module::default_libcall_names(),
) )
.unwrap(), .unwrap(),
); );

View File

@ -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 msg_bytes = format!("trap at {:?} ({}): {}\0", fx.instance, symbol_name, msg).into_bytes().into_boxed_slice();
let mut data_ctx = DataContext::new(); let mut data_ctx = DataContext::new();
data_ctx.define(msg_bytes); 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 // Ignore DuplicateDefinition error, as the data will be the same
let _ = fx.module.define_data(msg_id, &data_ctx); let _ = fx.module.define_data(msg_id, &data_ctx);

View File

@ -136,6 +136,7 @@ fn build_vtable<'a, 'tcx: 'a>(
&format!("vtable.{:?}.for.{:?}", trait_ref, ty), &format!("vtable.{:?}.for.{:?}", trait_ref, ty),
Linkage::Local, Linkage::Local,
false, false,
Some(fx.tcx.data_layout.pointer_align.pref.bytes().try_into().unwrap())
) )
.unwrap(); .unwrap();