Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
antoyo committed Jun 18, 2024
1 parent 765274b commit c341614
Show file tree
Hide file tree
Showing 16 changed files with 95 additions and 37 deletions.
14 changes: 7 additions & 7 deletions patches/libgccjit12/0001-core-Disable-portable-simd-test.patch
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
From a5663265f797a43c502915c356fe7899c16cee92 Mon Sep 17 00:00:00 2001
From 124a11ce086952a5794d5cfbaa45175809497b81 Mon Sep 17 00:00:00 2001
From: None <none@example.com>
Date: Sat, 18 Nov 2023 10:50:36 -0500
Subject: [PATCH] [core] Disable portable-simd test
Expand All @@ -8,25 +8,25 @@ Subject: [PATCH] [core] Disable portable-simd test
1 file changed, 2 deletions(-)

diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs
index d0a119c..76fdece 100644
index b71786c..cf484d5 100644
--- a/library/core/tests/lib.rs
+++ b/library/core/tests/lib.rs
@@ -89,7 +89,6 @@
@@ -95,7 +95,6 @@
#![feature(never_type)]
#![feature(unwrap_infallible)]
#![feature(pointer_is_aligned_to)]
-#![feature(portable_simd)]
#![feature(ptr_metadata)]
#![feature(lazy_cell)]
#![feature(unsized_tuple_coercion)]
@@ -155,7 +154,6 @@ mod pin;
#![feature(const_option)]
@@ -157,7 +156,6 @@ mod pin;
mod pin_macro;
mod ptr;
mod result;
-mod simd;
mod slice;
mod str;
mod str_lossy;
--
2.42.1
--
2.45.2

5 changes: 2 additions & 3 deletions src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,9 +537,8 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
}
if dest.is_none() && options.contains(InlineAsmOptions::NORETURN) {
let builtin_unreachable = self.context.get_builtin_function("__builtin_unreachable");
let builtin_unreachable: RValue<'gcc> = unsafe {
std::mem::transmute(builtin_unreachable)
};
let builtin_unreachable: RValue<'gcc> =
unsafe { std::mem::transmute(builtin_unreachable) };
self.call(self.type_void(), None, None, builtin_unreachable, &[], None, None);
}

Expand Down
4 changes: 2 additions & 2 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
}
}

let val = if let Some(_) = place.val.llextra {
let val = if place.val.llextra.is_some() {
// FIXME: Merge with the `else` below?
OperandValue::Ref(place.val)
} else if place.layout.is_gcc_immediate() {
Expand Down Expand Up @@ -1672,7 +1672,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
_instance: Option<Instance<'tcx>>,
) -> RValue<'gcc> {
// FIXME(antoyo): remove when having a proper API.
let gcc_func = unsafe { std::mem::transmute(func) };
let gcc_func = unsafe { std::mem::transmute::<RValue<'gcc>, Function<'gcc>>(func) };
let call = if self.functions.borrow().values().any(|value| *value == gcc_func) {
self.function_call(func, args, funclet)
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ impl<'gcc, 'tcx> MiscMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
"rust_eh_personality"
};
let func = self.declare_func(name, self.type_i32(), &[], true);
unsafe { std::mem::transmute(func) }
unsafe { std::mem::transmute::<Function<'gcc>, RValue<'gcc>>(func) }
}
};
// TODO(antoyo): apply target cpu attributes.
Expand Down
36 changes: 20 additions & 16 deletions src/int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,16 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
} else {
let a_size = a_type.get_size();
let b_size = b_type.get_size();
if a_size > b_size {
let b = self.context.new_cast(self.location, b, a_type);
a >> b
} else if a_size < b_size {
let a = self.context.new_cast(self.location, a, b_type);
a >> b
} else {
a >> b
match a_size.cmp(&b_size) {
std::cmp::Ordering::Less => {
let a = self.context.new_cast(self.location, a, b_type);
a >> b
}
std::cmp::Ordering::Equal => a >> b,
std::cmp::Ordering::Greater => {
let b = self.context.new_cast(self.location, b, a_type);
a >> b
}
}
}
} else if a_type.is_vector() && a_type.is_vector() {
Expand Down Expand Up @@ -648,14 +650,16 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
} else {
let a_size = a_type.get_size();
let b_size = b_type.get_size();
if a_size > b_size {
let b = self.context.new_cast(self.location, b, a_type);
a << b
} else if a_size < b_size {
let a = self.context.new_cast(self.location, a, b_type);
a << b
} else {
a << b
match a_size.cmp(&b_size) {
std::cmp::Ordering::Less => {
let a = self.context.new_cast(self.location, a, b_type);
a << b
}
std::cmp::Ordering::Equal => a << b,
std::cmp::Ordering::Greater => {
let b = self.context.new_cast(self.location, b, a_type);
a << b
}
}
}
} else if a_type.is_vector() && a_type.is_vector() {
Expand Down
14 changes: 10 additions & 4 deletions src/intrinsic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
let llval = match name {
_ if simple.is_some() => {
// FIXME(antoyo): remove this cast when the API supports function.
let func = unsafe { std::mem::transmute(simple.expect("simple")) };
let func = unsafe {
std::mem::transmute::<Function<'gcc>, RValue<'gcc>>(simple.expect("simple"))
};
self.call(
self.type_void(),
None,
Expand Down Expand Up @@ -675,7 +677,11 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
let step3 = self.or(left, right);

// Fourth step.
if width == 8 { step3 } else { self.gcc_bswap(step3, width) }
if width == 8 {
step3
} else {
self.gcc_bswap(step3, width)
}
}
128 => {
// TODO(antoyo): find a more efficient implementation?
Expand Down Expand Up @@ -1194,7 +1200,7 @@ fn codegen_gnu_try<'gcc>(
bx.invoke(try_func_ty, None, None, try_func, &[data], then, catch, None, None);
});

let func = unsafe { std::mem::transmute(func) };
let func = unsafe { std::mem::transmute::<Function<'gcc>, RValue<'gcc>>(func) };

// Note that no invoke is used here because by definition this function
// can't panic (that's what it's catching).
Expand Down Expand Up @@ -1268,7 +1274,7 @@ fn gen_fn<'a, 'gcc, 'tcx>(
// FIXME(eddyb) find a nicer way to do this.
cx.linkage.set(FunctionType::Internal);
let func = cx.declare_fn(name, fn_abi);
let func_val = unsafe { std::mem::transmute(func) };
let func_val = unsafe { std::mem::transmute::<Function<'gcc>, RValue<'gcc>>(func) };
cx.set_frame_pointer_type(func_val);
cx.apply_target_cpu_attr(func_val);
let block = Builder::append_block(cx, func_val, "entry-block");
Expand Down
1 change: 1 addition & 0 deletions src/intrinsic/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use rustc_codegen_ssa::errors::InvalidMonomorphization;
use rustc_codegen_ssa::mir::operand::OperandRef;
use rustc_codegen_ssa::mir::place::PlaceRef;
use rustc_codegen_ssa::traits::{BaseTypeMethods, BuilderMethods};
#[cfg(feature = "master")]
use rustc_hir as hir;
use rustc_middle::mir::BinOp;
use rustc_middle::span_bug;
Expand Down
5 changes: 4 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,10 @@ impl WriteBackendMethods for GccCodegenBackend {
back::write::codegen(cgcx, dcx, module, config)
}

fn prepare_thin(_module: ModuleCodegen<Self::Module>, _emit_summary: bool) -> (String, Self::ThinBuffer) {
fn prepare_thin(
_module: ModuleCodegen<Self::Module>,
_emit_summary: bool,
) -> (String, Self::ThinBuffer) {
unimplemented!();
}

Expand Down
2 changes: 1 addition & 1 deletion src/mono_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ impl<'gcc, 'tcx> PreDefineMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
// TODO(antoyo): use inline attribute from there in linkage.set() above.

self.functions.borrow_mut().insert(symbol_name.to_string(), decl);
self.function_instances.borrow_mut().insert(instance, unsafe { std::mem::transmute(decl) });
self.function_instances.borrow_mut().insert(instance, decl);
}
}
1 change: 0 additions & 1 deletion tests/failing-run-make-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ tests/run-make/doctests-runtool/
tests/run-make/emit-shared-files/
tests/run-make/exit-code/
tests/run-make/issue-22131/
tests/run-make/issue-38237/
tests/run-make/issue-64153/
tests/run-make/llvm-ident/
tests/run-make/native-link-modifier-bundle/
Expand Down
1 change: 0 additions & 1 deletion tests/failing-ui-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ tests/ui/sepcomp/sepcomp-fns-backwards.rs
tests/ui/sepcomp/sepcomp-fns.rs
tests/ui/sepcomp/sepcomp-statics.rs
tests/ui/asm/x86_64/may_unwind.rs
tests/ui/backtrace.rs
tests/ui/catch-unwind-bang.rs
tests/ui/drop/dynamic-drop-async.rs
tests/ui/cfg/cfg-panic-abort.rs
Expand Down
11 changes: 11 additions & 0 deletions tests/run/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,17 @@ impl Sub for i16 {
}
}

#[track_caller]
#[lang = "panic_const_add_overflow"]
pub fn panic_const_add_overflow() -> ! {
panic("attempt to add with overflow");
}

#[track_caller]
#[lang = "panic_const_sub_overflow"]
pub fn panic_const_sub_overflow() -> ! {
panic("attempt to subtract with overflow");
}

/*
* Code
Expand Down
6 changes: 6 additions & 0 deletions tests/run/assign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ impl Add for isize {
}
}

#[track_caller]
#[lang = "panic_const_add_overflow"]
pub fn panic_const_add_overflow() -> ! {
panic("attempt to add with overflow");
}

/*
* Code
*/
Expand Down
6 changes: 6 additions & 0 deletions tests/run/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,12 @@ pub fn panic(_msg: &'static str) -> ! {
}
}

#[track_caller]
#[lang = "panic_const_add_overflow"]
pub fn panic_const_add_overflow() -> ! {
panic("attempt to add with overflow");
}

/*
* Code
*/
Expand Down
6 changes: 6 additions & 0 deletions tests/run/mut_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ impl Add for isize {
}
}

#[track_caller]
#[lang = "panic_const_add_overflow"]
pub fn panic_const_add_overflow() -> ! {
panic("attempt to add with overflow");
}

/*
* Code
*/
Expand Down
18 changes: 18 additions & 0 deletions tests/run/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,24 @@ impl Mul for isize {
}
}

#[track_caller]
#[lang = "panic_const_add_overflow"]
pub fn panic_const_add_overflow() -> ! {
panic("attempt to add with overflow");
}

#[track_caller]
#[lang = "panic_const_sub_overflow"]
pub fn panic_const_sub_overflow() -> ! {
panic("attempt to subtract with overflow");
}

#[track_caller]
#[lang = "panic_const_mul_overflow"]
pub fn panic_const_mul_overflow() -> ! {
panic("attempt to multiply with overflow");
}

/*
* Code
*/
Expand Down

0 comments on commit c341614

Please sign in to comment.