Merge commit '40dd3e2b7089b5e96714e064b731f6dbf17c61a9' into sync_cg_clif-2021-05-27

This commit is contained in:
bjorn3 2021-05-27 13:08:14 +02:00
parent 9d41e8f90d
commit d6b03451e6
25 changed files with 218 additions and 296 deletions

140
Cargo.lock generated
View File

@ -25,12 +25,6 @@ version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]]
name = "byteorder"
version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b"
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
version = "1.0.0" version = "1.0.0"
@ -39,18 +33,17 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "cranelift-bforest" name = "cranelift-bforest"
version = "0.73.0" version = "0.74.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#45bee40f338c631bff4a799288101ba328c7ad36" source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=main#76c6b83f6a21a12a11d4f890490f8acb6329a600"
dependencies = [ dependencies = [
"cranelift-entity", "cranelift-entity",
] ]
[[package]] [[package]]
name = "cranelift-codegen" name = "cranelift-codegen"
version = "0.73.0" version = "0.74.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#45bee40f338c631bff4a799288101ba328c7ad36" source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=main#76c6b83f6a21a12a11d4f890490f8acb6329a600"
dependencies = [ dependencies = [
"byteorder",
"cranelift-bforest", "cranelift-bforest",
"cranelift-codegen-meta", "cranelift-codegen-meta",
"cranelift-codegen-shared", "cranelift-codegen-shared",
@ -60,13 +53,12 @@ dependencies = [
"regalloc", "regalloc",
"smallvec", "smallvec",
"target-lexicon", "target-lexicon",
"thiserror",
] ]
[[package]] [[package]]
name = "cranelift-codegen-meta" name = "cranelift-codegen-meta"
version = "0.73.0" version = "0.74.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#45bee40f338c631bff4a799288101ba328c7ad36" source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=main#76c6b83f6a21a12a11d4f890490f8acb6329a600"
dependencies = [ dependencies = [
"cranelift-codegen-shared", "cranelift-codegen-shared",
"cranelift-entity", "cranelift-entity",
@ -74,18 +66,18 @@ dependencies = [
[[package]] [[package]]
name = "cranelift-codegen-shared" name = "cranelift-codegen-shared"
version = "0.73.0" version = "0.74.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#45bee40f338c631bff4a799288101ba328c7ad36" source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=main#76c6b83f6a21a12a11d4f890490f8acb6329a600"
[[package]] [[package]]
name = "cranelift-entity" name = "cranelift-entity"
version = "0.73.0" version = "0.74.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#45bee40f338c631bff4a799288101ba328c7ad36" source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=main#76c6b83f6a21a12a11d4f890490f8acb6329a600"
[[package]] [[package]]
name = "cranelift-frontend" name = "cranelift-frontend"
version = "0.73.0" version = "0.74.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#45bee40f338c631bff4a799288101ba328c7ad36" source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=main#76c6b83f6a21a12a11d4f890490f8acb6329a600"
dependencies = [ dependencies = [
"cranelift-codegen", "cranelift-codegen",
"log", "log",
@ -95,15 +87,14 @@ dependencies = [
[[package]] [[package]]
name = "cranelift-jit" name = "cranelift-jit"
version = "0.73.0" version = "0.74.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#45bee40f338c631bff4a799288101ba328c7ad36" source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=main#76c6b83f6a21a12a11d4f890490f8acb6329a600"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cranelift-codegen", "cranelift-codegen",
"cranelift-entity", "cranelift-entity",
"cranelift-module", "cranelift-module",
"cranelift-native", "cranelift-native",
"errno",
"libc", "libc",
"log", "log",
"region", "region",
@ -113,20 +104,19 @@ dependencies = [
[[package]] [[package]]
name = "cranelift-module" name = "cranelift-module"
version = "0.73.0" version = "0.74.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#45bee40f338c631bff4a799288101ba328c7ad36" source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=main#76c6b83f6a21a12a11d4f890490f8acb6329a600"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cranelift-codegen", "cranelift-codegen",
"cranelift-entity", "cranelift-entity",
"log", "log",
"thiserror",
] ]
[[package]] [[package]]
name = "cranelift-native" name = "cranelift-native"
version = "0.73.0" version = "0.74.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#45bee40f338c631bff4a799288101ba328c7ad36" source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=main#76c6b83f6a21a12a11d4f890490f8acb6329a600"
dependencies = [ dependencies = [
"cranelift-codegen", "cranelift-codegen",
"target-lexicon", "target-lexicon",
@ -134,8 +124,8 @@ dependencies = [
[[package]] [[package]]
name = "cranelift-object" name = "cranelift-object"
version = "0.73.0" version = "0.74.0"
source = "git+https://github.com/bytecodealliance/wasmtime/?branch=main#45bee40f338c631bff4a799288101ba328c7ad36" source = "git+https://github.com/bytecodealliance/wasmtime.git?branch=main#76c6b83f6a21a12a11d4f890490f8acb6329a600"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cranelift-codegen", "cranelift-codegen",
@ -154,38 +144,11 @@ dependencies = [
"cfg-if", "cfg-if",
] ]
[[package]]
name = "errno"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa68f2fb9cae9d37c9b2b3584aba698a2e97f72d7aef7b9f7aa71d8b54ce46fe"
dependencies = [
"errno-dragonfly",
"libc",
"winapi",
]
[[package]]
name = "errno-dragonfly"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067"
dependencies = [
"gcc",
"libc",
]
[[package]]
name = "gcc"
version = "0.3.55"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2"
[[package]] [[package]]
name = "gimli" name = "gimli"
version = "0.23.0" version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" checksum = "0e4075386626662786ddb0ec9081e7c7eeb1ba31951f447ca780ef9f5d568189"
dependencies = [ dependencies = [
"indexmap", "indexmap",
] ]
@ -242,32 +205,14 @@ dependencies = [
[[package]] [[package]]
name = "object" name = "object"
version = "0.23.0" version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9a7ab5d64814df0fe4a4b5ead45ed6c5f181ee3ff04ba344313a6c80446c5d4" checksum = "1a5b3dd1c072ee7963717671d1ca129f1048fda25edea6b752bfc71ac8854170"
dependencies = [ dependencies = [
"crc32fast", "crc32fast",
"indexmap", "indexmap",
] ]
[[package]]
name = "proc-macro2"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
dependencies = [
"unicode-xid",
]
[[package]]
name = "quote"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7"
dependencies = [
"proc-macro2",
]
[[package]] [[package]]
name = "regalloc" name = "regalloc"
version = "0.0.31" version = "0.0.31"
@ -322,49 +267,12 @@ version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
[[package]]
name = "syn"
version = "1.0.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081"
dependencies = [
"proc-macro2",
"quote",
"unicode-xid",
]
[[package]] [[package]]
name = "target-lexicon" name = "target-lexicon"
version = "0.12.0" version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64ae3b39281e4b14b8123bdbaddd472b7dfe215e444181f2f9d2443c2444f834" checksum = "64ae3b39281e4b14b8123bdbaddd472b7dfe215e444181f2f9d2443c2444f834"
[[package]]
name = "thiserror"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0f4a65597094d4483ddaed134f409b2cb7c1beccf25201a9f73c719254fa98e"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "unicode-xid"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
[[package]] [[package]]
name = "winapi" name = "winapi"
version = "0.3.9" version = "0.3.9"

View File

@ -9,15 +9,15 @@ crate-type = ["dylib"]
[dependencies] [dependencies]
# These have to be in sync with each other # These have to be in sync with each other
cranelift-codegen = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main", features = ["unwind"] } cranelift-codegen = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "main", features = ["unwind"] }
cranelift-frontend = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" } cranelift-frontend = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "main" }
cranelift-module = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" } cranelift-module = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "main" }
cranelift-native = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" } cranelift-native = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "main" }
cranelift-jit = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main", optional = true } cranelift-jit = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "main", optional = true }
cranelift-object = { git = "https://github.com/bytecodealliance/wasmtime/", branch = "main" } cranelift-object = { git = "https://github.com/bytecodealliance/wasmtime.git", branch = "main" }
target-lexicon = "0.12.0" target-lexicon = "0.12.0"
gimli = { version = "0.23.0", default-features = false, features = ["write"]} gimli = { version = "0.24.0", default-features = false, features = ["write"]}
object = { version = "0.23.0", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] } object = { version = "0.24.0", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] }
ar = { git = "https://github.com/bjorn3/rust-ar.git", branch = "do_not_remove_cg_clif_ranlib" } ar = { git = "https://github.com/bjorn3/rust-ar.git", branch = "do_not_remove_cg_clif_ranlib" }
indexmap = "1.0.2" indexmap = "1.0.2"
@ -25,11 +25,11 @@ libloading = { version = "0.6.0", optional = true }
smallvec = "1.6.1" smallvec = "1.6.1"
# Uncomment to use local checkout of cranelift # Uncomment to use local checkout of cranelift
#[patch."https://github.com/bytecodealliance/wasmtime/"] #[patch."https://github.com/bytecodealliance/wasmtime.git"]
#cranelift-codegen = { path = "../wasmtime/cranelift/codegen" } #cranelift-codegen = { path = "../wasmtime/cranelift/codegen" }
#cranelift-frontend = { path = "../wasmtime/cranelift/frontend" } #cranelift-frontend = { path = "../wasmtime/cranelift/frontend" }
#cranelift-module = { path = "../wasmtime/cranelift/module" } #cranelift-module = { path = "../wasmtime/cranelift/module" }
#cranelift-native = { path = ../wasmtime/cranelift/native" } #cranelift-native = { path = "../wasmtime/cranelift/native" }
#cranelift-jit = { path = "../wasmtime/cranelift/jit" } #cranelift-jit = { path = "../wasmtime/cranelift/jit" }
#cranelift-object = { path = "../wasmtime/cranelift/object" } #cranelift-object = { path = "../wasmtime/cranelift/object" }
@ -70,13 +70,5 @@ debug = false
opt-level = 0 opt-level = 0
debug = false debug = false
[profile.dev.package.syn]
opt-level = 0
debug = false
[profile.release.package.syn]
opt-level = 0
debug = false
[package.metadata.rust-analyzer] [package.metadata.rust-analyzer]
rustc_private = true rustc_private = true

View File

@ -40,9 +40,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.0.67" version = "1.0.68"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd" checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787"
[[package]] [[package]]
name = "cfg-if" name = "cfg-if"
@ -56,7 +56,7 @@ dependencies = [
[[package]] [[package]]
name = "compiler_builtins" name = "compiler_builtins"
version = "0.1.40" version = "0.1.43"
dependencies = [ dependencies = [
"rustc-std-workspace-core", "rustc-std-workspace-core",
] ]
@ -132,9 +132,9 @@ dependencies = [
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.94" version = "0.2.95"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e" checksum = "789da6d93f1b866ffe175afc5322a4d76c038605a1c3319bb57b06967ca98a36"
dependencies = [ dependencies = [
"rustc-std-workspace-core", "rustc-std-workspace-core",
] ]
@ -195,9 +195,9 @@ dependencies = [
[[package]] [[package]]
name = "rustc-demangle" name = "rustc-demangle"
version = "0.1.18" version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232" checksum = "410f7acf3cb3a44527c5d9546bad4bf4e6c460915d5f9f2fc524498bfe8f70ce"
dependencies = [ dependencies = [
"compiler_builtins", "compiler_builtins",
"rustc-std-workspace-core", "rustc-std-workspace-core",

View File

@ -32,7 +32,7 @@ popd
git clone https://github.com/rust-lang/compiler-builtins.git || echo "rust-lang/compiler-builtins has already been cloned" git clone https://github.com/rust-lang/compiler-builtins.git || echo "rust-lang/compiler-builtins has already been cloned"
pushd compiler-builtins pushd compiler-builtins
git checkout -- . git checkout -- .
git checkout 0.1.40 git checkout 0.1.43
git apply ../../crate_patches/000*-compiler-builtins-*.patch git apply ../../crate_patches/000*-compiler-builtins-*.patch
popd popd

View File

@ -1,35 +0,0 @@
From 7078cca3cb614e1e82da428380b4e16fc3afef46 Mon Sep 17 00:00:00 2001
From: bjorn3 <bjorn3@users.noreply.github.com>
Date: Thu, 21 Jan 2021 14:46:36 +0100
Subject: [PATCH] Remove rotate_left from Int
---
src/int/mod.rs | 5 -----
1 file changed, 5 deletions(-)
diff --git a/src/int/mod.rs b/src/int/mod.rs
index 06054c8..3bea17b 100644
--- a/src/int/mod.rs
+++ b/src/int/mod.rs
@@ -85,7 +85,6 @@ pub trait Int:
fn wrapping_sub(self, other: Self) -> Self;
fn wrapping_shl(self, other: u32) -> Self;
fn wrapping_shr(self, other: u32) -> Self;
- fn rotate_left(self, other: u32) -> Self;
fn overflowing_add(self, other: Self) -> (Self, bool);
fn leading_zeros(self) -> u32;
}
@@ -209,10 +208,6 @@ macro_rules! int_impl_common {
<Self>::wrapping_shr(self, other)
}
- fn rotate_left(self, other: u32) -> Self {
- <Self>::rotate_left(self, other)
- }
-
fn overflowing_add(self, other: Self) -> (Self, bool) {
<Self>::overflowing_add(self, other)
}
--
2.26.2.7.g19db9cfb68

View File

@ -187,20 +187,6 @@ unsafe fn test_mm_slli_si128() {
); );
let r = _mm_slli_si128(a, 16); let r = _mm_slli_si128(a, 16);
assert_eq_m128i(r, _mm_set1_epi8(0)); assert_eq_m128i(r, _mm_set1_epi8(0));
#[rustfmt::skip]
let a = _mm_setr_epi8(
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
);
let r = _mm_slli_si128(a, -1);
assert_eq_m128i(_mm_set1_epi8(0), r);
#[rustfmt::skip]
let a = _mm_setr_epi8(
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
);
let r = _mm_slli_si128(a, -0x80000000);
assert_eq_m128i(r, _mm_set1_epi8(0));
} }
#[cfg(target_arch = "x86_64")] #[cfg(target_arch = "x86_64")]
@ -295,7 +281,7 @@ unsafe fn test_mm_extract_epi8() {
8, 9, 10, 11, 12, 13, 14, 15 8, 9, 10, 11, 12, 13, 14, 15
); );
let r1 = _mm_extract_epi8(a, 0); let r1 = _mm_extract_epi8(a, 0);
let r2 = _mm_extract_epi8(a, 19); let r2 = _mm_extract_epi8(a, 3);
assert_eq!(r1, 0xFF); assert_eq!(r1, 0xFF);
assert_eq!(r2, 3); assert_eq!(r2, 3);
} }

View File

@ -39,46 +39,6 @@ index a35897e..f0bf645 100644
pub fn decode_finite<T: DecodableFloat>(v: T) -> Decoded { pub fn decode_finite<T: DecodableFloat>(v: T) -> Decoded {
match decode(v).1 { match decode(v).1 {
diff --git a/library/core/tests/num/int_macros.rs b/library/core/tests/num/int_macros.rs
index 0475aeb..9558198 100644
--- a/library/core/tests/num/int_macros.rs
+++ b/library/core/tests/num/int_macros.rs
@@ -88,6 +88,7 @@ mod tests {
assert_eq!(x.trailing_ones(), 0);
}
+ /*
#[test]
fn test_rotate() {
assert_eq!(A.rotate_left(6).rotate_right(2).rotate_right(4), A);
@@ -112,6 +113,7 @@ mod tests {
assert_eq!(B.rotate_left(128), B);
assert_eq!(C.rotate_left(128), C);
}
+ */
#[test]
fn test_swap_bytes() {
diff --git a/library/core/tests/num/uint_macros.rs b/library/core/tests/num/uint_macros.rs
index 04ed14f..a6e372e 100644
--- a/library/core/tests/num/uint_macros.rs
+++ b/library/core/tests/num/uint_macros.rs
@@ -52,6 +52,7 @@ mod tests {
assert_eq!(x.trailing_ones(), 0);
}
+ /*
#[test]
fn test_rotate() {
assert_eq!(A.rotate_left(6).rotate_right(2).rotate_right(4), A);
@@ -76,6 +77,7 @@ mod tests {
assert_eq!(B.rotate_left(128), B);
assert_eq!(C.rotate_left(128), C);
}
+ */
#[test]
fn test_swap_bytes() {
diff --git a/library/core/tests/ptr.rs b/library/core/tests/ptr.rs diff --git a/library/core/tests/ptr.rs b/library/core/tests/ptr.rs
index 1a6be3a..42dbd59 100644 index 1a6be3a..42dbd59 100644
--- a/library/core/tests/ptr.rs --- a/library/core/tests/ptr.rs

View File

@ -1,3 +1,3 @@
[toolchain] [toolchain]
channel = "nightly-2021-04-28" channel = "nightly-2021-05-26"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"] components = ["rust-src", "rustc-dev", "llvm-tools-preview"]

View File

@ -24,18 +24,6 @@ index 5bd1147cad5..10d68a2ff14 100644
+ +
[patch."https://github.com/rust-lang/rust-clippy"] [patch."https://github.com/rust-lang/rust-clippy"]
clippy_lints = { path = "src/tools/clippy/clippy_lints" } clippy_lints = { path = "src/tools/clippy/clippy_lints" }
diff --git a/compiler/rustc_data_structures/Cargo.toml b/compiler/rustc_data_structures/Cargo.toml
index 23e689fcae7..5f077b765b6 100644
--- a/compiler/rustc_data_structures/Cargo.toml
+++ b/compiler/rustc_data_structures/Cargo.toml
@@ -32,7 +32,6 @@ tempfile = "3.0.5"
[dependencies.parking_lot]
version = "0.11"
-features = ["nightly"]
[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["fileapi", "psapi"] }
diff --git a/library/alloc/Cargo.toml b/library/alloc/Cargo.toml diff --git a/library/alloc/Cargo.toml b/library/alloc/Cargo.toml
index d95b5b7f17f..00b6f0e3635 100644 index d95b5b7f17f..00b6f0e3635 100644
--- a/library/alloc/Cargo.toml --- a/library/alloc/Cargo.toml
@ -44,11 +32,12 @@ index d95b5b7f17f..00b6f0e3635 100644
[dependencies] [dependencies]
core = { path = "../core" } core = { path = "../core" }
-compiler_builtins = { version = "0.1.39", features = ['rustc-dep-of-std'] } -compiler_builtins = { version = "0.1.40", features = ['rustc-dep-of-std'] }
+compiler_builtins = { version = "0.1.40", features = ['rustc-dep-of-std', 'no-asm'] } +compiler_builtins = { version = "0.1.43", features = ['rustc-dep-of-std', 'no-asm'] }
[dev-dependencies] [dev-dependencies]
rand = "0.7" rand = "0.7"
rand_xorshift = "0.2"
EOF EOF
cat > config.toml <<EOF cat > config.toml <<EOF

View File

@ -116,6 +116,7 @@ function extended_sysroot_tests() {
pushd regex pushd regex
echo "[TEST] rust-lang/regex example shootout-regex-dna" echo "[TEST] rust-lang/regex example shootout-regex-dna"
cargo clean cargo clean
export RUSTFLAGS="$RUSTFLAGS --cap-lints warn" # newer aho_corasick versions throw a deprecation warning
# Make sure `[codegen mono items] start` doesn't poison the diff # Make sure `[codegen mono items] start` doesn't poison the diff
../build/cargo.sh build --example shootout-regex-dna --target $TARGET_TRIPLE ../build/cargo.sh build --example shootout-regex-dna --target $TARGET_TRIPLE
if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then if [[ "$HOST_TRIPLE" = "$TARGET_TRIPLE" ]]; then

View File

@ -160,7 +160,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
}; };
if !self.no_builtin_ranlib { if !self.no_builtin_ranlib {
match object::File::parse(&data) { match object::File::parse(&*data) {
Ok(object) => { Ok(object) => {
symbol_table.insert( symbol_table.insert(
entry_name.as_bytes().to_vec(), entry_name.as_bytes().to_vec(),

View File

@ -110,11 +110,6 @@ pub(crate) fn codegen_fn<'tcx>(
// Verify function // Verify function
verify_func(tcx, &clif_comments, &context.func); verify_func(tcx, &clif_comments, &context.func);
// Perform rust specific optimizations
tcx.sess.time("optimize clif ir", || {
crate::optimize::optimize_function(tcx, instance, context, &mut clif_comments);
});
// If the return block is not reachable, then the SSA builder may have inserted an `iconst.i128` // If the return block is not reachable, then the SSA builder may have inserted an `iconst.i128`
// instruction, which doesn't have an encoding. // instruction, which doesn't have an encoding.
context.compute_cfg(); context.compute_cfg();
@ -125,10 +120,14 @@ pub(crate) fn codegen_fn<'tcx>(
// invalidate it when it would change. // invalidate it when it would change.
context.domtree.clear(); context.domtree.clear();
context.want_disasm = crate::pretty_clif::should_write_ir(tcx); // Perform rust specific optimizations
tcx.sess.time("optimize clif ir", || {
crate::optimize::optimize_function(tcx, instance, context, &mut clif_comments);
});
// Define function // Define function
tcx.sess.time("define function", || { tcx.sess.time("define function", || {
context.want_disasm = crate::pretty_clif::should_write_ir(tcx);
module module
.define_function(func_id, context, &mut NullTrapSink {}, &mut NullStackMapSink {}) .define_function(func_id, context, &mut NullTrapSink {}, &mut NullStackMapSink {})
.unwrap() .unwrap()
@ -870,7 +869,7 @@ pub(crate) fn codegen_operand<'tcx>(
pub(crate) fn codegen_panic<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, msg_str: &str, span: Span) { pub(crate) fn codegen_panic<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, msg_str: &str, span: Span) {
let location = fx.get_caller_location(span).load_scalar(fx); let location = fx.get_caller_location(span).load_scalar(fx);
let msg_ptr = fx.anonymous_str("assert", msg_str); let msg_ptr = fx.anonymous_str(msg_str);
let msg_len = fx.bcx.ins().iconst(fx.pointer_type, i64::try_from(msg_str.len()).unwrap()); let msg_len = fx.bcx.ins().iconst(fx.pointer_type, i64::try_from(msg_str.len()).unwrap());
let args = [msg_ptr, msg_len, location]; let args = [msg_ptr, msg_len, location];

View File

@ -347,19 +347,10 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
self.module.isa().triple() self.module.isa().triple()
} }
pub(crate) fn anonymous_str(&mut self, prefix: &str, msg: &str) -> Value { pub(crate) fn anonymous_str(&mut self, msg: &str) -> Value {
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
let mut hasher = DefaultHasher::new();
msg.hash(&mut hasher);
let msg_hash = hasher.finish();
let mut data_ctx = DataContext::new(); let mut data_ctx = DataContext::new();
data_ctx.define(msg.as_bytes().to_vec().into_boxed_slice()); data_ctx.define(msg.as_bytes().to_vec().into_boxed_slice());
let msg_id = self let msg_id = self.module.declare_anonymous_data(false, false).unwrap();
.module
.declare_data(&format!("__{}_{:08x}", prefix, msg_hash), Linkage::Local, false, false)
.unwrap();
// Ignore DuplicateDefinition error, as the data will be the same // Ignore DuplicateDefinition error, as the data will be the same
let _ = self.module.define_data(msg_id, &data_ctx); let _ = self.module.define_data(msg_id, &data_ctx);

View File

@ -48,6 +48,12 @@ pub struct BackendConfig {
/// Can be set using `-Cllvm-args=display_cg_time=...`. /// Can be set using `-Cllvm-args=display_cg_time=...`.
pub display_cg_time: bool, pub display_cg_time: bool,
/// The register allocator to use.
///
/// Defaults to the value of `CG_CLIF_REGALLOC` or `backtracking` otherwise. Can be set using
/// `-Cllvm-args=regalloc=...`.
pub regalloc: String,
/// Enable the Cranelift ir verifier for all compilation passes. If not set it will only run /// Enable the Cranelift ir verifier for all compilation passes. If not set it will only run
/// once before passing the clif ir to Cranelift for compilation. /// once before passing the clif ir to Cranelift for compilation.
/// ///
@ -74,6 +80,8 @@ impl Default for BackendConfig {
args.split(' ').map(|arg| arg.to_string()).collect() args.split(' ').map(|arg| arg.to_string()).collect()
}, },
display_cg_time: bool_env_var("CG_CLIF_DISPLAY_CG_TIME"), display_cg_time: bool_env_var("CG_CLIF_DISPLAY_CG_TIME"),
regalloc: std::env::var("CG_CLIF_REGALLOC")
.unwrap_or_else(|_| "backtracking".to_string()),
enable_verifier: cfg!(debug_assertions) || bool_env_var("CG_CLIF_ENABLE_VERIFIER"), enable_verifier: cfg!(debug_assertions) || bool_env_var("CG_CLIF_ENABLE_VERIFIER"),
disable_incr_cache: bool_env_var("CG_CLIF_DISABLE_INCR_CACHE"), disable_incr_cache: bool_env_var("CG_CLIF_DISABLE_INCR_CACHE"),
} }
@ -93,6 +101,7 @@ impl BackendConfig {
match name { match name {
"mode" => config.codegen_mode = value.parse()?, "mode" => config.codegen_mode = value.parse()?,
"display_cg_time" => config.display_cg_time = parse_bool(name, value)?, "display_cg_time" => config.display_cg_time = parse_bool(name, value)?,
"regalloc" => config.regalloc = value.to_string(),
"enable_verifier" => config.enable_verifier = parse_bool(name, value)?, "enable_verifier" => config.enable_verifier = parse_bool(name, value)?,
"disable_incr_cache" => config.disable_incr_cache = parse_bool(name, value)?, "disable_incr_cache" => config.disable_incr_cache = parse_bool(name, value)?,
_ => return Err(format!("Unknown option `{}`", name)), _ => return Err(format!("Unknown option `{}`", name)),

View File

@ -7,7 +7,8 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_errors::ErrorReported; use rustc_errors::ErrorReported;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::mir::interpret::{ use rustc_middle::mir::interpret::{
alloc_range, read_target_uint, AllocId, Allocation, ConstValue, ErrorHandled, GlobalAlloc, Scalar, alloc_range, read_target_uint, AllocId, Allocation, ConstValue, ErrorHandled, GlobalAlloc,
Scalar,
}; };
use rustc_middle::ty::ConstKind; use rustc_middle::ty::ConstKind;
@ -375,8 +376,19 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
data_ctx.set_align(alloc.align.bytes()); data_ctx.set_align(alloc.align.bytes());
if let Some(section_name) = section_name { if let Some(section_name) = section_name {
// FIXME set correct segment for Mach-O files let (segment_name, section_name) = if tcx.sess.target.is_like_osx {
data_ctx.set_segment_section("", &*section_name); if let Some(names) = section_name.split_once(',') {
names
} else {
tcx.sess.fatal(&format!(
"#[link_section = \"{}\"] is not valid for macos target: must be segment and section separated by comma",
section_name
));
}
} else {
("", &*section_name)
};
data_ctx.set_segment_section(segment_name, section_name);
} }
let bytes = alloc.inspect_with_uninit_and_ptr_outside_interpreter(0..alloc.len()).to_vec(); let bytes = alloc.inspect_with_uninit_and_ptr_outside_interpreter(0..alloc.len()).to_vec();
@ -438,12 +450,89 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
operand: &Operand<'tcx>, operand: &Operand<'tcx>,
) -> Option<ConstValue<'tcx>> { ) -> Option<ConstValue<'tcx>> {
match operand { match operand {
Operand::Copy(_) | Operand::Move(_) => None,
Operand::Constant(const_) => match const_.literal { Operand::Constant(const_) => match const_.literal {
ConstantKind::Ty(const_) => { ConstantKind::Ty(const_) => {
fx.monomorphize(const_).eval(fx.tcx, ParamEnv::reveal_all()).val.try_to_value() fx.monomorphize(const_).eval(fx.tcx, ParamEnv::reveal_all()).val.try_to_value()
} }
ConstantKind::Val(val, _) => Some(val), ConstantKind::Val(val, _) => Some(val),
}, },
// FIXME(rust-lang/rust#85105): Casts like `IMM8 as u32` result in the const being stored
// inside a temporary before being passed to the intrinsic requiring the const argument.
// This code tries to find a single constant defining definition of the referenced local.
Operand::Copy(place) | Operand::Move(place) => {
if !place.projection.is_empty() {
return None;
}
let mut computed_const_val = None;
for bb_data in fx.mir.basic_blocks() {
for stmt in &bb_data.statements {
match &stmt.kind {
StatementKind::Assign(local_and_rvalue) if &local_and_rvalue.0 == place => {
match &local_and_rvalue.1 {
Rvalue::Cast(CastKind::Misc, operand, ty) => {
if computed_const_val.is_some() {
return None; // local assigned twice
}
if !matches!(ty.kind(), ty::Uint(_) | ty::Int(_)) {
return None;
}
let const_val = mir_operand_get_const_val(fx, operand)?;
if fx.layout_of(ty).size
!= const_val.try_to_scalar_int()?.size()
{
return None;
}
computed_const_val = Some(const_val);
}
Rvalue::Use(operand) => {
computed_const_val = mir_operand_get_const_val(fx, operand)
}
_ => return None,
}
}
StatementKind::SetDiscriminant { place: stmt_place, variant_index: _ }
if &**stmt_place == place =>
{
return None;
}
StatementKind::LlvmInlineAsm(_) | StatementKind::CopyNonOverlapping(_) => {
return None;
} // conservative handling
StatementKind::Assign(_)
| StatementKind::FakeRead(_)
| StatementKind::SetDiscriminant { .. }
| StatementKind::StorageLive(_)
| StatementKind::StorageDead(_)
| StatementKind::Retag(_, _)
| StatementKind::AscribeUserType(_, _)
| StatementKind::Coverage(_)
| StatementKind::Nop => {}
}
}
match &bb_data.terminator().kind {
TerminatorKind::Goto { .. }
| TerminatorKind::SwitchInt { .. }
| TerminatorKind::Resume
| TerminatorKind::Abort
| TerminatorKind::Return
| TerminatorKind::Unreachable
| TerminatorKind::Drop { .. }
| TerminatorKind::Assert { .. } => {}
TerminatorKind::DropAndReplace { .. }
| TerminatorKind::Yield { .. }
| TerminatorKind::GeneratorDrop
| TerminatorKind::FalseEdge { .. }
| TerminatorKind::FalseUnwind { .. } => unreachable!(),
TerminatorKind::InlineAsm { .. } => return None,
TerminatorKind::Call { destination: Some((call_place, _)), .. }
if call_place == place =>
{
return None;
}
TerminatorKind::Call { .. } => {}
}
}
computed_const_val
}
} }
} }

View File

@ -73,9 +73,8 @@ fn reuse_workproduct_for_cgu(
let mut object = None; let mut object = None;
let work_product = cgu.work_product(tcx); let work_product = cgu.work_product(tcx);
if let Some(saved_file) = &work_product.saved_file { if let Some(saved_file) = &work_product.saved_file {
let obj_out = tcx let obj_out =
.output_filenames(()) tcx.output_filenames(()).temp_path(OutputType::Object, Some(&cgu.name().as_str()));
.temp_path(OutputType::Object, Some(&cgu.name().as_str()));
object = Some(obj_out.clone()); object = Some(obj_out.clone());
let source_file = rustc_incremental::in_incr_comp_dir(&incr_comp_session_dir, &saved_file); let source_file = rustc_incremental::in_incr_comp_dir(&incr_comp_session_dir, &saved_file);
if let Err(err) = rustc_fs_util::link_or_copy(&source_file, &obj_out) { if let Err(err) = rustc_fs_util::link_or_copy(&source_file, &obj_out) {
@ -145,7 +144,13 @@ fn module_codegen(
} }
} }
} }
crate::main_shim::maybe_create_entry_wrapper(tcx, &mut module, &mut cx.unwind_context, false); crate::main_shim::maybe_create_entry_wrapper(
tcx,
&mut module,
&mut cx.unwind_context,
false,
cgu.is_primary(),
);
let debug_context = cx.debug_context; let debug_context = cx.debug_context;
let unwind_context = cx.unwind_context; let unwind_context = cx.unwind_context;
@ -275,9 +280,8 @@ pub(crate) fn run_aot(
.as_str() .as_str()
.to_string(); .to_string();
let tmp_file = tcx let tmp_file =
.output_filenames(()) tcx.output_filenames(()).temp_path(OutputType::Metadata, Some(&metadata_cgu_name));
.temp_path(OutputType::Metadata, Some(&metadata_cgu_name));
let obj = crate::backend::with_object(tcx.sess, &metadata_cgu_name, |object| { let obj = crate::backend::with_object(tcx.sess, &metadata_cgu_name, |object| {
crate::metadata::write_metadata(tcx, object); crate::metadata::write_metadata(tcx, object);
@ -352,8 +356,7 @@ fn codegen_global_asm(tcx: TyCtxt<'_>, cgu_name: &str, global_asm: &str) {
.collect::<Vec<_>>() .collect::<Vec<_>>()
.join("\n"); .join("\n");
let output_object_file = let output_object_file = tcx.output_filenames(()).temp_path(OutputType::Object, Some(cgu_name));
tcx.output_filenames(()).temp_path(OutputType::Object, Some(cgu_name));
// Assemble `global_asm` // Assemble `global_asm`
let global_asm_object_file = add_file_stem_postfix(output_object_file.clone(), ".asm"); let global_asm_object_file = add_file_stem_postfix(output_object_file.clone(), ".asm");

View File

@ -45,6 +45,7 @@ fn create_jit_module<'tcx>(
&mut jit_module, &mut jit_module,
&mut cx.unwind_context, &mut cx.unwind_context,
true, true,
true,
); );
(jit_module, cx) (jit_module, cx)
@ -206,7 +207,7 @@ fn load_imported_symbols_for_jit(tcx: TyCtxt<'_>) -> Vec<(String, *const u8)> {
use object::{Object, ObjectSymbol}; use object::{Object, ObjectSymbol};
let lib = libloading::Library::new(&path).unwrap(); let lib = libloading::Library::new(&path).unwrap();
let obj = std::fs::read(path).unwrap(); let obj = std::fs::read(path).unwrap();
let obj = object::File::parse(&obj).unwrap(); let obj = object::File::parse(&*obj).unwrap();
imported_symbols.extend(obj.dynamic_symbols().filter_map(|symbol| { imported_symbols.extend(obj.dynamic_symbols().filter_map(|symbol| {
let name = symbol.name().unwrap().to_string(); let name = symbol.name().unwrap().to_string();
if name.is_empty() || !symbol.is_global() || symbol.is_undefined() { if name.is_empty() || !symbol.is_global() || symbol.is_undefined() {

View File

@ -24,14 +24,22 @@ pub(crate) fn codegen_inline_asm<'tcx>(
let true_ = fx.bcx.ins().iconst(types::I32, 1); let true_ = fx.bcx.ins().iconst(types::I32, 1);
fx.bcx.ins().trapnz(true_, TrapCode::User(1)); fx.bcx.ins().trapnz(true_, TrapCode::User(1));
return; return;
} else if template[0] == InlineAsmTemplatePiece::String("mov rsi, rbx".to_string()) } else if template[0] == InlineAsmTemplatePiece::String("movq %rbx, ".to_string())
&& template[1] == InlineAsmTemplatePiece::String("\n".to_string()) && matches!(
&& template[2] == InlineAsmTemplatePiece::String("cpuid".to_string()) template[1],
&& template[3] == InlineAsmTemplatePiece::String("\n".to_string()) InlineAsmTemplatePiece::Placeholder { operand_idx: 0, modifier: Some('r'), span: _ }
&& template[4] == InlineAsmTemplatePiece::String("xchg rsi, rbx".to_string()) )
&& template[2] == InlineAsmTemplatePiece::String("\n".to_string())
&& template[3] == InlineAsmTemplatePiece::String("cpuid".to_string())
&& template[4] == InlineAsmTemplatePiece::String("\n".to_string())
&& template[5] == InlineAsmTemplatePiece::String("xchgq %rbx, ".to_string())
&& matches!(
template[6],
InlineAsmTemplatePiece::Placeholder { operand_idx: 0, modifier: Some('r'), span: _ }
)
{ {
assert_eq!(operands.len(), 4); assert_eq!(operands.len(), 4);
let (leaf, eax_place) = match operands[0] { let (leaf, eax_place) = match operands[1] {
InlineAsmOperand::InOut { reg, late: true, ref in_value, out_place } => { InlineAsmOperand::InOut { reg, late: true, ref in_value, out_place } => {
let reg = expect_reg(reg); let reg = expect_reg(reg);
assert_eq!(reg, InlineAsmReg::X86(X86InlineAsmReg::ax)); assert_eq!(reg, InlineAsmReg::X86(X86InlineAsmReg::ax));
@ -42,10 +50,14 @@ pub(crate) fn codegen_inline_asm<'tcx>(
} }
_ => unreachable!(), _ => unreachable!(),
}; };
let ebx_place = match operands[1] { let ebx_place = match operands[0] {
InlineAsmOperand::Out { reg, late: true, place } => { InlineAsmOperand::Out { reg, late: true, place } => {
let reg = expect_reg(reg); assert_eq!(
assert_eq!(reg, InlineAsmReg::X86(X86InlineAsmReg::si)); reg,
InlineAsmRegOrRegClass::RegClass(InlineAsmRegClass::X86(
X86InlineAsmRegClass::reg
))
);
crate::base::codegen_place(fx, place.unwrap()) crate::base::codegen_place(fx, place.unwrap())
} }
_ => unreachable!(), _ => unreachable!(),

View File

@ -12,6 +12,7 @@ pub(crate) fn codegen_cpuid_call<'tcx>(
) -> (Value, Value, Value, Value) { ) -> (Value, Value, Value, Value) {
let leaf_0 = fx.bcx.create_block(); let leaf_0 = fx.bcx.create_block();
let leaf_1 = fx.bcx.create_block(); let leaf_1 = fx.bcx.create_block();
let leaf_7 = fx.bcx.create_block();
let leaf_8000_0000 = fx.bcx.create_block(); let leaf_8000_0000 = fx.bcx.create_block();
let leaf_8000_0001 = fx.bcx.create_block(); let leaf_8000_0001 = fx.bcx.create_block();
let unsupported_leaf = fx.bcx.create_block(); let unsupported_leaf = fx.bcx.create_block();
@ -25,6 +26,7 @@ pub(crate) fn codegen_cpuid_call<'tcx>(
let mut switch = cranelift_frontend::Switch::new(); let mut switch = cranelift_frontend::Switch::new();
switch.set_entry(0, leaf_0); switch.set_entry(0, leaf_0);
switch.set_entry(1, leaf_1); switch.set_entry(1, leaf_1);
switch.set_entry(7, leaf_7);
switch.set_entry(0x8000_0000, leaf_8000_0000); switch.set_entry(0x8000_0000, leaf_8000_0000);
switch.set_entry(0x8000_0001, leaf_8000_0001); switch.set_entry(0x8000_0001, leaf_8000_0001);
switch.emit(&mut fx.bcx, leaf, unsupported_leaf); switch.emit(&mut fx.bcx, leaf, unsupported_leaf);
@ -43,6 +45,11 @@ pub(crate) fn codegen_cpuid_call<'tcx>(
let edx_features = fx.bcx.ins().iconst(types::I32, 1 << 25 /* sse */ | 1 << 26 /* sse2 */); let edx_features = fx.bcx.ins().iconst(types::I32, 1 << 25 /* sse */ | 1 << 26 /* sse2 */);
fx.bcx.ins().jump(dest, &[cpu_signature, additional_information, ecx_features, edx_features]); fx.bcx.ins().jump(dest, &[cpu_signature, additional_information, ecx_features, edx_features]);
fx.bcx.switch_to_block(leaf_7);
// This leaf technically has subleaves, but we just return zero for all subleaves.
let zero = fx.bcx.ins().iconst(types::I32, 0);
fx.bcx.ins().jump(dest, &[zero, zero, zero, zero]);
fx.bcx.switch_to_block(leaf_8000_0000); fx.bcx.switch_to_block(leaf_8000_0000);
let extended_max_basic_leaf = fx.bcx.ins().iconst(types::I32, 0); let extended_max_basic_leaf = fx.bcx.ins().iconst(types::I32, 0);
let zero = fx.bcx.ins().iconst(types::I32, 0); let zero = fx.bcx.ins().iconst(types::I32, 0);

View File

@ -8,8 +8,8 @@ mod simd;
pub(crate) use cpuid::codegen_cpuid_call; pub(crate) use cpuid::codegen_cpuid_call;
pub(crate) use llvm::codegen_llvm_intrinsic_call; pub(crate) use llvm::codegen_llvm_intrinsic_call;
use rustc_span::symbol::{sym, kw};
use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_span::symbol::{kw, sym};
use crate::prelude::*; use crate::prelude::*;
use cranelift_codegen::ir::AtomicRmwOp; use cranelift_codegen::ir::AtomicRmwOp;

View File

@ -256,6 +256,8 @@ fn build_isa(sess: &Session, backend_config: &BackendConfig) -> Box<dyn isa::Tar
flags_builder.set("enable_llvm_abi_extensions", "true").unwrap(); flags_builder.set("enable_llvm_abi_extensions", "true").unwrap();
flags_builder.set("regalloc", &backend_config.regalloc).unwrap();
use rustc_session::config::OptLevel; use rustc_session::config::OptLevel;
match sess.opts.optimize { match sess.opts.optimize {
OptLevel::No => { OptLevel::No => {
@ -277,21 +279,23 @@ fn build_isa(sess: &Session, backend_config: &BackendConfig) -> Box<dyn isa::Tar
builder builder
} }
Some(value) => { Some(value) => {
let mut builder = cranelift_codegen::isa::lookup_variant(target_triple, variant).unwrap(); let mut builder =
cranelift_codegen::isa::lookup_variant(target_triple, variant).unwrap();
if let Err(_) = builder.enable(value) { if let Err(_) = builder.enable(value) {
sess.fatal("The specified target cpu isn't currently supported by Cranelift."); sess.fatal("The specified target cpu isn't currently supported by Cranelift.");
} }
builder builder
} }
None => { None => {
let mut builder = cranelift_codegen::isa::lookup_variant(target_triple, variant).unwrap(); let mut builder =
cranelift_codegen::isa::lookup_variant(target_triple, variant).unwrap();
// Don't use "haswell" as the default, as it implies `has_lzcnt`. // Don't use "haswell" as the default, as it implies `has_lzcnt`.
// macOS CI is still at Ivy Bridge EP, so `lzcnt` is interpreted as `bsr`. // macOS CI is still at Ivy Bridge EP, so `lzcnt` is interpreted as `bsr`.
builder.enable("nehalem").unwrap(); builder.enable("nehalem").unwrap();
builder builder
} }
}; };
isa_builder.finish(flags) isa_builder.finish(flags)
} }

View File

@ -14,6 +14,7 @@ pub(crate) fn maybe_create_entry_wrapper(
module: &mut impl Module, module: &mut impl Module,
unwind_context: &mut UnwindContext, unwind_context: &mut UnwindContext,
is_jit: bool, is_jit: bool,
is_primary_cgu: bool,
) { ) {
let (main_def_id, is_main_fn) = match tcx.entry_fn(()) { let (main_def_id, is_main_fn) = match tcx.entry_fn(()) {
Some((def_id, entry_ty)) => ( Some((def_id, entry_ty)) => (
@ -26,8 +27,12 @@ pub(crate) fn maybe_create_entry_wrapper(
None => return, None => return,
}; };
let instance = Instance::mono(tcx, main_def_id).polymorphize(tcx); if main_def_id.is_local() {
if !is_jit && module.get_name(&*tcx.symbol_name(instance).name).is_none() { let instance = Instance::mono(tcx, main_def_id).polymorphize(tcx);
if !is_jit && module.get_name(&*tcx.symbol_name(instance).name).is_none() {
return;
}
} else if !is_primary_cgu {
return; return;
} }

View File

@ -21,7 +21,7 @@ fn codegen_print(fx: &mut FunctionCx<'_, '_, '_>, msg: &str) {
} }
let real_msg = format!("trap at {:?} ({}): {}\0", fx.instance, fx.symbol_name, msg); let real_msg = format!("trap at {:?} ({}): {}\0", fx.instance, fx.symbol_name, msg);
let msg_ptr = fx.anonymous_str("trap", &real_msg); let msg_ptr = fx.anonymous_str(&real_msg);
fx.bcx.ins().call(puts, &[msg_ptr]); fx.bcx.ins().call(puts, &[msg_ptr]);
} }

View File

@ -561,6 +561,7 @@ impl<'tcx> CPlace<'tcx> {
dst_align, dst_align,
src_align, src_align,
true, true,
MemFlags::trusted(),
); );
} }
CValueInner::ByRef(_, Some(_)) => todo!(), CValueInner::ByRef(_, Some(_)) => todo!(),