Skip to content

Commit

Permalink
[WIP] Update Cranelift to 0.113
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Oct 20, 2024
1 parent 45c2002 commit e6ba514
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 99 deletions.
119 changes: 46 additions & 73 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 7 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions src/abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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>(
Expand Down
12 changes: 6 additions & 6 deletions src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}

Expand Down Expand Up @@ -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 { .. }
Expand Down Expand Up @@ -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;
}

Expand All @@ -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());
}
7 changes: 6 additions & 1 deletion src/debuginfo/line_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ fn make_file_info(hash: SourceFileHash) -> Option<FileInfo> {
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
}
Expand Down
3 changes: 2 additions & 1 deletion src/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,15 @@ 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(),
LineString::new(comp_dir.as_bytes(), encoding, &mut dwarf.line_strings),
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;

Expand Down
4 changes: 2 additions & 2 deletions src/inline_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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());
}
}
}
Expand Down
Loading

0 comments on commit e6ba514

Please sign in to comment.