Skip to content

Sync rustc_codegen_cranelift #96323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Apr 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d1904e5
Merge commit '370c397ec9169809e5ad270079712e0043514240' into sync_cg_…
bjorn3 Mar 20, 2022
26972c9
Merge branch 'sync_from_rust'
bjorn3 Mar 20, 2022
1bd90f8
Don't declare test_variadic_fnptr with two conflicting signatures
bjorn3 Mar 18, 2022
998fef8
Rustup to rustc 1.61.0-nightly (3c17c84a3 2022-03-21)
bjorn3 Mar 22, 2022
cf1149f
Update list of ignored rustc tests
bjorn3 Mar 22, 2022
90999c4
Sync from rust 903427b2e807cb1292388940b3f44f3b061cfebf
bjorn3 Mar 25, 2022
e336e1b
Rustup to rustc 1.61.0-nightly (63b8f01bb 2022-03-24)
bjorn3 Mar 25, 2022
f3d97cc
Fix saturating float casts test
bjorn3 Mar 25, 2022
3c030e2
Fix NaN handling of simd float min and max operations
bjorn3 Mar 25, 2022
11007c0
Use fma(f) libm function for simd_fma intrinsic
bjorn3 Mar 25, 2022
93aedb6
Spellchecking some comments
nyurik Mar 30, 2022
ae2f203
Spellchecking compiler code
nyurik Mar 30, 2022
804cae3
Rollup merge of #95461 - nyurik:spelling, r=lcnr
Dylan-DPC Mar 30, 2022
421baaf
Spellchecking compiler comments
nyurik Mar 30, 2022
7665d87
Addressed comments by @compiler-errors and @bjorn3
nyurik Mar 30, 2022
69046fa
Cleanup after some refactoring in rustc_target
Urgau Apr 3, 2022
bc62bd5
Sync from rust 949b98cab8a186b98bf87e64374b8d0848c55271
bjorn3 Apr 5, 2022
b87d783
Rustup to rustc 1.62.0-nightly (60e50fc1c 2022-04-04)
bjorn3 Apr 5, 2022
557a09f
Ignore broken rustc test
bjorn3 Apr 5, 2022
2efede7
Mark scalar layout unions so that backends that do not support partia…
oli-obk Mar 3, 2022
f2d2ec3
check_doc_keyword: don't alloc string for emptiness check
klensy Apr 5, 2022
a923e92
Add new `Deinit` statement kind
JakobDegen Apr 5, 2022
83d470d
Don't assume /bin/bash is available on every system. (#1223)
MikaelUrankar Apr 14, 2022
89c67a8
Remove option to select regalloc algorithm
bjorn3 Apr 17, 2022
a177a7f
Update Cranelift to 0.83.0
bjorn3 Apr 21, 2022
acb32e6
Sync from rust 1dec35a1b0df406da5d7cae55a7fa8d186a2b028
bjorn3 Apr 21, 2022
f2cdd4a
Rustup to rustc 1.62.0-nightly (879aff385 2022-04-20)
bjorn3 Apr 21, 2022
b70b01b
Merge commit 'f2cdd4a78d89c009342197cf5844a21f8aa813df' into sync_cg_…
bjorn3 Apr 22, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions compiler/rustc_codegen_cranelift/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"

[[package]]
name = "cranelift-bforest"
version = "0.82.1"
version = "0.83.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d16922317bd7dd104d509a373887822caa0242fc1def00de66abb538db221db4"
checksum = "ed44413e7e2fe3260d0ed73e6956ab188b69c10ee92b892e401e0f4f6808c68b"
dependencies = [
"cranelift-entity",
]

[[package]]
name = "cranelift-codegen"
version = "0.82.1"
version = "0.83.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b80bf40380256307b68a3dcbe1b91cac92a533e212b5b635abc3e4525781a0a"
checksum = "0b5d83f0f26bf213f971f45589d17e5b65e4861f9ed22392b0cbb6eaa5bd329c"
dependencies = [
"cranelift-bforest",
"cranelift-codegen-meta",
Expand All @@ -59,30 +59,30 @@ dependencies = [

[[package]]
name = "cranelift-codegen-meta"
version = "0.82.1"
version = "0.83.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "703d0ed7d3bc6c7a814ca12858175bf4e93167a3584127858c686e4b5dd6e432"
checksum = "6800dc386177df6ecc5a32680607ed8ba1fa0d31a2a59c8c61fbf44826b8191d"
dependencies = [
"cranelift-codegen-shared",
]

[[package]]
name = "cranelift-codegen-shared"
version = "0.82.1"
version = "0.83.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80f52311e1c90de12dcf8c4b9999c6ebfd1ed360373e88c357160936844511f6"
checksum = "c961f85070985ebc8fcdb81b838a5cf842294d1e6ed4852446161c7e246fd455"

[[package]]
name = "cranelift-entity"
version = "0.82.1"
version = "0.83.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66bc82ef522c1f643baf7d4d40b7c52643ee4549d8960b0e6a047daacb83f897"
checksum = "2347b2b8d1d5429213668f2a8e36c85ee3c73984a2f6a79007e365d3e575e7ed"

[[package]]
name = "cranelift-frontend"
version = "0.82.1"
version = "0.83.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3cc35e4251864b17515845ba47447bca88fec9ca1a4186b19fe42526e36140e8"
checksum = "4cbcdbf7bed29e363568b778649b69dabc3d727256d5d25236096ef693757654"
dependencies = [
"cranelift-codegen",
"log",
Expand All @@ -92,9 +92,9 @@ dependencies = [

[[package]]
name = "cranelift-jit"
version = "0.82.1"
version = "0.83.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93c66d594ad3bfe4e58b1fbd8d17877a7c6564a5f2d6f78cbbf4b0182af1927f"
checksum = "7c769d4e0d76f59c8b2a3bf0477d89ee149bb0731b53fbb245ee081d49063095"
dependencies = [
"anyhow",
"cranelift-codegen",
Expand All @@ -110,19 +110,19 @@ dependencies = [

[[package]]
name = "cranelift-module"
version = "0.82.1"
version = "0.83.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf356697c40232aa09e1e3fb8a350ee894e849ccecc4eac56ff0570a4575c325"
checksum = "0ab57d399a2401074bb0cc40b3031e420f3d66d46ec0cf21eeae53ac04bd73e2"
dependencies = [
"anyhow",
"cranelift-codegen",
]

[[package]]
name = "cranelift-native"
version = "0.82.1"
version = "0.83.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b882b2251c9845d509d92aebfdb6c8bb3b3b48e207ac951f21fbd20cfe7f90b3"
checksum = "8f4cdf93552e5ceb2e3c042829ebb4de4378492705f769eadc6a7c6c5251624c"
dependencies = [
"cranelift-codegen",
"libc",
Expand All @@ -131,9 +131,9 @@ dependencies = [

[[package]]
name = "cranelift-object"
version = "0.82.1"
version = "0.83.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d3f1a88e654e567d2591169239ed157ab290811a729a6468f53999c01001263"
checksum = "cf8e65f4839c26e6237fc0744911d79b0a2ac5e76b4e4eebd14db2b8d849fd31"
dependencies = [
"anyhow",
"cranelift-codegen",
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_codegen_cranelift/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ crate-type = ["dylib"]

[dependencies]
# These have to be in sync with each other
cranelift-codegen = { version = "0.82.1", features = ["unwind", "all-arch"] }
cranelift-frontend = "0.82.1"
cranelift-module = "0.82.1"
cranelift-native = "0.82.1"
cranelift-jit = { version = "0.82.1", optional = true }
cranelift-object = "0.82.1"
cranelift-codegen = { version = "0.83.0", features = ["unwind", "all-arch"] }
cranelift-frontend = "0.83.0"
cranelift-module = "0.83.0"
cranelift-native = "0.83.0"
cranelift-jit = { version = "0.83.0", optional = true }
cranelift-object = "0.83.0"
target-lexicon = "0.12.0"
gimli = { version = "0.26.0", default-features = false, features = ["write"]}
object = { version = "0.27.0", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] }
Expand Down
9 changes: 5 additions & 4 deletions compiler/rustc_codegen_cranelift/build_sysroot/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ dependencies = [

[[package]]
name = "compiler_builtins"
version = "0.1.71"
version = "0.1.72"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "163437f05ca8f29d7e9128ea728dedf5eb620e445fbca273641d3a3050305f23"
checksum = "afdbb35d279238cf77f0c9e8d90ad50d6c7bff476ab342baafa29440f0f10bff"
dependencies = [
"rustc-std-workspace-core",
]
Expand Down Expand Up @@ -134,9 +134,9 @@ dependencies = [

[[package]]
name = "libc"
version = "0.2.121"
version = "0.2.124"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f"
checksum = "21a41fed9d98f27ab1c6d161da622a4fa35e8a54a8adc24bbf3ddd0ef70b0e50"
dependencies = [
"rustc-std-workspace-core",
]
Expand Down Expand Up @@ -203,6 +203,7 @@ dependencies = [
name = "proc_macro"
version = "0.0.0"
dependencies = [
"core",
"std",
]

Expand Down
53 changes: 53 additions & 0 deletions compiler/rustc_codegen_cranelift/example/float-minmax-pass.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copied from https://github.com/rust-lang/rust/blob/3fe3b89cd57229343eeca753fdd8c63d9b03c65c/src/test/ui/simd/intrinsic/float-minmax-pass.rs
// run-pass
// ignore-emscripten

// Test that the simd_f{min,max} intrinsics produce the correct results.

#![feature(repr_simd, platform_intrinsics)]
#![allow(non_camel_case_types)]

#[repr(simd)]
#[derive(Copy, Clone, PartialEq, Debug)]
struct f32x4(pub f32, pub f32, pub f32, pub f32);

extern "platform-intrinsic" {
fn simd_fmin<T>(x: T, y: T) -> T;
fn simd_fmax<T>(x: T, y: T) -> T;
}

fn main() {
let x = f32x4(1.0, 2.0, 3.0, 4.0);
let y = f32x4(2.0, 1.0, 4.0, 3.0);

#[cfg(not(any(target_arch = "mips", target_arch = "mips64")))]
let nan = f32::NAN;
// MIPS hardware treats f32::NAN as SNAN. Clear the signaling bit.
// See https://github.com/rust-lang/rust/issues/52746.
#[cfg(any(target_arch = "mips", target_arch = "mips64"))]
let nan = f32::from_bits(f32::NAN.to_bits() - 1);

let n = f32x4(nan, nan, nan, nan);

unsafe {
let min0 = simd_fmin(x, y);
let min1 = simd_fmin(y, x);
assert_eq!(min0, min1);
let e = f32x4(1.0, 1.0, 3.0, 3.0);
assert_eq!(min0, e);
let minn = simd_fmin(x, n);
assert_eq!(minn, x);
let minn = simd_fmin(y, n);
assert_eq!(minn, y);

let max0 = simd_fmax(x, y);
let max1 = simd_fmax(y, x);
assert_eq!(max0, max1);
let e = f32x4(2.0, 2.0, 4.0, 4.0);
assert_eq!(max0, e);
let maxn = simd_fmax(x, n);
assert_eq!(maxn, x);
let maxn = simd_fmax(y, n);
assert_eq!(maxn, y);
}
}
16 changes: 13 additions & 3 deletions compiler/rustc_codegen_cranelift/example/mini_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
#[lang = "sized"]
pub trait Sized {}

#[lang = "destruct"]
pub trait Destruct {}

#[lang = "unsize"]
pub trait Unsize<T: ?Sized> {}

Expand Down Expand Up @@ -491,13 +494,20 @@ pub trait Deref {
fn deref(&self) -> &Self::Target;
}

#[repr(transparent)]
#[rustc_layout_scalar_valid_range_start(1)]
#[rustc_nonnull_optimization_guaranteed]
pub struct NonNull<T: ?Sized>(pub *mut T);

impl<T: ?Sized, U: ?Sized> CoerceUnsized<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NonNull<U>> for NonNull<T> where T: Unsize<U> {}

pub struct Unique<T: ?Sized> {
pub pointer: *const T,
pub pointer: NonNull<T>,
pub _marker: PhantomData<T>,
}

impl<T: ?Sized, U: ?Sized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> {}

impl<T: ?Sized, U: ?Sized> DispatchFromDyn<Unique<U>> for Unique<T> where T: Unsize<U> {}

#[lang = "owned_box"]
Expand Down Expand Up @@ -526,7 +536,7 @@ unsafe fn allocate(size: usize, _align: usize) -> *mut u8 {

#[lang = "box_free"]
unsafe fn box_free<T: ?Sized>(ptr: Unique<T>, alloc: ()) {
libc::free(ptr.pointer as *mut u8);
libc::free(ptr.pointer.0 as *mut u8);
}

#[lang = "drop"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ fn call_return_u128_pair() {
#[allow(unreachable_code)] // FIXME false positive
fn main() {
take_unique(Unique {
pointer: 0 as *const (),
pointer: unsafe { NonNull(1 as *mut ()) },
_marker: PhantomData,
});
take_f32(0.1);
Expand Down Expand Up @@ -173,7 +173,7 @@ fn main() {
assert!(intrinsics::needs_drop::<NoisyDrop>());

Unique {
pointer: 0 as *const &str,
pointer: NonNull(1 as *mut &str),
_marker: PhantomData,
} as Unique<dyn SomeTrait>;

Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_codegen_cranelift/example/std_example.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#![feature(core_intrinsics, generators, generator_trait, is_sorted)]
#![feature(core_intrinsics, generators, generator_trait, is_sorted, bench_black_box)]

#[cfg(target_arch = "x86_64")]
use std::arch::x86_64::*;
use std::hint::black_box;
use std::io::Write;
use std::ops::Generator;

Expand Down Expand Up @@ -86,6 +87,9 @@ fn main() {
assert_eq!(houndred_f64 as i128, 100);
assert_eq!(1u128.rotate_left(2), 4);

assert_eq!(black_box(f32::NAN) as i128, 0);
assert_eq!(black_box(f32::NAN) as u128, 0);

// Test signed 128bit comparing
let max = usize::MAX as i128;
if 100i128 < 0i128 || 100i128 > max {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,42 +102,6 @@ index 6a8ecd3..68fcb49 100644
}
}
}
diff --git a/crates/core_simd/tests/ops_macros.rs b/crates/core_simd/tests/ops_macros.rs
index 31b7ee2..bd04b3c 100644
--- a/crates/core_simd/tests/ops_macros.rs
+++ b/crates/core_simd/tests/ops_macros.rs
@@ -567,6 +567,7 @@ macro_rules! impl_float_tests {
});
}

+ /*
fn horizontal_max<const LANES: usize>() {
test_helpers::test_1(&|x| {
let vmax = Vector::<LANES>::from_array(x).horizontal_max();
@@ -590,6 +591,7 @@ macro_rules! impl_float_tests {
Ok(())
});
}
+ */
}

#[cfg(feature = "std")]
@@ -604,6 +606,7 @@ macro_rules! impl_float_tests {
)
}

+ /*
fn mul_add<const LANES: usize>() {
test_helpers::test_ternary_elementwise(
&Vector::<LANES>::mul_add,
@@ -611,6 +614,7 @@ macro_rules! impl_float_tests {
&|_, _, _| true,
)
}
+ */
}
}
}
--
2.26.2.7.g19db9cfb68

2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2022-03-19"
channel = "nightly-2022-04-21"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/scripts/filter_profile.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#![forbid(unsafe_code)]/* This line is ignored by bash
# This block is ignored by rustc
pushd $(dirname "$0")/../
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
set -e

./y.rs build --no-unstable-features
Expand Down
Loading