Skip to content

Commit 3855a90

Browse files
authored
Merge pull request rust-lang#729 from bjorn3/misc_changes
Update cranelift and use crates.io version of gimli
2 parents 0f938f6 + 58a9b64 commit 3855a90

File tree

8 files changed

+85
-75
lines changed

8 files changed

+85
-75
lines changed

Cargo.lock

Lines changed: 61 additions & 53 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ ar = "0.8.0"
2222
bitflags = "1.1.0"
2323
byteorder = "1.2.7"
2424
libc = "0.2.53"
25-
gimli = { git = "https://github.com/gimli-rs/gimli.git" }
25+
gimli = "0.19.0"
2626
indexmap = "1.0.2"
2727
libloading = "0.5.1"
2828

@@ -38,7 +38,7 @@ features = ["compression", "read", "std"] # We don't need WASM support
3838
#cranelift-simplejit = { path = "../cranelift/cranelift-simplejit" }
3939
#cranelift-faerie = { path = "../cranelift/cranelift-faerie" }
4040

41-
#[patch."https://github.com/gimli-rs/gimli.git"]
41+
#[patch.crates-io]
4242
#gimli = { path = "../" }
4343

4444
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]

src/allocator.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ pub fn codegen_inner(sess: &Session, module: &mut Module<impl Backend + 'static>
7373
.unwrap();
7474

7575
let mut ctx = Context::new();
76-
ctx.func = {
77-
let mut bcx = FunctionBuilder::new(Function::with_name_signature(ExternalName::user(0, 0), sig.clone()));
76+
ctx.func = Function::with_name_signature(ExternalName::user(0, 0), sig.clone());
77+
{
78+
let mut func_ctx = FunctionBuilderContext::new();
79+
let mut bcx = FunctionBuilder::new(&mut ctx.func, &mut func_ctx);
7880

7981
let ebb = bcx.create_ebb();
8082
bcx.switch_to_block(ebb);
@@ -90,9 +92,8 @@ pub fn codegen_inner(sess: &Session, module: &mut Module<impl Backend + 'static>
9092
let results = bcx.inst_results(call_inst).to_vec(); // Clone to prevent borrow error
9193
bcx.ins().return_(&results);
9294
bcx.seal_all_blocks();
93-
bcx.finalize()
94-
};
95-
95+
bcx.finalize();
96+
}
9697
module.define_function(func_id, &mut ctx).unwrap();
9798
}
9899
}

src/base.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>(
1919
.as_mut()
2020
.map(|debug_context| FunctionDebugContext::new(tcx, debug_context, mir, &name, &sig));
2121

22-
// FIXME reuse Function and FunctionBuilder between multiple trans_fn calls
23-
let mut bcx = FunctionBuilder::new(Function::with_name_signature(ExternalName::user(0, 0), sig));
22+
// Make FunctionBuilder
23+
let mut func = Function::with_name_signature(ExternalName::user(0, 0), sig);
24+
let mut func_ctx = FunctionBuilderContext::new();
25+
let mut bcx = FunctionBuilder::new(&mut func, &mut func_ctx);
2426

2527
// Predefine ebb's
2628
let start_ebb = bcx.create_ebb();
@@ -56,9 +58,6 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>(
5658
codegen_fn_content(&mut fx);
5759
});
5860

59-
fx.bcx.seal_all_blocks();
60-
let func = fx.bcx.finalize();
61-
6261
// Recover all necessary data from fx, before accessing func will prevent future access to it.
6362
let instance = fx.instance;
6463
let clif_comments = fx.clif_comments;
@@ -239,6 +238,9 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) {
239238
}
240239
};
241240
}
241+
242+
fx.bcx.seal_all_blocks();
243+
fx.bcx.finalize();
242244
}
243245

244246
fn trans_stmt<'tcx>(

src/codegen_i128.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ pub fn maybe_codegen<'tcx>(
9898
// Optimize `val >> 64`, because compiler_builtins uses it to deconstruct an 128bit
9999
// integer into its lsb and msb.
100100
// https://github.com/rust-lang-nursery/compiler-builtins/blob/79a6a1603d5672cbb9187ff41ff4d9b5048ac1cb/src/int/mod.rs#L217
101-
if let Some(64) = resolve_value_imm(&fx.bcx.func, rhs_val) {
101+
if let Some(64) = resolve_value_imm(fx.bcx.func, rhs_val) {
102102
let (lhs_lsb, lhs_msb) = fx.bcx.ins().isplit(lhs_val);
103103
let all_zeros = fx.bcx.ins().iconst(types::I64, 0);
104104
let val = match (bin_op, is_signed) {

src/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ pub struct FunctionCx<'clif, 'tcx, B: Backend + 'static> {
279279
pub instance: Instance<'tcx>,
280280
pub mir: &'tcx Body<'tcx>,
281281

282-
pub bcx: FunctionBuilder,
282+
pub bcx: FunctionBuilder<'clif>,
283283
pub ebb_map: HashMap<BasicBlock, Ebb>,
284284
pub local_map: HashMap<Local, CPlace<'tcx>>,
285285

src/main_shim.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ pub fn maybe_create_entry_wrapper(tcx: TyCtxt<'_>, module: &mut Module<impl Back
5656
.unwrap();
5757

5858
let mut ctx = Context::new();
59-
ctx.func = {
60-
let mut bcx: FunctionBuilder = FunctionBuilder::new(
61-
Function::with_name_signature(ExternalName::user(0, 0), cmain_sig.clone())
62-
);
59+
ctx.func = Function::with_name_signature(ExternalName::user(0, 0), cmain_sig.clone());
60+
{
61+
let mut func_ctx = FunctionBuilderContext::new();
62+
let mut bcx: FunctionBuilder = FunctionBuilder::new(&mut ctx.func, &mut func_ctx);
6363

6464
let ebb = bcx.create_ebb();
6565
bcx.switch_to_block(ebb);
@@ -93,9 +93,8 @@ pub fn maybe_create_entry_wrapper(tcx: TyCtxt<'_>, module: &mut Module<impl Back
9393
let result = bcx.inst_results(call_inst)[0];
9494
bcx.ins().return_(&[result]);
9595
bcx.seal_all_blocks();
96-
bcx.finalize()
97-
};
98-
96+
bcx.finalize();
97+
}
9998
m.define_function(cmain_func_id, &mut ctx).unwrap();
10099
}
101100
}

src/trap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, impl cranelift_module::Backend>, ms
3636
// Ignore DuplicateDefinition error, as the data will be the same
3737
let _ = fx.module.define_data(msg_id, &data_ctx);
3838

39-
let local_msg_id = fx.module.declare_data_in_func(msg_id, &mut fx.bcx.func);
39+
let local_msg_id = fx.module.declare_data_in_func(msg_id, fx.bcx.func);
4040
#[cfg(debug_assertions)]
4141
{
4242
fx.add_entity_comment(local_msg_id, msg);

0 commit comments

Comments
 (0)