1
Fork 0

Fix warnings

This commit is contained in:
bjorn3 2020-03-24 13:41:19 +01:00
parent dc76cd0551
commit b113e88ddb
6 changed files with 15 additions and 9 deletions

View file

@ -130,7 +130,9 @@ pub(super) fn adjust_arg_for_abi<'tcx>(
pub(super) fn cvalue_for_param<'tcx>( pub(super) fn cvalue_for_param<'tcx>(
fx: &mut FunctionCx<'_, 'tcx, impl Backend>, fx: &mut FunctionCx<'_, 'tcx, impl Backend>,
start_block: Block, start_block: Block,
#[cfg_attr(not(debug_assertions), allow(unused_variables))]
local: Option<mir::Local>, local: Option<mir::Local>,
#[cfg_attr(not(debug_assertions), allow(unused_variables))]
local_field: Option<usize>, local_field: Option<usize>,
arg_ty: Ty<'tcx>, arg_ty: Ty<'tcx>,
) -> Option<CValue<'tcx>> { ) -> Option<CValue<'tcx>> {

View file

@ -43,6 +43,9 @@ pub(super) fn codegen_return_param(
PassMode::ByRef { sized: false } => todo!(), PassMode::ByRef { sized: false } => todo!(),
}; };
#[cfg(not(debug_assertions))]
let _ = ret_param;
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
crate::abi::comments::add_arg_comment( crate::abi::comments::add_arg_comment(
fx, fx,

View file

@ -5,6 +5,7 @@ mod stack2reg;
pub fn optimize_function<'tcx>( pub fn optimize_function<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
#[cfg_attr(not(debug_assertions), allow(unused_variables))]
instance: Instance<'tcx>, instance: Instance<'tcx>,
ctx: &mut Context, ctx: &mut Context,
cold_blocks: &EntitySet<Block>, cold_blocks: &EntitySet<Block>,

View file

@ -162,6 +162,7 @@ impl<'a> OptimizeContext<'a> {
pub(super) fn optimize_function( pub(super) fn optimize_function(
ctx: &mut Context, ctx: &mut Context,
#[cfg_attr(not(debug_assertions), allow(unused_variables))]
clif_comments: &mut crate::pretty_clif::CommentWriter, clif_comments: &mut crate::pretty_clif::CommentWriter,
) { ) {
combine_stack_addr_with_load_store(&mut ctx.func); combine_stack_addr_with_load_store(&mut ctx.func);

View file

@ -37,6 +37,7 @@ impl Pointer {
} }
} }
#[cfg(debug_assertions)]
pub fn base_and_offset(self) -> (PointerBase, Offset32) { pub fn base_and_offset(self) -> (PointerBase, Offset32) {
(self.base, self.offset) (self.base, self.offset)
} }

View file

@ -1,12 +1,10 @@
use std::borrow::Cow;
use std::collections::HashMap; use std::collections::HashMap;
use std::fmt; use std::fmt;
use cranelift_codegen::{ use cranelift_codegen::{
entity::SecondaryMap, entity::SecondaryMap,
ir::{self, entities::AnyEntity, function::DisplayFunctionAnnotations}, ir::{entities::AnyEntity, function::DisplayFunctionAnnotations},
write::{FuncWriter, PlainWriter}, write::{FuncWriter, PlainWriter},
ValueLabelsRanges,
}; };
use crate::prelude::*; use crate::prelude::*;
@ -103,7 +101,7 @@ impl CommentWriter {
self.global_comments.push(comment.into()); self.global_comments.push(comment.into());
} }
pub fn add_comment<'s, S: Into<Cow<'s, str>>, E: Into<AnyEntity>>( pub fn add_comment<S: Into<String> + AsRef<str>, E: Into<AnyEntity>>(
&mut self, &mut self,
entity: E, entity: E,
comment: S, comment: S,
@ -112,10 +110,10 @@ impl CommentWriter {
match self.entity_comments.entry(entity.into()) { match self.entity_comments.entry(entity.into()) {
Entry::Occupied(mut occ) => { Entry::Occupied(mut occ) => {
occ.get_mut().push('\n'); 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) => { 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); self.clif_comments.add_global_comment(comment);
} }
pub fn add_comment<'s, S: Into<Cow<'s, str>>, E: Into<AnyEntity>>( pub fn add_comment<S: Into<String> + AsRef<str>, E: Into<AnyEntity>>(
&mut self, &mut self,
entity: E, entity: E,
comment: S, comment: S,
@ -206,9 +204,9 @@ pub fn write_clif_file<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
postfix: &str, postfix: &str,
instance: Instance<'tcx>, instance: Instance<'tcx>,
func: &ir::Function, func: &cranelift_codegen::ir::Function,
mut clif_comments: &CommentWriter, mut clif_comments: &CommentWriter,
value_ranges: Option<&ValueLabelsRanges>, value_ranges: Option<&cranelift_codegen::ValueLabelsRanges>,
) { ) {
use std::io::Write; use std::io::Write;