Skip to content

Commit 93703a4

Browse files
authored
Merge pull request #1283 from bjorn3/update_cranelift
Update to Cranelift 0.88.1
2 parents 7dccb51 + fb71d8a commit 93703a4

File tree

7 files changed

+63
-60
lines changed

7 files changed

+63
-60
lines changed

Cargo.lock

+36-22
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
@@ -8,12 +8,12 @@ crate-type = ["dylib"]
88

99
[dependencies]
1010
# These have to be in sync with each other
11-
cranelift-codegen = { version = "0.87.0", features = ["unwind", "all-arch"] }
12-
cranelift-frontend = "0.87.0"
13-
cranelift-module = "0.87.0"
14-
cranelift-native = "0.87.0"
15-
cranelift-jit = { version = "0.87.0", optional = true }
16-
cranelift-object = "0.87.0"
11+
cranelift-codegen = { version = "0.88.1", features = ["unwind", "all-arch"] }
12+
cranelift-frontend = "0.88.1"
13+
cranelift-module = "0.88.1"
14+
cranelift-native = "0.88.1"
15+
cranelift-jit = { version = "0.88.1", optional = true }
16+
cranelift-object = "0.88.1"
1717
target-lexicon = "0.12.0"
1818
gimli = { version = "0.26.0", default-features = false, features = ["write"]}
1919
object = { version = "0.29.0", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] }

example/issue-91827-extern-types.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// Test that we can handle unsized types with an extern type tail part.
66
// Regression test for issue #91827.
77

8-
#![feature(const_ptr_offset_from)]
98
#![feature(extern_types)]
109

1110
use std::ptr::addr_of;

patches/0001-abi-cafe-Disable-failing-tests.patch

+1-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ diff --git a/src/report.rs b/src/report.rs
1111
index 7346f5e..8347762 100644
1212
--- a/src/report.rs
1313
+++ b/src/report.rs
14-
@@ -45,6 +45,20 @@ pub fn get_test_rules(test: &TestKey, caller: &dyn AbiImpl, callee: &dyn AbiImpl
14+
@@ -45,6 +45,13 @@ pub fn get_test_rules(test: &TestKey, caller: &dyn AbiImpl, callee: &dyn AbiImpl
1515
//
1616
// THIS AREA RESERVED FOR VENDORS TO APPLY PATCHES
1717

@@ -21,13 +21,6 @@ index 7346f5e..8347762 100644
2121
+ result.run = Link;
2222
+ result.check = Pass(Link);
2323
+ }
24-
+
25-
+ // structs is broken in the current release of cranelift for aarch64.
26-
+ // It has been fixed for cranelift 0.88: https://github.com/bytecodealliance/wasmtime/pull/4634
27-
+ if cfg!(target_arch = "aarch64") && test.test_name == "structs" {
28-
+ result.run = Link;
29-
+ result.check = Pass(Link);
30-
+ }
3124
+
3225
// END OF VENDOR RESERVED AREA
3326
//

src/base.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ use rustc_middle::ty::adjustment::PointerCast;
66
use rustc_middle::ty::layout::FnAbiOf;
77
use rustc_middle::ty::print::with_no_trimmed_paths;
88

9+
use cranelift_codegen::ir::UserFuncName;
10+
911
use crate::constant::ConstantCx;
1012
use crate::debuginfo::FunctionDebugContext;
1113
use crate::prelude::*;
@@ -64,7 +66,7 @@ pub(crate) fn codegen_fn<'tcx>(
6466
let mut func_ctx = FunctionBuilderContext::new();
6567
let mut func = cached_func;
6668
func.clear();
67-
func.name = ExternalName::user(0, func_id.as_u32());
69+
func.name = UserFuncName::user(0, func_id.as_u32());
6870
func.signature = sig;
6971
func.collect_debug_info();
7072

src/lib.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ mod prelude {
9696
pub(crate) use cranelift_codegen::ir::function::Function;
9797
pub(crate) use cranelift_codegen::ir::types;
9898
pub(crate) use cranelift_codegen::ir::{
99-
AbiParam, Block, ExternalName, FuncRef, Inst, InstBuilder, MemFlags, Signature, SourceLoc,
100-
StackSlot, StackSlotData, StackSlotKind, TrapCode, Type, Value,
99+
AbiParam, Block, FuncRef, Inst, InstBuilder, MemFlags, Signature, SourceLoc, StackSlot,
100+
StackSlotData, StackSlotKind, TrapCode, Type, Value,
101101
};
102102
pub(crate) use cranelift_codegen::isa::{self, CallConv};
103103
pub(crate) use cranelift_codegen::Context;
@@ -251,7 +251,6 @@ fn build_isa(sess: &Session, backend_config: &BackendConfig) -> Box<dyn isa::Tar
251251

252252
let mut flags_builder = settings::builder();
253253
flags_builder.enable("is_pic").unwrap();
254-
flags_builder.set("enable_probestack", "false").unwrap(); // __cranelift_probestack is not provided
255254
let enable_verifier = if backend_config.enable_verifier { "true" } else { "false" };
256255
flags_builder.set("enable_verifier", enable_verifier).unwrap();
257256
flags_builder.set("regalloc_checker", enable_verifier).unwrap();
@@ -279,6 +278,15 @@ fn build_isa(sess: &Session, backend_config: &BackendConfig) -> Box<dyn isa::Tar
279278
}
280279
}
281280

281+
if target_triple.architecture == target_lexicon::Architecture::X86_64 {
282+
// Windows depends on stack probes to grow the committed part of the stack
283+
flags_builder.enable("enable_probestack").unwrap();
284+
flags_builder.set("probestack_strategy", "inline").unwrap();
285+
} else {
286+
// __cranelift_probestack is not provided and inline stack probes are only supported on x86_64
287+
flags_builder.set("enable_probestack", "false").unwrap();
288+
}
289+
282290
let flags = settings::Flags::new(flags_builder);
283291

284292
let isa_builder = match sess.opts.cg.target_cpu.as_deref() {

src/num.rs

+6-19
Original file line numberDiff line numberDiff line change
@@ -150,18 +150,12 @@ pub(crate) fn codegen_int_binop<'tcx>(
150150
BinOp::BitXor => b.bxor(lhs, rhs),
151151
BinOp::BitAnd => b.band(lhs, rhs),
152152
BinOp::BitOr => b.bor(lhs, rhs),
153-
BinOp::Shl => {
154-
let lhs_ty = fx.bcx.func.dfg.value_type(lhs);
155-
let actual_shift = fx.bcx.ins().band_imm(rhs, i64::from(lhs_ty.bits() - 1));
156-
fx.bcx.ins().ishl(lhs, actual_shift)
157-
}
153+
BinOp::Shl => b.ishl(lhs, rhs),
158154
BinOp::Shr => {
159-
let lhs_ty = fx.bcx.func.dfg.value_type(lhs);
160-
let actual_shift = fx.bcx.ins().band_imm(rhs, i64::from(lhs_ty.bits() - 1));
161155
if signed {
162-
fx.bcx.ins().sshr(lhs, actual_shift)
156+
b.sshr(lhs, rhs)
163157
} else {
164-
fx.bcx.ins().ushr(lhs, actual_shift)
158+
b.ushr(lhs, rhs)
165159
}
166160
}
167161
// Compare binops handles by `codegen_binop`.
@@ -279,22 +273,15 @@ pub(crate) fn codegen_checked_int_binop<'tcx>(
279273
}
280274
}
281275
BinOp::Shl => {
282-
let lhs_ty = fx.bcx.func.dfg.value_type(lhs);
283-
let masked_shift = fx.bcx.ins().band_imm(rhs, i64::from(lhs_ty.bits() - 1));
284-
let val = fx.bcx.ins().ishl(lhs, masked_shift);
276+
let val = fx.bcx.ins().ishl(lhs, rhs);
285277
let ty = fx.bcx.func.dfg.value_type(val);
286278
let max_shift = i64::from(ty.bits()) - 1;
287279
let has_overflow = fx.bcx.ins().icmp_imm(IntCC::UnsignedGreaterThan, rhs, max_shift);
288280
(val, has_overflow)
289281
}
290282
BinOp::Shr => {
291-
let lhs_ty = fx.bcx.func.dfg.value_type(lhs);
292-
let masked_shift = fx.bcx.ins().band_imm(rhs, i64::from(lhs_ty.bits() - 1));
293-
let val = if !signed {
294-
fx.bcx.ins().ushr(lhs, masked_shift)
295-
} else {
296-
fx.bcx.ins().sshr(lhs, masked_shift)
297-
};
283+
let val =
284+
if !signed { fx.bcx.ins().ushr(lhs, rhs) } else { fx.bcx.ins().sshr(lhs, rhs) };
298285
let ty = fx.bcx.func.dfg.value_type(val);
299286
let max_shift = i64::from(ty.bits()) - 1;
300287
let has_overflow = fx.bcx.ins().icmp_imm(IntCC::UnsignedGreaterThan, rhs, max_shift);

0 commit comments

Comments
 (0)