Skip to content

Commit

Permalink
Updated rust version
Browse files Browse the repository at this point in the history
  • Loading branch information
FractalFir committed Dec 25, 2024
1 parent 00176a6 commit 7736677
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 36 deletions.
28 changes: 0 additions & 28 deletions src/rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,34 +338,6 @@ pub fn handle_rvalue<'tcx>(
)
}
}
Rvalue::Len(operand) => {
let ty = ctx.monomorphize(operand.ty(ctx.body(), ctx.tcx()));
match ty.ty.kind() {
TyKind::Slice(inner) => {
let slice_tpe = fat_ptr_to(*inner, ctx);
let descriptor = FieldDesc::new(
slice_tpe,
ctx.alloc_string(crate::METADATA),
cilly::v2::Type::Int(Int::USize),
);
let addr = crate::place::place_address_raw(operand, ctx);
assert!(
!matches!(addr, CILNode::LDLoc(_)),
"improper addr {addr:?}. operand:{operand:?}"
);
(vec![], ld_field!(addr, ctx.alloc_field(descriptor)))
}
TyKind::Array(_ty, length) => {
let len =
crate::utilis::try_resolve_const_size(ctx.monomorphize(*length)).unwrap();
(
vec![],
CILNode::V2(ctx.alloc_node(Const::USize(len as u64))),
)
}
_ => todo!("Get length of type {ty:?}"),
}
}
Rvalue::Repeat(operand, times) => repeat(rvalue, ctx, operand, *times, target_location),
Rvalue::ThreadLocalRef(def_id) => {
if !def_id.is_local() && ctx.tcx().needs_thread_local_shim(*def_id) {
Expand Down
1 change: 1 addition & 0 deletions src/type/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ fn handle_tag<'tcx>(
fields.push((tag_type, ctx.alloc_string(crate::ENUM_TAG), Some(offset)));
}
}
rustc_target::abi::Variants::Empty => (),
rustc_target::abi::Variants::Multiple {
tag: _,
tag_encoding,
Expand Down
11 changes: 5 additions & 6 deletions src/utilis/adt.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
use cilly::{
call,
cil_node::CILNode,
cil_root::CILRoot,
eq, gt_un,
v2::{cilnode::MethodKind, Assembly, ClassRef, ClassRefIdx, FieldDesc, Float, Int, MethodRef},
Type,
call, cil_node::CILNode, cil_root::CILRoot, eq, gt_un, v2::{cilnode::MethodKind, Assembly, ClassRef, ClassRefIdx, FieldDesc, Float, Int, MethodRef}, Const, Type
};
use rustc_middle::ty::{AdtDef, Ty};
use rustc_target::abi::{
Expand Down Expand Up @@ -111,6 +106,7 @@ pub fn enum_tag_info(r#enum: Layout<'_>, asm: &mut Assembly) -> (Type, u32) {
.nth(*tag_field)
.unwrap_or(0),
),
Variants::Empty => (Type::Void,0),
}
}
fn scalr_to_type(scalar: rustc_target::abi::Scalar, asm: &mut Assembly) -> Type {
Expand Down Expand Up @@ -150,6 +146,7 @@ pub fn get_variant_at_index(
match layout.variants {
Variants::Single { .. } => layout,
Variants::Multiple { variants, .. } => variants[variant_index].clone(),
Variants::Empty => todo!("Empty variants have no variants."),
}
}
pub fn set_discr<'tcx>(
Expand All @@ -170,6 +167,7 @@ pub fn set_discr<'tcx>(
);
}
match layout.variants {
Variants::Empty => CILRoot::Nop,
Variants::Single { index } => {
assert_eq!(index, variant_index);
CILRoot::Nop
Expand Down Expand Up @@ -255,6 +253,7 @@ pub fn get_discr<'tcx>(
Variants::Multiple {
ref tag_encoding, ..
} => tag_encoding,
Variants::Empty => return crate::casts::int_to_int(Type::Int(Int::U64), tag_tpe, CILNode::V2(ctx.alloc_node(Const::U64(0))), ctx),
};

// Decode the discriminant (specifically if it's niche-encoded).
Expand Down
5 changes: 5 additions & 0 deletions test/arthm/num_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub fn test_variadic_fnptr() {
test!(!(p < q));
}
fn main() {
unsafe{printf(c"val:%f\n".as_ptr(),core::hint::black_box(cst_f64()))};
isqrt_test();
unsafe { black_box(ldexpf(black_box(434.43), 1232.3434)) };
check_float_nan();
Expand Down Expand Up @@ -419,3 +420,7 @@ fn isqrt_test() {
.unwrap_or(true));
}
}
#[no_mangle]
pub extern fn cst_f64()->f64{
core::hint::black_box(2_i32) as f64
}
4 changes: 2 additions & 2 deletions test/fuzz/fuzz333.rs
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ pub fn fn1(mut _1: f64, mut _2: char, mut _3: i128) -> i64 {
{
RET = (-1862555209_i32) as i64;
RET = !2978883428705732703_i64;
_1 = 22087_i16 as f64;
_1 = 2_i32 as f64;
RET = 7469067570071337310_i64;
_3 = 138924407888664610422382143887634307467_i128;
RET = -6060649836288376761_i64;
Expand Down Expand Up @@ -989,7 +989,7 @@ pub fn fn1(mut _1: f64, mut _2: char, mut _3: i128) -> i64 {
Call(_32 = dump_var(1_usize, 24_usize, Move(_24), 14_usize, Move(_14), 10_usize, Move(_10), 28_usize, Move(_28)), ReturnTo(bb17), UnwindUnreachable())
}
bb17 = {
Call(_32 = dump_var(1_usize, 19_usize, Move(_19), 13_usize, _13, 33_usize, _33, 33_usize, _33), ReturnTo(bb18), UnwindUnreachable())
Call(_32 = dump_var(1_usize, 19_usize, Move(_19), 1_usize, _1, 33_usize, _33, 33_usize, _33), ReturnTo(bb18), UnwindUnreachable())
}
bb18 = {
Return()
Expand Down

0 comments on commit 7736677

Please sign in to comment.