Skip to content

Commit 450257c

Browse files
authored
Merge pull request rust-lang#1295 from bjorn3/update_cranelift
Update Cranelift to 0.90.0
2 parents 3cf8994 + a54a377 commit 450257c

File tree

13 files changed

+95
-162
lines changed

13 files changed

+95
-162
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ crate-type = ["dylib"]
1515

1616
[dependencies]
1717
# These have to be in sync with each other
18-
cranelift-codegen = { version = "0.89.1", features = ["unwind", "all-arch"] }
19-
cranelift-frontend = "0.89.1"
20-
cranelift-module = "0.89.1"
21-
cranelift-native = "0.89.1"
22-
cranelift-jit = { version = "0.89.1", optional = true }
23-
cranelift-object = "0.89.1"
18+
cranelift-codegen = { version = "0.90.1", features = ["unwind", "all-arch"] }
19+
cranelift-frontend = "0.90.1"
20+
cranelift-module = "0.90.1"
21+
cranelift-native = "0.90.1"
22+
cranelift-jit = { version = "0.90.1", optional = true }
23+
cranelift-object = "0.90.1"
2424
target-lexicon = "0.12.0"
2525
gimli = { version = "0.26.0", default-features = false, features = ["write"]}
2626
object = { version = "0.29.0", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] }

src/base.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -388,11 +388,9 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
388388
_ => unreachable!("{:?}", targets),
389389
};
390390

391-
let discr = crate::optimize::peephole::maybe_unwrap_bint(&mut fx.bcx, discr);
392391
let (discr, is_inverted) =
393392
crate::optimize::peephole::maybe_unwrap_bool_not(&mut fx.bcx, discr);
394393
let test_zero = if is_inverted { !test_zero } else { test_zero };
395-
let discr = crate::optimize::peephole::maybe_unwrap_bint(&mut fx.bcx, discr);
396394
if let Some(taken) = crate::optimize::peephole::maybe_known_branch_taken(
397395
&fx.bcx, discr, test_zero,
398396
) {
@@ -569,20 +567,14 @@ fn codegen_stmt<'tcx>(
569567
UnOp::Not => match layout.ty.kind() {
570568
ty::Bool => {
571569
let res = fx.bcx.ins().icmp_imm(IntCC::Equal, val, 0);
572-
CValue::by_val(fx.bcx.ins().bint(types::I8, res), layout)
570+
CValue::by_val(res, layout)
573571
}
574572
ty::Uint(_) | ty::Int(_) => {
575573
CValue::by_val(fx.bcx.ins().bnot(val), layout)
576574
}
577575
_ => unreachable!("un op Not for {:?}", layout.ty),
578576
},
579577
UnOp::Neg => match layout.ty.kind() {
580-
ty::Int(IntTy::I128) => {
581-
// FIXME remove this case once ineg.i128 works
582-
let zero =
583-
CValue::const_val(fx, layout, ty::ScalarInt::null(layout.size));
584-
crate::num::codegen_int_binop(fx, BinOp::Sub, zero, operand)
585-
}
586578
ty::Int(_) => CValue::by_val(fx.bcx.ins().ineg(val), layout),
587579
ty::Float(_) => CValue::by_val(fx.bcx.ins().fneg(val), layout),
588580
_ => unreachable!("un op Neg for {:?}", layout.ty),

src/cast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ pub(crate) fn clif_int_or_float_cast(
149149
}
150150

151151
let is_not_nan = fx.bcx.ins().fcmp(FloatCC::Equal, from, from);
152-
let zero = fx.bcx.ins().iconst(to_ty, 0);
152+
let zero = type_zero_value(&mut fx.bcx, to_ty);
153153
fx.bcx.ins().select(is_not_nan, val, zero)
154154
} else if from_ty.is_float() && to_ty.is_float() {
155155
// float -> float

src/common.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,15 @@ pub(crate) fn codegen_icmp_imm(
167167
}
168168
}
169169

170+
pub(crate) fn type_zero_value(bcx: &mut FunctionBuilder<'_>, ty: Type) -> Value {
171+
if ty == types::I128 {
172+
let zero = bcx.ins().iconst(types::I64, 0);
173+
bcx.ins().iconcat(zero, zero)
174+
} else {
175+
bcx.ins().iconst(ty, 0)
176+
}
177+
}
178+
170179
pub(crate) fn type_min_max_value(
171180
bcx: &mut FunctionBuilder<'_>,
172181
ty: Type,

src/debuginfo/unwind.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ impl UnwindContext {
3939
}
4040

4141
pub(crate) fn add_function(&mut self, func_id: FuncId, context: &Context, isa: &dyn TargetIsa) {
42-
let unwind_info = if let Some(unwind_info) = context.create_unwind_info(isa).unwrap() {
42+
let unwind_info = if let Some(unwind_info) =
43+
context.compiled_code().unwrap().create_unwind_info(isa).unwrap()
44+
{
4345
unwind_info
4446
} else {
4547
return;

src/discriminant.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,14 @@ pub(crate) fn codegen_get_discriminant<'tcx>(
278278
fx.bcx.ins().iadd(tagged_discr, delta)
279279
};
280280

281-
let untagged_variant =
282-
fx.bcx.ins().iconst(cast_to, i64::from(untagged_variant.as_u32()));
281+
let untagged_variant = if cast_to == types::I128 {
282+
let zero = fx.bcx.ins().iconst(types::I64, 0);
283+
let untagged_variant =
284+
fx.bcx.ins().iconst(types::I64, i64::from(untagged_variant.as_u32()));
285+
fx.bcx.ins().iconcat(untagged_variant, zero)
286+
} else {
287+
fx.bcx.ins().iconst(cast_to, i64::from(untagged_variant.as_u32()))
288+
};
283289
let discr = fx.bcx.ins().select(is_niche, tagged_discr, untagged_variant);
284290
let res = CValue::by_val(discr, dest_layout);
285291
dest.write_cvalue(fx, res);

src/driver/jit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ pub(crate) fn run_jit(tcx: TyCtxt<'_>, backend_config: BackendConfig) -> ! {
159159

160160
tcx.sess.abort_if_errors();
161161

162-
jit_module.finalize_definitions();
162+
jit_module.finalize_definitions().unwrap();
163163
unsafe { cx.unwind_context.register_jit(&jit_module) };
164164

165165
println!(
@@ -278,7 +278,7 @@ fn jit_fn(instance_ptr: *const Instance<'static>, trampoline_ptr: *const u8) ->
278278
});
279279

280280
assert!(cx.global_asm.is_empty());
281-
jit_module.finalize_definitions();
281+
jit_module.finalize_definitions().unwrap();
282282
unsafe { cx.unwind_context.register_jit(&jit_module) };
283283
jit_module.get_finalized_function(func_id)
284284
})

0 commit comments

Comments
 (0)