From e6ba5147ada707727c2024cb1417503dba127254 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Thu, 10 Oct 2024 17:12:17 +0000 Subject: [PATCH] [WIP] Update Cranelift to 0.113 --- Cargo.lock | 119 ++++++++++++++----------------------- Cargo.toml | 15 +++-- src/abi/mod.rs | 4 +- src/base.rs | 12 ++-- src/debuginfo/line_info.rs | 7 ++- src/debuginfo/mod.rs | 3 +- src/inline_asm.rs | 4 +- src/intrinsics/mod.rs | 4 +- src/intrinsics/simd.rs | 6 +- src/trap.rs | 2 +- 10 files changed, 77 insertions(+), 99 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 82640dafa..d004e5755 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "ahash" @@ -46,24 +46,21 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cranelift-bforest" -version = "0.112.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6e376bd92bddd03dcfc443b14382611cae5d10012aa0b1628bbf18bb73f12f7" +version = "0.113.0" +source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-26.0.0#44ecb523a517cd9813f896543a0938047026d58a" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-bitset" -version = "0.112.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45ecbe07f25a8100e5077933516200e97808f1d7196b5a073edb85fa08fde32e" +version = "0.113.0" +source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-26.0.0#44ecb523a517cd9813f896543a0938047026d58a" [[package]] name = "cranelift-codegen" -version = "0.112.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc60913f32c1de18538c28bef74b8c87cf16de7841a1b0956fcf01b23237853a" +version = "0.113.0" +source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-26.0.0#44ecb523a517cd9813f896543a0938047026d58a" dependencies = [ "bumpalo", "cranelift-bforest", @@ -84,42 +81,37 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.112.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bae009e7822f47aa55e7dcef846ccf3aa4eb102ca6b4bcb8a44b36f3f49aa85c" +version = "0.113.0" +source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-26.0.0#44ecb523a517cd9813f896543a0938047026d58a" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.112.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c78f01a852536c68e34444450f845ed6e0782a1f047f85397fe460b8fbce8f1" +version = "0.113.0" +source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-26.0.0#44ecb523a517cd9813f896543a0938047026d58a" [[package]] name = "cranelift-control" -version = "0.112.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a061b22e00a9e36b31f2660dfb05a9617b7775bd54b79754d3bb75a990dac06" +version = "0.113.0" +source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-26.0.0#44ecb523a517cd9813f896543a0938047026d58a" dependencies = [ "arbitrary", ] [[package]] name = "cranelift-entity" -version = "0.112.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95e2b261a3e74ae42f4e606906d5ffa44ee2684e8b1ae23bdf75d21908dc9233" +version = "0.113.0" +source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-26.0.0#44ecb523a517cd9813f896543a0938047026d58a" dependencies = [ "cranelift-bitset", ] [[package]] name = "cranelift-frontend" -version = "0.112.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe14abba0e6bab42aca0f9ce757f96880f9187e88bc6cb975ed6acd8a42f7770" +version = "0.113.0" +source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-26.0.0#44ecb523a517cd9813f896543a0938047026d58a" dependencies = [ "cranelift-codegen", "log", @@ -129,15 +121,13 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.112.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "311d91ae72b37d4262b51217baf8c9e01f1afd5148931468da1fdb7e9d011347" +version = "0.113.0" +source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-26.0.0#44ecb523a517cd9813f896543a0938047026d58a" [[package]] name = "cranelift-jit" -version = "0.112.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b8ea36cb2f092c71300eb1ffdb30b7e301fdc3c00479aabe36036bac53c5a5a" +version = "0.113.0" +source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-26.0.0#44ecb523a517cd9813f896543a0938047026d58a" dependencies = [ "anyhow", "cranelift-codegen", @@ -150,14 +140,13 @@ dependencies = [ "region", "target-lexicon", "wasmtime-jit-icache-coherence", - "windows-sys", + "windows-sys 0.59.0", ] [[package]] name = "cranelift-module" -version = "0.112.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e03d6e8524b5093252fb624a5bb7a0517a1f23d2d2a1418ef8bfd81290ef549" +version = "0.113.0" +source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-26.0.0#44ecb523a517cd9813f896543a0938047026d58a" dependencies = [ "anyhow", "cranelift-codegen", @@ -166,9 +155,8 @@ dependencies = [ [[package]] name = "cranelift-native" -version = "0.112.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a3f84c75e578189ff7a716c24ad83740b553bf583f2510b323bfe4c1a74bb93" +version = "0.113.0" +source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-26.0.0#44ecb523a517cd9813f896543a0938047026d58a" dependencies = [ "cranelift-codegen", "libc", @@ -177,9 +165,8 @@ dependencies = [ [[package]] name = "cranelift-object" -version = "0.112.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc18e6930ac086d1fe10da77d7019f29048feb7b73b236bddf8980b587ed89d7" +version = "0.113.0" +source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-26.0.0#44ecb523a517cd9813f896543a0938047026d58a" dependencies = [ "anyhow", "cranelift-codegen", @@ -213,9 +200,9 @@ checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" [[package]] name = "gimli" -version = "0.29.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" dependencies = [ "fallible-iterator", "indexmap", @@ -264,10 +251,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] -name = "mach" -version = "0.3.2" +name = "mach2" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" +checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709" dependencies = [ "libc", ] @@ -329,14 +316,14 @@ dependencies = [ [[package]] name = "region" -version = "2.2.0" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0" +checksum = "e6b6ebd13bc009aef9cd476c1310d49ac354d36e240cf1bd753290f3dc7199a7" dependencies = [ "bitflags", "libc", - "mach", - "winapi", + "mach2", + "windows-sys 0.52.0", ] [[package]] @@ -412,43 +399,29 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasmtime-jit-icache-coherence" -version = "25.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48011232c0da424f89c3752a378d0b7f512fae321ea414a43e1e7a302a6a1f7e" +version = "26.0.0" +source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=release-26.0.0#44ecb523a517cd9813f896543a0938047026d58a" dependencies = [ "anyhow", "cfg-if", "libc", - "windows-sys", + "windows-sys 0.59.0", ] [[package]] -name = "winapi" -version = "0.3.9" +name = "windows-sys" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", + "windows-targets", ] -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - [[package]] name = "windows-sys" -version = "0.52.0" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ "windows-targets", ] diff --git a/Cargo.toml b/Cargo.toml index a30ed75c0..77c09a072 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,15 +8,14 @@ crate-type = ["dylib"] [dependencies] # These have to be in sync with each other -# FIXME switch to native-arch instead of listing all archs on the next Cranelift update -cranelift-codegen = { version = "0.112.0", default-features = false, features = ["std", "unwind", "x86", "arm64", "s390x", "riscv64"] } -cranelift-frontend = { version = "0.112.0" } -cranelift-module = { version = "0.112.0" } -cranelift-native = { version = "0.112.0" } -cranelift-jit = { version = "0.112.0", optional = true } -cranelift-object = { version = "0.112.0" } +cranelift-codegen = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-26.0.0", version = "0.113.0", default-features = false, features = ["std", "unwind", "all-native-arch"] } +cranelift-frontend = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-26.0.0", version = "0.113.0" } +cranelift-module = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-26.0.0", version = "0.113.0" } +cranelift-native = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-26.0.0", version = "0.113.0" } +cranelift-jit = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-26.0.0", version = "0.113.0", optional = true } +cranelift-object = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "release-26.0.0", version = "0.113.0" } target-lexicon = "0.12.0" -gimli = { version = "0.29", default-features = false, features = ["write"] } +gimli = { version = "0.31", default-features = false, features = ["write"] } object = { version = "0.36", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] } indexmap = "2.0.0" diff --git a/src/abi/mod.rs b/src/abi/mod.rs index c0aa63eab..c532a3dfe 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -389,7 +389,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( let callee = with_no_trimmed_paths!(fx.tcx.def_path_str(def_id)); fx.tcx.dcx().emit_err(CompilerBuiltinsCannotCall { caller, callee }); } else { - fx.bcx.ins().trap(TrapCode::User(0)); + fx.bcx.ins().trap(TrapCode::user(2).unwrap()); return; } } @@ -579,7 +579,7 @@ pub(crate) fn codegen_terminator_call<'tcx>( let ret_block = fx.get_block(dest); fx.bcx.ins().jump(ret_block, &[]); } else { - fx.bcx.ins().trap(TrapCode::UnreachableCodeReached); + fx.bcx.ins().trap(TrapCode::user(1 /* unreachable */).unwrap()); } fn adjust_call_for_c_variadic<'tcx>( diff --git a/src/base.rs b/src/base.rs index 5d860bf6e..e7a67c11f 100644 --- a/src/base.rs +++ b/src/base.rs @@ -294,7 +294,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) { if arg_uninhabited { fx.bcx.append_block_params_for_function_params(fx.block_map[START_BLOCK]); fx.bcx.switch_to_block(fx.block_map[START_BLOCK]); - fx.bcx.ins().trap(TrapCode::UnreachableCodeReached); + fx.bcx.ins().trap(TrapCode::user(1 /* unreachable */).unwrap()); return; } fx.tcx @@ -311,7 +311,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) { if !reachable_blocks.contains(bb) { // We want to skip this block, because it's not reachable. But we still create // the block so terminators in other blocks can reference it. - fx.bcx.ins().trap(TrapCode::UnreachableCodeReached); + fx.bcx.ins().trap(TrapCode::user(1 /* unreachable */).unwrap()); continue; } @@ -540,11 +540,11 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) { } TerminatorKind::UnwindResume => { // FIXME implement unwinding - fx.bcx.ins().trap(TrapCode::UnreachableCodeReached); + fx.bcx.ins().trap(TrapCode::user(1 /* unreachable */).unwrap()); } TerminatorKind::Unreachable => { fx.bcx.set_cold_block(block); - fx.bcx.ins().trap(TrapCode::UnreachableCodeReached); + fx.bcx.ins().trap(TrapCode::user(1 /* unreachable */).unwrap()); } TerminatorKind::Yield { .. } | TerminatorKind::FalseEdge { .. } @@ -1082,7 +1082,7 @@ fn codegen_panic_inner<'tcx>( let instance = Instance::mono(fx.tcx, def_id).polymorphize(fx.tcx); if is_call_from_compiler_builtins_to_upstream_monomorphization(fx.tcx, instance) { - fx.bcx.ins().trap(TrapCode::User(0)); + fx.bcx.ins().trap(TrapCode::user(2).unwrap()); return; } @@ -1095,5 +1095,5 @@ fn codegen_panic_inner<'tcx>( args, ); - fx.bcx.ins().trap(TrapCode::UnreachableCodeReached); + fx.bcx.ins().trap(TrapCode::user(1 /* unreachable */).unwrap()); } diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index c3d9d6350..fa7b39c83 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -50,7 +50,12 @@ fn make_file_info(hash: SourceFileHash) -> Option { if hash.kind == SourceFileHashAlgorithm::Md5 { let mut buf = [0u8; MD5_LEN]; buf.copy_from_slice(hash.hash_bytes()); - Some(FileInfo { timestamp: 0, size: 0, md5: buf }) + Some(FileInfo { + timestamp: 0, + size: 0, + md5: buf, + source: None, // FIXME implement -Zembed-source + }) } else { None } diff --git a/src/debuginfo/mod.rs b/src/debuginfo/mod.rs index f0b78e5d7..a877d8ca9 100644 --- a/src/debuginfo/mod.rs +++ b/src/debuginfo/mod.rs @@ -101,6 +101,7 @@ impl DebugContext { None => (tcx.crate_name(LOCAL_CRATE).to_string(), None), }; + let file_has_md5 = file_info.is_some(); let mut line_program = LineProgram::new( encoding, LineEncoding::default(), @@ -108,7 +109,7 @@ impl DebugContext { LineString::new(name.as_bytes(), encoding, &mut dwarf.line_strings), file_info, ); - line_program.file_has_md5 = file_info.is_some(); + line_program.file_has_md5 = file_has_md5; dwarf.unit.line_program = line_program; diff --git a/src/inline_asm.rs b/src/inline_asm.rs index 41f1b30d1..0fbd5a168 100644 --- a/src/inline_asm.rs +++ b/src/inline_asm.rs @@ -47,7 +47,7 @@ pub(crate) fn codegen_inline_asm_terminator<'tcx>( // asm!() by accident and breaks with the GNU assembler as well as global_asm!() for // the LLVM backend. if template.len() == 1 && template[0] == InlineAsmTemplatePiece::String("int $$0x29".into()) { - fx.bcx.ins().trap(TrapCode::User(1)); + fx.bcx.ins().trap(TrapCode::user(2).unwrap()); return; } @@ -137,7 +137,7 @@ pub(crate) fn codegen_inline_asm_terminator<'tcx>( fx.bcx.ins().jump(destination_block, &[]); } None => { - fx.bcx.ins().trap(TrapCode::UnreachableCodeReached); + fx.bcx.ins().trap(TrapCode::user(0 /* unreachable */).unwrap()); } } } diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index e96ab1e90..6371b5272 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -47,7 +47,7 @@ fn report_atomic_type_validation_error<'tcx>( ), ); // Prevent verifier error - fx.bcx.ins().trap(TrapCode::UnreachableCodeReached); + fx.bcx.ins().trap(TrapCode::user(1 /* unreachable */).unwrap()); } pub(crate) fn clif_vector_type<'tcx>(tcx: TyCtxt<'tcx>, layout: TyAndLayout<'tcx>) -> Type { @@ -450,7 +450,7 @@ fn codegen_regular_intrinsic_call<'tcx>( match intrinsic { sym::abort => { fx.bcx.set_cold_block(fx.bcx.current_block().unwrap()); - fx.bcx.ins().trap(TrapCode::User(0)); + fx.bcx.ins().trap(TrapCode::user(2).unwrap()); return Ok(()); } sym::likely | sym::unlikely => { diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs index cbe411d78..b77f0fd86 100644 --- a/src/intrinsics/simd.rs +++ b/src/intrinsics/simd.rs @@ -14,7 +14,7 @@ fn report_simd_type_validation_error( ) { fx.tcx.dcx().span_err(span, format!("invalid monomorphization of `{}` intrinsic: expected SIMD input type, found non-SIMD `{}`", intrinsic, ty)); // Prevent verifier error - fx.bcx.ins().trap(TrapCode::UnreachableCodeReached); + fx.bcx.ins().trap(TrapCode::user(1 /* unreachable */).unwrap()); } pub(super) fn codegen_simd_intrinsic_call<'tcx>( @@ -189,7 +189,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( format!("simd_shuffle index must be a SIMD vector of `u32`, got `{}`", idx_ty), ); // Prevent verifier error - fx.bcx.ins().trap(TrapCode::UnreachableCodeReached); + fx.bcx.ins().trap(TrapCode::user(1 /* unreachable */).unwrap()); return; }; let n: u16 = idx_ty.simd_size_and_type(fx.tcx).0.try_into().unwrap(); @@ -1130,7 +1130,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( _ => { fx.tcx.dcx().span_err(span, format!("Unknown SIMD intrinsic {}", intrinsic)); // Prevent verifier error - fx.bcx.ins().trap(TrapCode::UnreachableCodeReached); + fx.bcx.ins().trap(TrapCode::user(0 /* unreachable */).unwrap()); return; } } diff --git a/src/trap.rs b/src/trap.rs index a61e1e334..9ef1a523d 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -30,5 +30,5 @@ pub(crate) fn trap_unimplemented(fx: &mut FunctionCx<'_, '_, '_>, msg: impl AsRe let one = fx.bcx.ins().iconst(types::I32, 1); fx.lib_call("exit", vec![AbiParam::new(types::I32)], vec![], &[one]); - fx.bcx.ins().trap(TrapCode::User(!0)); + fx.bcx.ins().trap(TrapCode::user(3).unwrap()); }