From 08ba5d4e809ecf39d9f909c28b0a2f38f372155d Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Wed, 14 Dec 2022 12:25:53 +0000 Subject: [PATCH] Remove a couple of module.isa() calls --- src/abi/mod.rs | 6 +++--- src/allocator.rs | 4 ++-- src/base.rs | 2 +- src/driver/jit.rs | 8 ++++++-- src/driver/mod.rs | 3 ++- src/main_shim.rs | 6 +++--- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/abi/mod.rs b/src/abi/mod.rs index 42371d2af50..65cc6b43767 100644 --- a/src/abi/mod.rs +++ b/src/abi/mod.rs @@ -56,13 +56,13 @@ pub(crate) fn conv_to_call_conv(c: Conv, default_call_conv: CallConv) -> CallCon pub(crate) fn get_function_sig<'tcx>( tcx: TyCtxt<'tcx>, - triple: &target_lexicon::Triple, + default_call_conv: CallConv, inst: Instance<'tcx>, ) -> Signature { assert!(!inst.substs.needs_infer()); clif_sig_from_fn_abi( tcx, - CallConv::triple_default(triple), + default_call_conv, &RevealAllLayoutCx(tcx).fn_abi_of_instance(inst, ty::List::empty()), ) } @@ -74,7 +74,7 @@ pub(crate) fn import_function<'tcx>( inst: Instance<'tcx>, ) -> FuncId { let name = tcx.symbol_name(inst).name; - let sig = get_function_sig(tcx, module.isa().triple(), inst); + let sig = get_function_sig(tcx, module.target_config().default_call_conv, inst); match module.declare_function(name, Linkage::Import, &sig) { Ok(func_id) => func_id, Err(ModuleError::IncompatibleDeclaration(_)) => tcx.sess.fatal(&format!( diff --git a/src/allocator.rs b/src/allocator.rs index 12bb00d346d..8508227179a 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -66,7 +66,7 @@ fn codegen_inner( }; let sig = Signature { - call_conv: CallConv::triple_default(module.isa().triple()), + call_conv: module.target_config().default_call_conv, params: arg_tys.iter().cloned().map(AbiParam::new).collect(), returns: output.into_iter().map(AbiParam::new).collect(), }; @@ -104,7 +104,7 @@ fn codegen_inner( } let sig = Signature { - call_conv: CallConv::triple_default(module.isa().triple()), + call_conv: module.target_config().default_call_conv, params: vec![AbiParam::new(usize_ty), AbiParam::new(usize_ty)], returns: vec![], }; diff --git a/src/base.rs b/src/base.rs index ac3c0be025c..89d955e8bf2 100644 --- a/src/base.rs +++ b/src/base.rs @@ -59,7 +59,7 @@ pub(crate) fn codegen_fn<'tcx>( // Declare function let symbol_name = tcx.symbol_name(instance).name.to_string(); - let sig = get_function_sig(tcx, module.isa().triple(), instance); + let sig = get_function_sig(tcx, module.target_config().default_call_conv, instance); let func_id = module.declare_function(&symbol_name, Linkage::Local, &sig).unwrap(); // Make the FunctionBuilder diff --git a/src/driver/jit.rs b/src/driver/jit.rs index 1dcb8025183..be1b8c9ead3 100644 --- a/src/driver/jit.rs +++ b/src/driver/jit.rs @@ -245,7 +245,11 @@ fn jit_fn(instance_ptr: *const Instance<'static>, trampoline_ptr: *const u8) -> let backend_config = lazy_jit_state.backend_config.clone(); let name = tcx.symbol_name(instance).name; - let sig = crate::abi::get_function_sig(tcx, jit_module.isa().triple(), instance); + let sig = crate::abi::get_function_sig( + tcx, + jit_module.target_config().default_call_conv, + instance, + ); let func_id = jit_module.declare_function(name, Linkage::Export, &sig).unwrap(); let current_ptr = jit_module.read_got_entry(func_id); @@ -344,7 +348,7 @@ fn codegen_shim<'tcx>( let pointer_type = module.target_config().pointer_type(); let name = tcx.symbol_name(inst).name; - let sig = crate::abi::get_function_sig(tcx, module.isa().triple(), inst); + let sig = crate::abi::get_function_sig(tcx, module.target_config().default_call_conv, inst); let func_id = module.declare_function(name, Linkage::Export, &sig).unwrap(); let instance_ptr = Box::into_raw(Box::new(inst)); diff --git a/src/driver/mod.rs b/src/driver/mod.rs index 8f5714ecb41..6e925cea277 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -24,7 +24,8 @@ fn predefine_mono_items<'tcx>( MonoItem::Fn(instance) => { let name = tcx.symbol_name(instance).name; let _inst_guard = crate::PrintOnPanic(|| format!("{:?} {}", instance, name)); - let sig = get_function_sig(tcx, module.isa().triple(), instance); + let sig = + get_function_sig(tcx, module.target_config().default_call_conv, instance); let linkage = crate::linkage::get_clif_linkage( mono_item, linkage, diff --git a/src/main_shim.rs b/src/main_shim.rs index f7434633ea4..c10054e7f0d 100644 --- a/src/main_shim.rs +++ b/src/main_shim.rs @@ -65,7 +65,7 @@ pub(crate) fn maybe_create_entry_wrapper( returns: vec![AbiParam::new(m.target_config().pointer_type() /*isize*/)], call_conv: crate::conv_to_call_conv( tcx.sess.target.options.entry_abi, - CallConv::triple_default(m.isa().triple()), + m.target_config().default_call_conv, ), }; @@ -75,7 +75,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; - let main_sig = get_function_sig(tcx, m.isa().triple(), instance); + let main_sig = get_function_sig(tcx, m.target_config().default_call_conv, instance); let main_func_id = m.declare_function(main_name, Linkage::Import, &main_sig).unwrap(); let mut ctx = Context::new(); @@ -119,7 +119,7 @@ pub(crate) fn maybe_create_entry_wrapper( .polymorphize(tcx); let report_name = tcx.symbol_name(report).name; - let report_sig = get_function_sig(tcx, m.isa().triple(), report); + let report_sig = get_function_sig(tcx, m.target_config().default_call_conv, report); let report_func_id = m.declare_function(report_name, Linkage::Import, &report_sig).unwrap(); let report_func_ref = m.declare_func_in_func(report_func_id, &mut bcx.func);