Fix many clippy warnings
This commit is contained in:
@@ -11,9 +11,9 @@ use crate::abi::pass_mode::*;
|
|||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub(super) fn add_args_header_comment(fx: &mut FunctionCx<'_, '_, impl Module>) {
|
pub(super) fn add_args_header_comment(fx: &mut FunctionCx<'_, '_, impl Module>) {
|
||||||
fx.add_global_comment(format!(
|
fx.add_global_comment(
|
||||||
"kind loc.idx param pass mode ty"
|
"kind loc.idx param pass mode ty".to_string(),
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn add_arg_comment<'tcx>(
|
pub(super) fn add_arg_comment<'tcx>(
|
||||||
@@ -56,9 +56,9 @@ pub(super) fn add_arg_comment<'tcx>(
|
|||||||
|
|
||||||
pub(super) fn add_locals_header_comment(fx: &mut FunctionCx<'_, '_, impl Module>) {
|
pub(super) fn add_locals_header_comment(fx: &mut FunctionCx<'_, '_, impl Module>) {
|
||||||
fx.add_global_comment(String::new());
|
fx.add_global_comment(String::new());
|
||||||
fx.add_global_comment(format!(
|
fx.add_global_comment(
|
||||||
"kind local ty size align (abi,pref)"
|
"kind local ty size align (abi,pref)".to_string(),
|
||||||
));
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn add_local_place_comments<'tcx>(
|
pub(super) fn add_local_place_comments<'tcx>(
|
||||||
|
|||||||
@@ -300,7 +300,7 @@ impl<'tcx, M: Module> FunctionCx<'_, 'tcx, M> {
|
|||||||
return_ty: Ty<'tcx>,
|
return_ty: Ty<'tcx>,
|
||||||
) -> CValue<'tcx> {
|
) -> CValue<'tcx> {
|
||||||
let (input_tys, args): (Vec<_>, Vec<_>) = args
|
let (input_tys, args): (Vec<_>, Vec<_>) = args
|
||||||
.into_iter()
|
.iter()
|
||||||
.map(|arg| {
|
.map(|arg| {
|
||||||
(
|
(
|
||||||
self.clif_type(arg.layout().ty).unwrap(),
|
self.clif_type(arg.layout().ty).unwrap(),
|
||||||
@@ -421,34 +421,31 @@ pub(crate) fn codegen_fn_prelude<'tcx>(
|
|||||||
|
|
||||||
// While this is normally an optimization to prevent an unnecessary copy when an argument is
|
// While this is normally an optimization to prevent an unnecessary copy when an argument is
|
||||||
// not mutated by the current function, this is necessary to support unsized arguments.
|
// not mutated by the current function, this is necessary to support unsized arguments.
|
||||||
match arg_kind {
|
if let ArgKind::Normal(Some(val)) = arg_kind {
|
||||||
ArgKind::Normal(Some(val)) => {
|
if let Some((addr, meta)) = val.try_to_ptr() {
|
||||||
if let Some((addr, meta)) = val.try_to_ptr() {
|
let local_decl = &fx.mir.local_decls[local];
|
||||||
let local_decl = &fx.mir.local_decls[local];
|
// v this ! is important
|
||||||
// v this ! is important
|
let internally_mutable = !val.layout().ty.is_freeze(
|
||||||
let internally_mutable = !val.layout().ty.is_freeze(
|
fx.tcx.at(local_decl.source_info.span),
|
||||||
fx.tcx.at(local_decl.source_info.span),
|
ParamEnv::reveal_all(),
|
||||||
ParamEnv::reveal_all(),
|
);
|
||||||
);
|
if local_decl.mutability == mir::Mutability::Not && !internally_mutable {
|
||||||
if local_decl.mutability == mir::Mutability::Not && !internally_mutable {
|
// We wont mutate this argument, so it is fine to borrow the backing storage
|
||||||
// We wont mutate this argument, so it is fine to borrow the backing storage
|
// of this argument, to prevent a copy.
|
||||||
// of this argument, to prevent a copy.
|
|
||||||
|
|
||||||
let place = if let Some(meta) = meta {
|
let place = if let Some(meta) = meta {
|
||||||
CPlace::for_ptr_with_extra(addr, meta, val.layout())
|
CPlace::for_ptr_with_extra(addr, meta, val.layout())
|
||||||
} else {
|
} else {
|
||||||
CPlace::for_ptr(addr, val.layout())
|
CPlace::for_ptr(addr, val.layout())
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
self::comments::add_local_place_comments(fx, place, local);
|
self::comments::add_local_place_comments(fx, place, local);
|
||||||
|
|
||||||
assert_eq!(fx.local_map.push(place), local);
|
assert_eq!(fx.local_map.push(place), local);
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let place = make_local_place(fx, local, layout, is_ssa);
|
let place = make_local_place(fx, local, layout, is_ssa);
|
||||||
@@ -568,7 +565,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
|
|||||||
}
|
}
|
||||||
args
|
args
|
||||||
} else {
|
} else {
|
||||||
args.into_iter()
|
args.iter()
|
||||||
.map(|arg| trans_operand(fx, arg))
|
.map(|arg| trans_operand(fx, arg))
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ fn codegen_inner(
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let mut ctx = Context::new();
|
let mut ctx = Context::new();
|
||||||
ctx.func = Function::with_name_signature(ExternalName::user(0, 0), sig.clone());
|
ctx.func = Function::with_name_signature(ExternalName::user(0, 0), sig);
|
||||||
{
|
{
|
||||||
let mut func_ctx = FunctionBuilderContext::new();
|
let mut func_ctx = FunctionBuilderContext::new();
|
||||||
let mut bcx = FunctionBuilder::new(&mut ctx.func, &mut func_ctx);
|
let mut bcx = FunctionBuilder::new(&mut ctx.func, &mut func_ctx);
|
||||||
@@ -131,7 +131,7 @@ fn codegen_inner(
|
|||||||
let block = bcx.create_block();
|
let block = bcx.create_block();
|
||||||
bcx.switch_to_block(block);
|
bcx.switch_to_block(block);
|
||||||
let args = (&[usize_ty, usize_ty])
|
let args = (&[usize_ty, usize_ty])
|
||||||
.into_iter()
|
.iter()
|
||||||
.map(|&ty| bcx.append_block_param(block, ty))
|
.map(|&ty| bcx.append_block_param(block, ty))
|
||||||
.collect::<Vec<Value>>();
|
.collect::<Vec<Value>>();
|
||||||
|
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ok, don't skip this
|
// ok, don't skip this
|
||||||
return false;
|
false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use crate::prelude::*;
|
|||||||
|
|
||||||
#[cfg(all(feature = "jit", unix))]
|
#[cfg(all(feature = "jit", unix))]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub static mut __cg_clif_global_atomic_mutex: libc::pthread_mutex_t =
|
static mut __cg_clif_global_atomic_mutex: libc::pthread_mutex_t =
|
||||||
libc::PTHREAD_MUTEX_INITIALIZER;
|
libc::PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
pub(crate) fn init_global_lock(
|
pub(crate) fn init_global_lock(
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ impl WriteDebugInfo for ObjectProduct {
|
|||||||
// FIXME use SHT_X86_64_UNWIND for .eh_frame
|
// FIXME use SHT_X86_64_UNWIND for .eh_frame
|
||||||
let section_id = self.object.add_section(
|
let section_id = self.object.add_section(
|
||||||
segment,
|
segment,
|
||||||
name.clone(),
|
name,
|
||||||
if id == SectionId::EhFrame {
|
if id == SectionId::EhFrame {
|
||||||
SectionKind::ReadOnlyData
|
SectionKind::ReadOnlyData
|
||||||
} else {
|
} else {
|
||||||
@@ -201,6 +201,5 @@ pub(crate) fn make_module(sess: &Session, name: String) -> ObjectModule {
|
|||||||
if std::env::var("CG_CLIF_FUNCTION_SECTIONS").is_ok() {
|
if std::env::var("CG_CLIF_FUNCTION_SECTIONS").is_ok() {
|
||||||
builder.per_function_section(true);
|
builder.per_function_section(true);
|
||||||
}
|
}
|
||||||
let module = ObjectModule::new(builder);
|
ObjectModule::new(builder)
|
||||||
module
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -753,7 +753,7 @@ fn trans_stmt<'tcx>(
|
|||||||
}
|
}
|
||||||
Rvalue::Aggregate(kind, operands) => match **kind {
|
Rvalue::Aggregate(kind, operands) => match **kind {
|
||||||
AggregateKind::Array(_ty) => {
|
AggregateKind::Array(_ty) => {
|
||||||
for (i, operand) in operands.into_iter().enumerate() {
|
for (i, operand) in operands.iter().enumerate() {
|
||||||
let operand = trans_operand(fx, operand);
|
let operand = trans_operand(fx, operand);
|
||||||
let index = fx.bcx.ins().iconst(fx.pointer_type, i as i64);
|
let index = fx.bcx.ins().iconst(fx.pointer_type, i as i64);
|
||||||
let to = lval.place_index(fx, index);
|
let to = lval.place_index(fx, index);
|
||||||
@@ -938,7 +938,7 @@ pub(crate) fn trans_place<'tcx>(
|
|||||||
let ptr = cplace.to_ptr();
|
let ptr = cplace.to_ptr();
|
||||||
cplace = CPlace::for_ptr(
|
cplace = CPlace::for_ptr(
|
||||||
ptr.offset_i64(fx, elem_layout.size.bytes() as i64 * (from as i64)),
|
ptr.offset_i64(fx, elem_layout.size.bytes() as i64 * (from as i64)),
|
||||||
fx.layout_of(fx.tcx.mk_array(elem_ty, u64::from(to) - u64::from(from))),
|
fx.layout_of(fx.tcx.mk_array(elem_ty, to - from)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
ty::Slice(elem_ty) => {
|
ty::Slice(elem_ty) => {
|
||||||
|
|||||||
@@ -181,12 +181,10 @@ pub(crate) fn clif_int_or_float_cast(
|
|||||||
fx.bcx.ins().select(has_overflow, max_val, val)
|
fx.bcx.ins().select(has_overflow, max_val, val)
|
||||||
};
|
};
|
||||||
fx.bcx.ins().ireduce(to_ty, val)
|
fx.bcx.ins().ireduce(to_ty, val)
|
||||||
|
} else if to_signed {
|
||||||
|
fx.bcx.ins().fcvt_to_sint_sat(to_ty, from)
|
||||||
} else {
|
} else {
|
||||||
if to_signed {
|
fx.bcx.ins().fcvt_to_uint_sat(to_ty, from)
|
||||||
fx.bcx.ins().fcvt_to_sint_sat(to_ty, from)
|
|
||||||
} else {
|
|
||||||
fx.bcx.ins().fcvt_to_uint_sat(to_ty, from)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if from_ty.is_float() && to_ty.is_float() {
|
} else if from_ty.is_float() && to_ty.is_float() {
|
||||||
// float -> float
|
// float -> float
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ pub(crate) fn maybe_codegen<'tcx>(
|
|||||||
match bin_op {
|
match bin_op {
|
||||||
BinOp::BitAnd | BinOp::BitOr | BinOp::BitXor => {
|
BinOp::BitAnd | BinOp::BitOr | BinOp::BitXor => {
|
||||||
assert!(!checked);
|
assert!(!checked);
|
||||||
return None;
|
None
|
||||||
}
|
}
|
||||||
BinOp::Add | BinOp::Sub if !checked => return None,
|
BinOp::Add | BinOp::Sub if !checked => None,
|
||||||
BinOp::Add => {
|
BinOp::Add => {
|
||||||
let out_ty = fx.tcx.mk_tup([lhs.layout().ty, fx.tcx.types.bool].iter());
|
let out_ty = fx.tcx.mk_tup([lhs.layout().ty, fx.tcx.types.bool].iter());
|
||||||
return Some(if is_signed {
|
return Some(if is_signed {
|
||||||
@@ -57,7 +57,7 @@ pub(crate) fn maybe_codegen<'tcx>(
|
|||||||
};
|
};
|
||||||
fx.easy_call("__multi3", &[lhs, rhs], val_ty)
|
fx.easy_call("__multi3", &[lhs, rhs], val_ty)
|
||||||
};
|
};
|
||||||
return Some(res);
|
Some(res)
|
||||||
}
|
}
|
||||||
BinOp::Div => {
|
BinOp::Div => {
|
||||||
assert!(!checked);
|
assert!(!checked);
|
||||||
@@ -77,7 +77,7 @@ pub(crate) fn maybe_codegen<'tcx>(
|
|||||||
}
|
}
|
||||||
BinOp::Lt | BinOp::Le | BinOp::Eq | BinOp::Ge | BinOp::Gt | BinOp::Ne => {
|
BinOp::Lt | BinOp::Le | BinOp::Eq | BinOp::Ge | BinOp::Gt | BinOp::Ne => {
|
||||||
assert!(!checked);
|
assert!(!checked);
|
||||||
return None;
|
None
|
||||||
}
|
}
|
||||||
BinOp::Shl | BinOp::Shr => {
|
BinOp::Shl | BinOp::Shr => {
|
||||||
let is_overflow = if checked {
|
let is_overflow = if checked {
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ pub(crate) fn trans_const_value<'tcx>(
|
|||||||
match x {
|
match x {
|
||||||
Scalar::Raw { data, size } => {
|
Scalar::Raw { data, size } => {
|
||||||
assert_eq!(u64::from(size), layout.size.bytes());
|
assert_eq!(u64::from(size), layout.size.bytes());
|
||||||
return CValue::const_val(fx, layout, data);
|
CValue::const_val(fx, layout, data)
|
||||||
}
|
}
|
||||||
Scalar::Ptr(ptr) => {
|
Scalar::Ptr(ptr) => {
|
||||||
let alloc_kind = fx.tcx.get_global_alloc(ptr.alloc_id);
|
let alloc_kind = fx.tcx.get_global_alloc(ptr.alloc_id);
|
||||||
@@ -232,7 +232,7 @@ pub(crate) fn trans_const_value<'tcx>(
|
|||||||
} else {
|
} else {
|
||||||
base_addr
|
base_addr
|
||||||
};
|
};
|
||||||
return CValue::by_val(val, layout);
|
CValue::by_val(val, layout)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -293,14 +293,12 @@ fn data_id_for_static(
|
|||||||
let rlinkage = tcx.codegen_fn_attrs(def_id).linkage;
|
let rlinkage = tcx.codegen_fn_attrs(def_id).linkage;
|
||||||
let linkage = if definition {
|
let linkage = if definition {
|
||||||
crate::linkage::get_static_linkage(tcx, def_id)
|
crate::linkage::get_static_linkage(tcx, def_id)
|
||||||
|
} else if rlinkage == Some(rustc_middle::mir::mono::Linkage::ExternalWeak)
|
||||||
|
|| rlinkage == Some(rustc_middle::mir::mono::Linkage::WeakAny)
|
||||||
|
{
|
||||||
|
Linkage::Preemptible
|
||||||
} else {
|
} else {
|
||||||
if rlinkage == Some(rustc_middle::mir::mono::Linkage::ExternalWeak)
|
Linkage::Import
|
||||||
|| rlinkage == Some(rustc_middle::mir::mono::Linkage::WeakAny)
|
|
||||||
{
|
|
||||||
Linkage::Preemptible
|
|
||||||
} else {
|
|
||||||
Linkage::Import
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let instance = Instance::mono(tcx, def_id).polymorphize(tcx);
|
let instance = Instance::mono(tcx, def_id).polymorphize(tcx);
|
||||||
|
|||||||
@@ -195,9 +195,7 @@ impl Writer for WriterRelocate {
|
|||||||
});
|
});
|
||||||
self.write_udata(0, size)
|
self.write_udata(0, size)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => Err(gimli::write::Error::UnsupportedPointerEncoding(eh_pe)),
|
||||||
return Err(gimli::write::Error::UnsupportedPointerEncoding(eh_pe));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ fn osstr_as_utf8_bytes(path: &OsStr) -> &[u8] {
|
|||||||
|
|
||||||
pub(crate) const MD5_LEN: usize = 16;
|
pub(crate) const MD5_LEN: usize = 16;
|
||||||
|
|
||||||
pub fn make_file_info(hash: SourceFileHash) -> Option<FileInfo> {
|
pub(crate) fn make_file_info(hash: SourceFileHash) -> Option<FileInfo> {
|
||||||
if hash.kind == SourceFileHashAlgorithm::Md5 {
|
if hash.kind == SourceFileHashAlgorithm::Md5 {
|
||||||
let mut buf = [0u8; MD5_LEN];
|
let mut buf = [0u8; MD5_LEN];
|
||||||
buf.copy_from_slice(hash.hash_bytes());
|
buf.copy_from_slice(hash.hash_bytes());
|
||||||
@@ -190,7 +190,7 @@ impl<'tcx> DebugContext<'tcx> {
|
|||||||
if current_file_changed {
|
if current_file_changed {
|
||||||
let file_id = line_program_add_file(line_program, line_strings, &file);
|
let file_id = line_program_add_file(line_program, line_strings, &file);
|
||||||
line_program.row().file = file_id;
|
line_program.row().file = file_id;
|
||||||
last_file = Some(file.clone());
|
last_file = Some(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
line_program.row().line = line;
|
line_program.row().line = line;
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ pub(super) fn run_jit(tcx: TyCtxt<'_>) -> ! {
|
|||||||
|
|
||||||
let args = ::std::env::var("CG_CLIF_JIT_ARGS").unwrap_or_else(|_| String::new());
|
let args = ::std::env::var("CG_CLIF_JIT_ARGS").unwrap_or_else(|_| String::new());
|
||||||
let args = std::iter::once(&*tcx.crate_name(LOCAL_CRATE).as_str().to_string())
|
let args = std::iter::once(&*tcx.crate_name(LOCAL_CRATE).as_str().to_string())
|
||||||
.chain(args.split(" "))
|
.chain(args.split(' '))
|
||||||
.map(|arg| CString::new(arg).unwrap())
|
.map(|arg| CString::new(arg).unwrap())
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let mut argv = args.iter().map(|arg| arg.as_ptr()).collect::<Vec<_>>();
|
let mut argv = args.iter().map(|arg| arg.as_ptr()).collect::<Vec<_>>();
|
||||||
@@ -151,7 +151,7 @@ fn load_imported_symbols_for_jit(tcx: TyCtxt<'_>) -> Vec<(String, *const u8)> {
|
|||||||
}
|
}
|
||||||
let dlsym_name = if cfg!(target_os = "macos") {
|
let dlsym_name = if cfg!(target_os = "macos") {
|
||||||
// On macOS `dlsym` expects the name without leading `_`.
|
// On macOS `dlsym` expects the name without leading `_`.
|
||||||
assert!(name.starts_with("_"), "{:?}", name);
|
assert!(name.starts_with('_'), "{:?}", name);
|
||||||
&name[1..]
|
&name[1..]
|
||||||
} else {
|
} else {
|
||||||
&name
|
&name
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ pub(crate) fn codegen_llvm_intrinsic_call<'tcx>(
|
|||||||
};
|
};
|
||||||
llvm.x86.sse2.cmp.ps | llvm.x86.sse2.cmp.pd, (c x, c y, o kind) {
|
llvm.x86.sse2.cmp.ps | llvm.x86.sse2.cmp.pd, (c x, c y, o kind) {
|
||||||
let kind_const = crate::constant::mir_operand_get_const_val(fx, kind).expect("llvm.x86.sse2.cmp.* kind not const");
|
let kind_const = crate::constant::mir_operand_get_const_val(fx, kind).expect("llvm.x86.sse2.cmp.* kind not const");
|
||||||
let flt_cc = match kind_const.val.try_to_bits(Size::from_bytes(1)).expect(&format!("kind not scalar: {:?}", kind_const)) {
|
let flt_cc = match kind_const.val.try_to_bits(Size::from_bytes(1)).unwrap_or_else(|| panic!("kind not scalar: {:?}", kind_const)) {
|
||||||
0 => FloatCC::Equal,
|
0 => FloatCC::Equal,
|
||||||
1 => FloatCC::LessThan,
|
1 => FloatCC::LessThan,
|
||||||
2 => FloatCC::LessThanOrEqual,
|
2 => FloatCC::LessThanOrEqual,
|
||||||
@@ -84,7 +84,7 @@ pub(crate) fn codegen_llvm_intrinsic_call<'tcx>(
|
|||||||
llvm.x86.sse2.psrli.d, (c a, o imm8) {
|
llvm.x86.sse2.psrli.d, (c a, o imm8) {
|
||||||
let imm8 = crate::constant::mir_operand_get_const_val(fx, imm8).expect("llvm.x86.sse2.psrli.d imm8 not const");
|
let imm8 = crate::constant::mir_operand_get_const_val(fx, imm8).expect("llvm.x86.sse2.psrli.d imm8 not const");
|
||||||
simd_for_each_lane(fx, a, ret, |fx, _lane_layout, res_lane_layout, lane| {
|
simd_for_each_lane(fx, a, ret, |fx, _lane_layout, res_lane_layout, lane| {
|
||||||
let res_lane = match imm8.val.try_to_bits(Size::from_bytes(4)).expect(&format!("imm8 not scalar: {:?}", imm8)) {
|
let res_lane = match imm8.val.try_to_bits(Size::from_bytes(4)).unwrap_or_else(|| panic!("imm8 not scalar: {:?}", imm8)) {
|
||||||
imm8 if imm8 < 32 => fx.bcx.ins().ushr_imm(lane, i64::from(imm8 as u8)),
|
imm8 if imm8 < 32 => fx.bcx.ins().ushr_imm(lane, i64::from(imm8 as u8)),
|
||||||
_ => fx.bcx.ins().iconst(types::I32, 0),
|
_ => fx.bcx.ins().iconst(types::I32, 0),
|
||||||
};
|
};
|
||||||
@@ -94,7 +94,7 @@ pub(crate) fn codegen_llvm_intrinsic_call<'tcx>(
|
|||||||
llvm.x86.sse2.pslli.d, (c a, o imm8) {
|
llvm.x86.sse2.pslli.d, (c a, o imm8) {
|
||||||
let imm8 = crate::constant::mir_operand_get_const_val(fx, imm8).expect("llvm.x86.sse2.psrli.d imm8 not const");
|
let imm8 = crate::constant::mir_operand_get_const_val(fx, imm8).expect("llvm.x86.sse2.psrli.d imm8 not const");
|
||||||
simd_for_each_lane(fx, a, ret, |fx, _lane_layout, res_lane_layout, lane| {
|
simd_for_each_lane(fx, a, ret, |fx, _lane_layout, res_lane_layout, lane| {
|
||||||
let res_lane = match imm8.val.try_to_bits(Size::from_bytes(4)).expect(&format!("imm8 not scalar: {:?}", imm8)) {
|
let res_lane = match imm8.val.try_to_bits(Size::from_bytes(4)).unwrap_or_else(|| panic!("imm8 not scalar: {:?}", imm8)) {
|
||||||
imm8 if imm8 < 32 => fx.bcx.ins().ishl_imm(lane, i64::from(imm8 as u8)),
|
imm8 if imm8 < 32 => fx.bcx.ins().ishl_imm(lane, i64::from(imm8 as u8)),
|
||||||
_ => fx.bcx.ins().iconst(types::I32, 0),
|
_ => fx.bcx.ins().iconst(types::I32, 0),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).expect(&format!("kind not scalar: {:?}", idx_const));
|
let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).unwrap_or_else(|| panic!("kind not scalar: {:?}", idx_const));
|
||||||
let (_lane_type, lane_count) = lane_type_and_count(fx.tcx, base.layout());
|
let (_lane_type, lane_count) = lane_type_and_count(fx.tcx, base.layout());
|
||||||
if idx >= lane_count.into() {
|
if idx >= lane_count.into() {
|
||||||
fx.tcx.sess.span_fatal(fx.mir.span, &format!("[simd_insert] idx {} >= lane_count {}", idx, lane_count));
|
fx.tcx.sess.span_fatal(fx.mir.span, &format!("[simd_insert] idx {} >= lane_count {}", idx, lane_count));
|
||||||
@@ -149,7 +149,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).expect(&format!("kind not scalar: {:?}", idx_const));
|
let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).unwrap_or_else(|| panic!("kind not scalar: {:?}", idx_const));
|
||||||
let (_lane_type, lane_count) = lane_type_and_count(fx.tcx, v.layout());
|
let (_lane_type, lane_count) = lane_type_and_count(fx.tcx, v.layout());
|
||||||
if idx >= lane_count.into() {
|
if idx >= lane_count.into() {
|
||||||
fx.tcx.sess.span_fatal(fx.mir.span, &format!("[simd_extract] idx {} >= lane_count {}", idx, lane_count));
|
fx.tcx.sess.span_fatal(fx.mir.span, &format!("[simd_extract] idx {} >= lane_count {}", idx, lane_count));
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
)]
|
)]
|
||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
#![warn(unused_lifetimes)]
|
#![warn(unused_lifetimes)]
|
||||||
|
#![warn(unreachable_pub)]
|
||||||
|
|
||||||
#[cfg(feature = "jit")]
|
#[cfg(feature = "jit")]
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
|
|||||||
@@ -25,11 +25,9 @@ pub(crate) fn get_static_linkage(tcx: TyCtxt<'_>, def_id: DefId) -> Linkage {
|
|||||||
RLinkage::ExternalWeak | RLinkage::WeakAny => Linkage::Preemptible,
|
RLinkage::ExternalWeak | RLinkage::WeakAny => Linkage::Preemptible,
|
||||||
_ => panic!("{:?}", linkage),
|
_ => panic!("{:?}", linkage),
|
||||||
}
|
}
|
||||||
|
} else if tcx.is_reachable_non_generic(def_id) {
|
||||||
|
Linkage::Export
|
||||||
} else {
|
} else {
|
||||||
if tcx.is_reachable_non_generic(def_id) {
|
Linkage::Hidden
|
||||||
Linkage::Export
|
|
||||||
} else {
|
|
||||||
Linkage::Hidden
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ pub(crate) fn maybe_create_entry_wrapper(
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let mut ctx = Context::new();
|
let mut ctx = Context::new();
|
||||||
ctx.func = Function::with_name_signature(ExternalName::user(0, 0), cmain_sig.clone());
|
ctx.func = Function::with_name_signature(ExternalName::user(0, 0), cmain_sig);
|
||||||
{
|
{
|
||||||
let mut func_ctx = FunctionBuilderContext::new();
|
let mut func_ctx = FunctionBuilderContext::new();
|
||||||
let mut bcx = FunctionBuilder::new(&mut ctx.func, &mut func_ctx);
|
let mut bcx = FunctionBuilder::new(&mut ctx.func, &mut func_ctx);
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ impl MetadataLoader for CraneliftMetadataLoader {
|
|||||||
.expect("Rlib metadata file too big to load into memory."),
|
.expect("Rlib metadata file too big to load into memory."),
|
||||||
);
|
);
|
||||||
::std::io::copy(&mut entry, &mut buf).map_err(|e| format!("{:?}", e))?;
|
::std::io::copy(&mut entry, &mut buf).map_err(|e| format!("{:?}", e))?;
|
||||||
let buf: OwningRef<Vec<u8>, [u8]> = OwningRef::new(buf).into();
|
let buf: OwningRef<Vec<u8>, [u8]> = OwningRef::new(buf);
|
||||||
return Ok(rustc_erase_owner!(buf.map_owner_box()));
|
return Ok(rustc_erase_owner!(buf.map_owner_box()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,7 @@ impl MetadataLoader for CraneliftMetadataLoader {
|
|||||||
.data()
|
.data()
|
||||||
.map_err(|e| format!("failed to read .rustc section: {:?}", e))?
|
.map_err(|e| format!("failed to read .rustc section: {:?}", e))?
|
||||||
.to_owned();
|
.to_owned();
|
||||||
let buf: OwningRef<Vec<u8>, [u8]> = OwningRef::new(buf).into();
|
let buf: OwningRef<Vec<u8>, [u8]> = OwningRef::new(buf);
|
||||||
Ok(rustc_erase_owner!(buf.map_owner_box()))
|
Ok(rustc_erase_owner!(buf.map_owner_box()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -228,7 +228,8 @@ pub(super) fn optimize_function(
|
|||||||
match *potential_stores {
|
match *potential_stores {
|
||||||
[] => {
|
[] => {
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
clif_comments.add_comment(load, format!("[BUG?] Reading uninitialized memory"));
|
clif_comments
|
||||||
|
.add_comment(load, "[BUG?] Reading uninitialized memory".to_string());
|
||||||
}
|
}
|
||||||
[store]
|
[store]
|
||||||
if spatial_overlap(&opt_ctx.ctx.func, store, load) == SpatialOverlap::Full
|
if spatial_overlap(&opt_ctx.ctx.func, store, load) == SpatialOverlap::Full
|
||||||
|
|||||||
@@ -131,11 +131,11 @@ impl FuncWriter for &'_ CommentWriter {
|
|||||||
if !comment.is_empty() {
|
if !comment.is_empty() {
|
||||||
writeln!(w, "; {}", comment)?;
|
writeln!(w, "; {}", comment)?;
|
||||||
} else {
|
} else {
|
||||||
writeln!(w, "")?;
|
writeln!(w)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !self.global_comments.is_empty() {
|
if !self.global_comments.is_empty() {
|
||||||
writeln!(w, "")?;
|
writeln!(w)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.super_preamble(w, func, reg_info)
|
self.super_preamble(w, func, reg_info)
|
||||||
@@ -153,7 +153,7 @@ impl FuncWriter for &'_ CommentWriter {
|
|||||||
if let Some(comment) = self.entity_comments.get(&entity) {
|
if let Some(comment) = self.entity_comments.get(&entity) {
|
||||||
writeln!(w, " ; {}", comment.replace('\n', "\n; "))
|
writeln!(w, " ; {}", comment.replace('\n', "\n; "))
|
||||||
} else {
|
} else {
|
||||||
writeln!(w, "")
|
writeln!(w)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,7 +261,7 @@ pub(crate) fn write_clif_file<'tcx>(
|
|||||||
writeln!(file, "set is_pic")?;
|
writeln!(file, "set is_pic")?;
|
||||||
writeln!(file, "set enable_simd")?;
|
writeln!(file, "set enable_simd")?;
|
||||||
writeln!(file, "target {} haswell", target_triple)?;
|
writeln!(file, "target {} haswell", target_triple)?;
|
||||||
writeln!(file, "")?;
|
writeln!(file)?;
|
||||||
file.write_all(clif.as_bytes())?;
|
file.write_all(clif.as_bytes())?;
|
||||||
};
|
};
|
||||||
if let Err(err) = res {
|
if let Err(err) = res {
|
||||||
|
|||||||
@@ -27,10 +27,10 @@ fn codegen_field<'tcx>(
|
|||||||
return simple(fx);
|
return simple(fx);
|
||||||
}
|
}
|
||||||
match field_layout.ty.kind() {
|
match field_layout.ty.kind() {
|
||||||
ty::Slice(..) | ty::Str | ty::Foreign(..) => return simple(fx),
|
ty::Slice(..) | ty::Str | ty::Foreign(..) => simple(fx),
|
||||||
ty::Adt(def, _) if def.repr.packed() => {
|
ty::Adt(def, _) if def.repr.packed() => {
|
||||||
assert_eq!(layout.align.abi.bytes(), 1);
|
assert_eq!(layout.align.abi.bytes(), 1);
|
||||||
return simple(fx);
|
simple(fx)
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
// We have to align the offset for DST's
|
// We have to align the offset for DST's
|
||||||
@@ -237,15 +237,12 @@ impl<'tcx> CValue<'tcx> {
|
|||||||
|
|
||||||
let clif_ty = fx.clif_type(layout.ty).unwrap();
|
let clif_ty = fx.clif_type(layout.ty).unwrap();
|
||||||
|
|
||||||
match layout.ty.kind() {
|
if let ty::Bool = layout.ty.kind() {
|
||||||
ty::Bool => {
|
assert!(
|
||||||
assert!(
|
const_val == 0 || const_val == 1,
|
||||||
const_val == 0 || const_val == 1,
|
"Invalid bool 0x{:032X}",
|
||||||
"Invalid bool 0x{:032X}",
|
const_val
|
||||||
const_val
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let val = match layout.ty.kind() {
|
let val = match layout.ty.kind() {
|
||||||
|
|||||||
@@ -108,14 +108,14 @@ fn build_vtable<'tcx>(
|
|||||||
(&[]).iter()
|
(&[]).iter()
|
||||||
};
|
};
|
||||||
let methods = methods.cloned().map(|opt_mth| {
|
let methods = methods.cloned().map(|opt_mth| {
|
||||||
opt_mth.map_or(None, |(def_id, substs)| {
|
opt_mth.map(|(def_id, substs)| {
|
||||||
Some(import_function(
|
import_function(
|
||||||
tcx,
|
tcx,
|
||||||
&mut fx.cx.module,
|
&mut fx.cx.module,
|
||||||
Instance::resolve_for_vtable(tcx, ParamEnv::reveal_all(), def_id, substs)
|
Instance::resolve_for_vtable(tcx, ParamEnv::reveal_all(), def_id, substs)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.polymorphize(fx.tcx),
|
.polymorphize(fx.tcx),
|
||||||
))
|
)
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
components.extend(methods);
|
components.extend(methods);
|
||||||
@@ -137,15 +137,7 @@ fn build_vtable<'tcx>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data_ctx.set_align(
|
data_ctx.set_align(fx.tcx.data_layout.pointer_align.pref.bytes());
|
||||||
fx.tcx
|
|
||||||
.data_layout
|
|
||||||
.pointer_align
|
|
||||||
.pref
|
|
||||||
.bytes()
|
|
||||||
.try_into()
|
|
||||||
.unwrap(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let data_id = fx
|
let data_id = fx
|
||||||
.cx
|
.cx
|
||||||
|
|||||||
Reference in New Issue
Block a user