diff --git a/src/abi/pass_mode.rs b/src/abi/pass_mode.rs index 3c19787ef92..dc6908fc72d 100644 --- a/src/abi/pass_mode.rs +++ b/src/abi/pass_mode.rs @@ -130,7 +130,9 @@ pub(super) fn adjust_arg_for_abi<'tcx>( pub(super) fn cvalue_for_param<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl Backend>, start_block: Block, + #[cfg_attr(not(debug_assertions), allow(unused_variables))] local: Option, + #[cfg_attr(not(debug_assertions), allow(unused_variables))] local_field: Option, arg_ty: Ty<'tcx>, ) -> Option> { diff --git a/src/abi/returning.rs b/src/abi/returning.rs index b4dd04002cf..0262728bb67 100644 --- a/src/abi/returning.rs +++ b/src/abi/returning.rs @@ -43,6 +43,9 @@ pub(super) fn codegen_return_param( PassMode::ByRef { sized: false } => todo!(), }; + #[cfg(not(debug_assertions))] + let _ = ret_param; + #[cfg(debug_assertions)] crate::abi::comments::add_arg_comment( fx, diff --git a/src/optimize/mod.rs b/src/optimize/mod.rs index f6d02e999e1..29ad5321d57 100644 --- a/src/optimize/mod.rs +++ b/src/optimize/mod.rs @@ -5,6 +5,7 @@ mod stack2reg; pub fn optimize_function<'tcx>( tcx: TyCtxt<'tcx>, + #[cfg_attr(not(debug_assertions), allow(unused_variables))] instance: Instance<'tcx>, ctx: &mut Context, cold_blocks: &EntitySet, diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index 757e608d733..b21f838111c 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -162,6 +162,7 @@ impl<'a> OptimizeContext<'a> { pub(super) fn optimize_function( ctx: &mut Context, + #[cfg_attr(not(debug_assertions), allow(unused_variables))] clif_comments: &mut crate::pretty_clif::CommentWriter, ) { combine_stack_addr_with_load_store(&mut ctx.func); diff --git a/src/pointer.rs b/src/pointer.rs index 0ecb0e1274e..b9183aeedc9 100644 --- a/src/pointer.rs +++ b/src/pointer.rs @@ -37,6 +37,7 @@ impl Pointer { } } + #[cfg(debug_assertions)] pub fn base_and_offset(self) -> (PointerBase, Offset32) { (self.base, self.offset) } diff --git a/src/pretty_clif.rs b/src/pretty_clif.rs index a2872af53f9..725df448161 100644 --- a/src/pretty_clif.rs +++ b/src/pretty_clif.rs @@ -1,12 +1,10 @@ -use std::borrow::Cow; use std::collections::HashMap; use std::fmt; use cranelift_codegen::{ entity::SecondaryMap, - ir::{self, entities::AnyEntity, function::DisplayFunctionAnnotations}, + ir::{entities::AnyEntity, function::DisplayFunctionAnnotations}, write::{FuncWriter, PlainWriter}, - ValueLabelsRanges, }; use crate::prelude::*; @@ -103,7 +101,7 @@ impl CommentWriter { self.global_comments.push(comment.into()); } - pub fn add_comment<'s, S: Into>, E: Into>( + pub fn add_comment + AsRef, E: Into>( &mut self, entity: E, comment: S, @@ -112,10 +110,10 @@ impl CommentWriter { match self.entity_comments.entry(entity.into()) { Entry::Occupied(mut occ) => { occ.get_mut().push('\n'); - occ.get_mut().push_str(comment.into().as_ref()); + occ.get_mut().push_str(comment.as_ref()); } Entry::Vacant(vac) => { - vac.insert(comment.into().into_owned()); + vac.insert(comment.into()); } } } @@ -192,7 +190,7 @@ impl<'a, 'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> { self.clif_comments.add_global_comment(comment); } - pub fn add_comment<'s, S: Into>, E: Into>( + pub fn add_comment + AsRef, E: Into>( &mut self, entity: E, comment: S, @@ -206,9 +204,9 @@ pub fn write_clif_file<'tcx>( tcx: TyCtxt<'tcx>, postfix: &str, instance: Instance<'tcx>, - func: &ir::Function, + func: &cranelift_codegen::ir::Function, mut clif_comments: &CommentWriter, - value_ranges: Option<&ValueLabelsRanges>, + value_ranges: Option<&cranelift_codegen::ValueLabelsRanges>, ) { use std::io::Write;