From 8cee28db3e3a585022666bc0cec3b6702a448f65 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 28 Sep 2019 17:49:11 +0200 Subject: [PATCH 1/2] Switch back to crates.io version of gimli Fixes #727 --- Cargo.lock | 6 +++--- Cargo.toml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 97463d483b9..1757ded68b2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -248,7 +248,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "gimli" version = "0.19.0" -source = "git+https://github.com/gimli-rs/gimli.git#7e76a9d56623da413f4fc2ea0e553cafe51bbfb8" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -400,7 +400,7 @@ dependencies = [ "cranelift-module 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", "cranelift-simplejit 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "gimli 0.19.0 (git+https://github.com/gimli-rs/gimli.git)", + "gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -575,7 +575,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" "checksum flate2 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "2adaffba6388640136149e18ed080b77a78611c1e1d6de75aedcdf78df5d4682" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" -"checksum gimli 0.19.0 (git+https://github.com/gimli-rs/gimli.git)" = "" +"checksum gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "162d18ae5f2e3b90a993d202f1ba17a5633c2484426f8bcae201f86194bacd00" "checksum goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)" = "e3fa261d919c1ae9d1e4533c4a2f99e10938603c4208d56c05bec7a872b661b0" "checksum indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a61202fbe46c4a951e9404a720a0180bcf3212c750d735cb5c4ba4dc551299f3" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" diff --git a/Cargo.toml b/Cargo.toml index 6cae573c8bd..74e1dda7e04 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ ar = "0.8.0" bitflags = "1.1.0" byteorder = "1.2.7" libc = "0.2.53" -gimli = { git = "https://github.com/gimli-rs/gimli.git" } +gimli = "0.19.0" indexmap = "1.0.2" libloading = "0.5.1" @@ -38,7 +38,7 @@ features = ["compression", "read", "std"] # We don't need WASM support #cranelift-simplejit = { path = "../cranelift/cranelift-simplejit" } #cranelift-faerie = { path = "../cranelift/cranelift-faerie" } -#[patch."https://github.com/gimli-rs/gimli.git"] +#[patch.crates-io] #gimli = { path = "../" } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] From 58a9b648e830bef11864db8f657a2eac944ea552 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 28 Sep 2019 17:59:27 +0200 Subject: [PATCH 2/2] Update cranelift, faerie and target-lexicon --- Cargo.lock | 108 ++++++++++++++++++++++++-------------------- src/allocator.rs | 11 +++-- src/base.rs | 12 +++-- src/codegen_i128.rs | 2 +- src/common.rs | 2 +- src/main_shim.rs | 13 +++--- src/trap.rs | 2 +- 7 files changed, 80 insertions(+), 70 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1757ded68b2..780571887c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -60,29 +60,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cranelift" -version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#8945b82f92642f621d32fead437abd174b52f709" +version = "0.44.0" +source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" dependencies = [ - "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-frontend 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-frontend 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-bforest" -version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#8945b82f92642f621d32fead437abd174b52f709" +version = "0.44.0" +source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" dependencies = [ - "cranelift-entity 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", ] [[package]] name = "cranelift-codegen" -version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#8945b82f92642f621d32fead437abd174b52f709" +version = "0.44.0" +source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" dependencies = [ - "cranelift-bforest 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-codegen-meta 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-bforest 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-meta 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-shared 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -92,24 +93,30 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#8945b82f92642f621d32fead437abd174b52f709" +version = "0.44.0" +source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" dependencies = [ - "cranelift-entity 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen-shared 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", ] +[[package]] +name = "cranelift-codegen-shared" +version = "0.44.0" +source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" + [[package]] name = "cranelift-entity" -version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#8945b82f92642f621d32fead437abd174b52f709" +version = "0.44.0" +source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" [[package]] name = "cranelift-faerie" -version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#8945b82f92642f621d32fead437abd174b52f709" +version = "0.44.0" +source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" dependencies = [ - "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)", @@ -118,10 +125,10 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#8945b82f92642f621d32fead437abd174b52f709" +version = "0.44.0" +source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" dependencies = [ - "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -129,33 +136,33 @@ dependencies = [ [[package]] name = "cranelift-module" -version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#8945b82f92642f621d32fead437abd174b52f709" +version = "0.44.0" +source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" dependencies = [ - "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-entity 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-entity 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-native" -version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#8945b82f92642f621d32fead437abd174b52f709" +version = "0.44.0" +source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" dependencies = [ - "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "target-lexicon 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "cranelift-simplejit" -version = "0.42.0" -source = "git+https://github.com/CraneStation/cranelift.git#8945b82f92642f621d32fead437abd174b52f709" +version = "0.44.0" +source = "git+https://github.com/CraneStation/cranelift.git#c7fd5d9a47198ecf87c06716b351909417fecf6f" dependencies = [ - "cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-native 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-native 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", "region 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -395,10 +402,10 @@ dependencies = [ "ar 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "cranelift 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-faerie 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-module 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", - "cranelift-simplejit 0.42.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-faerie 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-module 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", + "cranelift-simplejit 0.44.0 (git+https://github.com/CraneStation/cranelift.git)", "faerie 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "gimli 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -556,16 +563,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" "checksum cc 1.0.45 (registry+https://github.com/rust-lang/crates.io-index)" = "4fc9a35e1f4290eb9e5fc54ba6cf40671ed2a2514c3eeb2b2a908dda2ea5a1be" "checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" -"checksum cranelift 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-bforest 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-codegen-meta 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-entity 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-faerie 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-frontend 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-module 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-native 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" -"checksum cranelift-simplejit 0.42.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-bforest 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen-meta 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-codegen-shared 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-entity 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-faerie 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-frontend 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-module 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-native 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" +"checksum cranelift-simplejit 0.44.0 (git+https://github.com/CraneStation/cranelift.git)" = "" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e" "checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" diff --git a/src/allocator.rs b/src/allocator.rs index c4222a858ab..29e3ceb3a5a 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -73,8 +73,10 @@ pub fn codegen_inner(sess: &Session, module: &mut Module .unwrap(); let mut ctx = Context::new(); - ctx.func = { - let mut bcx = FunctionBuilder::new(Function::with_name_signature(ExternalName::user(0, 0), sig.clone())); + ctx.func = Function::with_name_signature(ExternalName::user(0, 0), sig.clone()); + { + let mut func_ctx = FunctionBuilderContext::new(); + let mut bcx = FunctionBuilder::new(&mut ctx.func, &mut func_ctx); let ebb = bcx.create_ebb(); bcx.switch_to_block(ebb); @@ -90,9 +92,8 @@ pub fn codegen_inner(sess: &Session, module: &mut Module let results = bcx.inst_results(call_inst).to_vec(); // Clone to prevent borrow error bcx.ins().return_(&results); bcx.seal_all_blocks(); - bcx.finalize() - }; - + bcx.finalize(); + } module.define_function(func_id, &mut ctx).unwrap(); } } diff --git a/src/base.rs b/src/base.rs index e58ab93158a..7cb079567f1 100644 --- a/src/base.rs +++ b/src/base.rs @@ -19,8 +19,10 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( .as_mut() .map(|debug_context| FunctionDebugContext::new(tcx, debug_context, mir, &name, &sig)); - // FIXME reuse Function and FunctionBuilder between multiple trans_fn calls - let mut bcx = FunctionBuilder::new(Function::with_name_signature(ExternalName::user(0, 0), sig)); + // Make FunctionBuilder + let mut func = Function::with_name_signature(ExternalName::user(0, 0), sig); + let mut func_ctx = FunctionBuilderContext::new(); + let mut bcx = FunctionBuilder::new(&mut func, &mut func_ctx); // Predefine ebb's let start_ebb = bcx.create_ebb(); @@ -56,9 +58,6 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>( codegen_fn_content(&mut fx); }); - fx.bcx.seal_all_blocks(); - let func = fx.bcx.finalize(); - // Recover all necessary data from fx, before accessing func will prevent future access to it. let instance = fx.instance; let clif_comments = fx.clif_comments; @@ -239,6 +238,9 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) { } }; } + + fx.bcx.seal_all_blocks(); + fx.bcx.finalize(); } fn trans_stmt<'tcx>( diff --git a/src/codegen_i128.rs b/src/codegen_i128.rs index 2d2aa7e1a1d..6653b4e2d91 100644 --- a/src/codegen_i128.rs +++ b/src/codegen_i128.rs @@ -98,7 +98,7 @@ pub fn maybe_codegen<'tcx>( // Optimize `val >> 64`, because compiler_builtins uses it to deconstruct an 128bit // integer into its lsb and msb. // https://github.com/rust-lang-nursery/compiler-builtins/blob/79a6a1603d5672cbb9187ff41ff4d9b5048ac1cb/src/int/mod.rs#L217 - if let Some(64) = resolve_value_imm(&fx.bcx.func, rhs_val) { + if let Some(64) = resolve_value_imm(fx.bcx.func, rhs_val) { let (lhs_lsb, lhs_msb) = fx.bcx.ins().isplit(lhs_val); let all_zeros = fx.bcx.ins().iconst(types::I64, 0); let val = match (bin_op, is_signed) { diff --git a/src/common.rs b/src/common.rs index 85778f4c8e9..3ebae0506c5 100644 --- a/src/common.rs +++ b/src/common.rs @@ -279,7 +279,7 @@ pub struct FunctionCx<'clif, 'tcx, B: Backend + 'static> { pub instance: Instance<'tcx>, pub mir: &'tcx Body<'tcx>, - pub bcx: FunctionBuilder, + pub bcx: FunctionBuilder<'clif>, pub ebb_map: HashMap, pub local_map: HashMap>, diff --git a/src/main_shim.rs b/src/main_shim.rs index 788b65a8230..17783b01d26 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -56,10 +56,10 @@ pub fn maybe_create_entry_wrapper(tcx: TyCtxt<'_>, module: &mut Module, module: &mut Module, ms // Ignore DuplicateDefinition error, as the data will be the same let _ = fx.module.define_data(msg_id, &data_ctx); - let local_msg_id = fx.module.declare_data_in_func(msg_id, &mut fx.bcx.func); + let local_msg_id = fx.module.declare_data_in_func(msg_id, fx.bcx.func); #[cfg(debug_assertions)] { fx.add_entity_comment(local_msg_id, msg);