Skip to content

Commit debd45c

Browse files
committed
Update to cranelift 0.91
Closes rust-lang#1307
1 parent 8b47801 commit debd45c

File tree

7 files changed

+76
-54
lines changed

7 files changed

+76
-54
lines changed

Cargo.lock

+54-40
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+6-6
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.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"
18+
cranelift-codegen = { version = "0.91", features = ["unwind", "all-arch"] }
19+
cranelift-frontend = "0.91"
20+
cranelift-module = "0.91"
21+
cranelift-native = "0.91"
22+
cranelift-jit = { version = "0.91", optional = true }
23+
cranelift-object = "0.91"
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

+2-3
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ pub(crate) fn codegen_fn<'tcx>(
113113
};
114114

115115
tcx.sess.time("codegen clif ir", || codegen_fn_body(&mut fx, start_block));
116+
fx.bcx.seal_all_blocks();
117+
fx.bcx.finalize();
116118

117119
// Recover all necessary data from fx, before accessing func will prevent future access to it.
118120
let symbol_name = fx.symbol_name;
@@ -487,9 +489,6 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
487489
}
488490
};
489491
}
490-
491-
fx.bcx.seal_all_blocks();
492-
fx.bcx.finalize();
493492
}
494493

495494
fn codegen_stmt<'tcx>(

src/common.rs

+9
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 codegen_bitcast(fx: &mut FunctionCx<'_, '_, '_>, dst_ty: Type, val: Value) -> Value {
171+
let mut flags = MemFlags::new();
172+
flags.set_endianness(match fx.tcx.data_layout.endian {
173+
rustc_target::abi::Endian::Big => cranelift_codegen::ir::Endianness::Big,
174+
rustc_target::abi::Endian::Little => cranelift_codegen::ir::Endianness::Little,
175+
});
176+
fx.bcx.ins().bitcast(dst_ty, flags, val)
177+
}
178+
170179
pub(crate) fn type_zero_value(bcx: &mut FunctionBuilder<'_>, ty: Type) -> Value {
171180
if ty == types::I128 {
172181
let zero = bcx.ins().iconst(types::I64, 0);

src/intrinsics/llvm_x86.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
3333

3434
// cast float to int
3535
let a_lane = match lane_ty {
36-
types::F32 => fx.bcx.ins().bitcast(types::I32, a_lane),
37-
types::F64 => fx.bcx.ins().bitcast(types::I64, a_lane),
36+
types::F32 => codegen_bitcast(fx, types::I32, a_lane),
37+
types::F64 => codegen_bitcast(fx, types::I64, a_lane),
3838
_ => a_lane,
3939
};
4040

src/intrinsics/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ fn bool_to_zero_or_max_uint<'tcx>(
200200
let mut res = fx.bcx.ins().bmask(int_ty, val);
201201

202202
if ty.is_float() {
203-
res = fx.bcx.ins().bitcast(ty, res);
203+
res = codegen_bitcast(fx, ty, res);
204204
}
205205

206206
res

src/value_and_place.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -514,8 +514,8 @@ impl<'tcx> CPlace<'tcx> {
514514
(types::I32, types::F32)
515515
| (types::F32, types::I32)
516516
| (types::I64, types::F64)
517-
| (types::F64, types::I64) => fx.bcx.ins().bitcast(dst_ty, data),
518-
_ if src_ty.is_vector() && dst_ty.is_vector() => fx.bcx.ins().bitcast(dst_ty, data),
517+
| (types::F64, types::I64) => codegen_bitcast(fx, dst_ty, data),
518+
_ if src_ty.is_vector() && dst_ty.is_vector() => codegen_bitcast(fx, dst_ty, data),
519519
_ if src_ty.is_vector() || dst_ty.is_vector() => {
520520
// FIXME do something more efficient for transmutes between vectors and integers.
521521
let stack_slot = fx.bcx.create_sized_stack_slot(StackSlotData {

0 commit comments

Comments
 (0)