From aa23f862dc020a568278dc4ad92c455a0a3ced46 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 27 Jan 2021 10:32:56 +0100 Subject: [PATCH] Remove vararg support check This check wasn't very useful and removing it simplifies the code. --- src/abi/mod.rs | 12 +----------- src/base.rs | 2 +- src/driver/jit.rs | 4 ++-- src/driver/mod.rs | 7 +------ src/main_shim.rs | 2 +- 5 files changed, 6 insertions(+), 21 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index bc35ca2de40..a27d5b8ab02 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -140,18 +140,8 @@ pub(crate) fn get_function_sig<'tcx>( tcx: TyCtxt<'tcx>, triple: &target_lexicon::Triple, inst: Instance<'tcx>, - support_vararg: bool, ) -> Signature { assert!(!inst.substs.needs_infer()); - let fn_sig = tcx - .normalize_erasing_late_bound_regions(ParamEnv::reveal_all(), fn_sig_for_fn_abi(tcx, inst)); - if fn_sig.c_variadic && !support_vararg { - tcx.sess.span_fatal( - tcx.def_span(inst.def_id()), - "Variadic function definitions are not yet supported", - ); - } - clif_sig_from_fn_abi( tcx, triple, @@ -166,7 +156,7 @@ pub(crate) fn import_function<'tcx>( inst: Instance<'tcx>, ) -> FuncId { let name = tcx.symbol_name(inst).name.to_string(); - let sig = get_function_sig(tcx, module.isa().triple(), inst, true); + let sig = get_function_sig(tcx, module.isa().triple(), inst); module .declare_function(&name, Linkage::Import, &sig) .unwrap() diff --git a/src/base.rs b/src/base.rs index 1eff0d4f516..e81aa52780b 100644 --- a/src/base.rs +++ b/src/base.rs @@ -22,7 +22,7 @@ pub(crate) fn codegen_fn<'tcx>( // Declare function let name = tcx.symbol_name(instance).name.to_string(); - let sig = get_function_sig(tcx, cx.module.isa().triple(), instance, false); + let sig = get_function_sig(tcx, cx.module.isa().triple(), instance); let func_id = cx.module.declare_function(&name, linkage, &sig).unwrap(); cx.cached_context.clear(); diff --git a/src/driver/jit.rs b/src/driver/jit.rs index 6a879259277..2d14ff2c022 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -157,7 +157,7 @@ extern "C" fn __clif_jit_fn(instance_ptr: *const Instance<'static>) -> *const u8 let mut cx = crate::CodegenCx::new(tcx, jit_module, false, false); let name = tcx.symbol_name(instance).name.to_string(); - let sig = crate::abi::get_function_sig(tcx, cx.module.isa().triple(), instance, true); + let sig = crate::abi::get_function_sig(tcx, cx.module.isa().triple(), instance); let func_id = cx .module .declare_function(&name, Linkage::Export, &sig) @@ -243,7 +243,7 @@ pub(super) fn codegen_shim<'tcx>(cx: &mut CodegenCx<'tcx, impl Module>, inst: In let pointer_type = cx.module.target_config().pointer_type(); let name = tcx.symbol_name(inst).name.to_string(); - let sig = crate::abi::get_function_sig(tcx, cx.module.isa().triple(), inst, true); + let sig = crate::abi::get_function_sig(tcx, cx.module.isa().triple(), inst); let func_id = cx .module .declare_function(&name, Linkage::Export, &sig) diff --git a/src/driver/mod.rs b/src/driver/mod.rs index e462f34a04f..752c3f747d5 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -51,12 +51,7 @@ fn predefine_mono_items<'tcx>( match mono_item { MonoItem::Fn(instance) => { let name = cx.tcx.symbol_name(instance).name.to_string(); - let sig= get_function_sig( - cx.tcx, - cx.module.isa().triple(), - instance, - false, - ); + let sig = get_function_sig(cx.tcx, cx.module.isa().triple(), instance); let linkage = crate::linkage::get_clif_linkage(mono_item, linkage, visibility); cx.module.declare_function(&name, linkage, &sig).unwrap(); } diff --git a/src/main_shim.rs b/src/main_shim.rs index 7900abb32a3..b193cea877d 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -70,7 +70,7 @@ pub(crate) fn maybe_create_entry_wrapper( let instance = Instance::mono(tcx, rust_main_def_id).polymorphize(tcx); let main_name = tcx.symbol_name(instance).name.to_string(); - let main_sig = get_function_sig(tcx, m.isa().triple(), instance, false); + let main_sig = get_function_sig(tcx, m.isa().triple(), instance); let main_func_id = m .declare_function(&main_name, Linkage::Import, &main_sig) .unwrap();