Skip to content

Commit ee05e4d

Browse files
committed
Don't ICE on unimplemented call convs
1 parent dffa6ac commit ee05e4d

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

src/abi/mod.rs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ mod returning;
77
use cranelift_module::ModuleError;
88
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
99
use rustc_middle::ty::layout::FnAbiOf;
10+
use rustc_session::Session;
1011
use rustc_target::abi::call::{Conv, FnAbi};
1112
use rustc_target::spec::abi::Abi;
1213

@@ -22,7 +23,7 @@ fn clif_sig_from_fn_abi<'tcx>(
2223
default_call_conv: CallConv,
2324
fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
2425
) -> Signature {
25-
let call_conv = conv_to_call_conv(fn_abi.conv, default_call_conv);
26+
let call_conv = conv_to_call_conv(tcx.sess, fn_abi.conv, default_call_conv);
2627

2728
let inputs = fn_abi.args.iter().map(|arg_abi| arg_abi.get_abi_param(tcx).into_iter()).flatten();
2829

@@ -33,24 +34,30 @@ fn clif_sig_from_fn_abi<'tcx>(
3334
Signature { params, returns, call_conv }
3435
}
3536

36-
pub(crate) fn conv_to_call_conv(c: Conv, default_call_conv: CallConv) -> CallConv {
37+
pub(crate) fn conv_to_call_conv(sess: &Session, c: Conv, default_call_conv: CallConv) -> CallConv {
3738
match c {
3839
Conv::Rust | Conv::C => default_call_conv,
3940
Conv::RustCold => CallConv::Cold,
4041
Conv::X86_64SysV => CallConv::SystemV,
4142
Conv::X86_64Win64 => CallConv::WindowsFastcall,
42-
Conv::ArmAapcs
43-
| Conv::CCmseNonSecureCall
43+
44+
// Should already get a back compat warning
45+
Conv::X86Fastcall | Conv::X86Stdcall | Conv::X86ThisCall | Conv::X86VectorCall => {
46+
default_call_conv
47+
}
48+
49+
Conv::X86Intr => sess.fatal("x86-interrupt call conv not yet implemented"),
50+
51+
Conv::ArmAapcs => sess.fatal("aapcs call conv not yet implemented"),
52+
53+
Conv::CCmseNonSecureCall
4454
| Conv::Msp430Intr
4555
| Conv::PtxKernel
46-
| Conv::X86Fastcall
47-
| Conv::X86Intr
48-
| Conv::X86Stdcall
49-
| Conv::X86ThisCall
50-
| Conv::X86VectorCall
5156
| Conv::AmdGpuKernel
5257
| Conv::AvrInterrupt
53-
| Conv::AvrNonBlockingInterrupt => todo!("{:?}", c),
58+
| Conv::AvrNonBlockingInterrupt => {
59+
unreachable!("tried to use {c:?} call conv which only exists on an unsupported target");
60+
}
5461
}
5562
}
5663

src/main_shim.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ pub(crate) fn maybe_create_entry_wrapper(
6464
],
6565
returns: vec![AbiParam::new(m.target_config().pointer_type() /*isize*/)],
6666
call_conv: crate::conv_to_call_conv(
67+
tcx.sess,
6768
tcx.sess.target.options.entry_abi,
6869
m.target_config().default_call_conv,
6970
),

0 commit comments

Comments
 (0)