Skip to content

Commit 71482b5

Browse files
authored
Merge pull request #700 from bjorn3/upstream_cranelift
Use upstream cranelift
2 parents b0e5c78 + 3a8dd34 commit 71482b5

File tree

8 files changed

+109
-109
lines changed

8 files changed

+109
-109
lines changed

Cargo.lock

Lines changed: 87 additions & 79 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 & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ crate-type = ["dylib"]
1414
cranelift = { git = "https://github.com/CraneStation/cranelift.git" }
1515
cranelift-module = { git = "https://github.com/CraneStation/cranelift.git" }
1616
cranelift-faerie = { git = "https://github.com/CraneStation/cranelift.git" }
17-
target-lexicon = "0.4.0"
18-
faerie = "0.10.2"
17+
target-lexicon = "0.8.1"
18+
faerie = "0.11.0"
1919

2020
#goblin = "0.0.17"
2121
ar = "0.8.0"
@@ -28,12 +28,6 @@ indexmap = "1.0.2"
2828
object = "0.12.0"
2929
libloading = "0.5.1"
3030

31-
[patch."https://github.com/CraneStation/cranelift.git"]
32-
cranelift = { git = "https://github.com/bjorn3/cretonne.git", branch = "do_not_remove_cg_clif_i128" }
33-
cranelift-module = { git = "https://github.com/bjorn3/cretonne.git", branch = "do_not_remove_cg_clif_i128" }
34-
cranelift-simplejit = { git = "https://github.com/bjorn3/cretonne.git", branch = "do_not_remove_cg_clif_i128" }
35-
cranelift-faerie = { git = "https://github.com/bjorn3/cretonne.git", branch = "do_not_remove_cg_clif_i128" }
36-
3731
# Uncomment to use local checkout of cranelift
3832
#[patch."https://github.com/CraneStation/cranelift.git"]
3933
#cranelift = { path = "../cranelift/cranelift-umbrella" }

src/allocator.rs

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

7575
let mut ctx = Context::new();
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);
76+
ctx.func = {
77+
let mut bcx = FunctionBuilder::new(Function::with_name_signature(ExternalName::user(0, 0), sig.clone()));
8078

8179
let ebb = bcx.create_ebb();
8280
bcx.switch_to_block(ebb);
@@ -92,8 +90,9 @@ pub fn codegen_inner(module: &mut Module<impl Backend + 'static>, kind: Allocato
9290
let results = bcx.inst_results(call_inst).to_vec(); // Clone to prevent borrow error
9391
bcx.ins().return_(&results);
9492
bcx.seal_all_blocks();
95-
bcx.finalize();
96-
}
93+
bcx.finalize()
94+
};
95+
9796
module.define_function(func_id, &mut ctx).unwrap();
9897
}
9998
}

src/base.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ 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-
// 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);
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));
2624

2725
// Predefine ebb's
2826
let start_ebb = bcx.create_ebb();
@@ -58,6 +56,9 @@ pub fn trans_fn<'clif, 'tcx, B: Backend + 'static>(
5856
codegen_fn_content(&mut fx);
5957
});
6058

59+
fx.bcx.seal_all_blocks();
60+
let func = fx.bcx.finalize();
61+
6162
// Recover all necessary data from fx, before accessing func will prevent future access to it.
6263
let instance = fx.instance;
6364
let clif_comments = fx.clif_comments;
@@ -238,9 +239,6 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) {
238239
}
239240
};
240241
}
241-
242-
fx.bcx.seal_all_blocks();
243-
fx.bcx.finalize();
244242
}
245243

246244
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
@@ -269,7 +269,7 @@ pub struct FunctionCx<'clif, 'tcx, B: Backend + 'static> {
269269
pub instance: Instance<'tcx>,
270270
pub mir: &'tcx Body<'tcx>,
271271

272-
pub bcx: FunctionBuilder<'clif>,
272+
pub bcx: FunctionBuilder,
273273
pub ebb_map: HashMap<BasicBlock, Ebb>,
274274
pub local_map: HashMap<Local, CPlace<'tcx>>,
275275

src/main_shim.rs

Lines changed: 7 additions & 6 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 = 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);
59+
ctx.func = {
60+
let mut bcx: FunctionBuilder = FunctionBuilder::new(
61+
Function::with_name_signature(ExternalName::user(0, 0), cmain_sig.clone())
62+
);
6363

6464
let ebb = bcx.create_ebb();
6565
bcx.switch_to_block(ebb);
@@ -93,8 +93,9 @@ 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-
}
96+
bcx.finalize()
97+
};
98+
9899
m.define_function(cmain_func_id, &mut ctx).unwrap();
99100
}
100101
}

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

0 commit comments

Comments
 (0)