mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Merge commit 'dec0daa8f6d0a0e1c702f169abb6bf3eee198c67' into sync_cg_clif-2023-03-15
This commit is contained in:
commit
fce629d2e9
64
compiler/rustc_codegen_cranelift/.github/workflows/abi-cafe.yml
vendored
Normal file
64
compiler/rustc_codegen_cranelift/.github/workflows/abi-cafe.yml
vendored
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
name: Abi-cafe
|
||||||
|
|
||||||
|
on:
|
||||||
|
- push
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
abi_cafe:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
timeout-minutes: 60
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }}-${{ matrix.env.TARGET_TRIPLE }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: true
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: ubuntu-latest
|
||||||
|
env:
|
||||||
|
TARGET_TRIPLE: x86_64-unknown-linux-gnu
|
||||||
|
- os: macos-latest
|
||||||
|
env:
|
||||||
|
TARGET_TRIPLE: x86_64-apple-darwin
|
||||||
|
- os: windows-latest
|
||||||
|
env:
|
||||||
|
TARGET_TRIPLE: x86_64-pc-windows-msvc
|
||||||
|
- os: windows-latest
|
||||||
|
env:
|
||||||
|
TARGET_TRIPLE: x86_64-pc-windows-gnu
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Cache cargo target dir
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: build/cg_clif
|
||||||
|
key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }}
|
||||||
|
|
||||||
|
- name: Set MinGW as the default toolchain
|
||||||
|
if: matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
|
||||||
|
run: rustup set default-host x86_64-pc-windows-gnu
|
||||||
|
|
||||||
|
- name: Use sparse cargo registry
|
||||||
|
run: |
|
||||||
|
cat >> ~/.cargo/config.toml <<EOF
|
||||||
|
[unstable]
|
||||||
|
sparse-registry = true
|
||||||
|
EOF
|
||||||
|
|
||||||
|
- name: Prepare dependencies
|
||||||
|
run: ./y.rs prepare
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: ./y.rs build --sysroot none
|
||||||
|
|
||||||
|
- name: Test abi-cafe
|
||||||
|
env:
|
||||||
|
TARGET_TRIPLE: ${{ matrix.env.TARGET_TRIPLE }}
|
||||||
|
run: ./y.rs abi-cafe
|
@ -22,7 +22,7 @@ jobs:
|
|||||||
rustfmt --check build_system/mod.rs
|
rustfmt --check build_system/mod.rs
|
||||||
|
|
||||||
|
|
||||||
build:
|
test:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
timeout-minutes: 60
|
timeout-minutes: 60
|
||||||
|
|
||||||
@ -114,63 +114,6 @@ jobs:
|
|||||||
run: ./y.rs test
|
run: ./y.rs test
|
||||||
|
|
||||||
|
|
||||||
abi_cafe:
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
timeout-minutes: 60
|
|
||||||
|
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
shell: bash
|
|
||||||
|
|
||||||
strategy:
|
|
||||||
fail-fast: true
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- os: ubuntu-latest
|
|
||||||
env:
|
|
||||||
TARGET_TRIPLE: x86_64-unknown-linux-gnu
|
|
||||||
- os: macos-latest
|
|
||||||
env:
|
|
||||||
TARGET_TRIPLE: x86_64-apple-darwin
|
|
||||||
- os: windows-latest
|
|
||||||
env:
|
|
||||||
TARGET_TRIPLE: x86_64-pc-windows-msvc
|
|
||||||
- os: windows-latest
|
|
||||||
env:
|
|
||||||
TARGET_TRIPLE: x86_64-pc-windows-gnu
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Cache cargo target dir
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: build/cg_clif
|
|
||||||
key: ${{ runner.os }}-${{ matrix.env.TARGET_TRIPLE }}-cargo-build-target-${{ hashFiles('rust-toolchain', '**/Cargo.lock') }}
|
|
||||||
|
|
||||||
- name: Set MinGW as the default toolchain
|
|
||||||
if: matrix.env.TARGET_TRIPLE == 'x86_64-pc-windows-gnu'
|
|
||||||
run: rustup set default-host x86_64-pc-windows-gnu
|
|
||||||
|
|
||||||
- name: Use sparse cargo registry
|
|
||||||
run: |
|
|
||||||
cat >> ~/.cargo/config.toml <<EOF
|
|
||||||
[unstable]
|
|
||||||
sparse-registry = true
|
|
||||||
EOF
|
|
||||||
|
|
||||||
- name: Prepare dependencies
|
|
||||||
run: ./y.rs prepare
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: ./y.rs build --sysroot none
|
|
||||||
|
|
||||||
- name: Test abi-cafe
|
|
||||||
env:
|
|
||||||
TARGET_TRIPLE: ${{ matrix.env.TARGET_TRIPLE }}
|
|
||||||
run: ./y.rs abi-cafe
|
|
||||||
|
|
||||||
|
|
||||||
bench:
|
bench:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 60
|
timeout-minutes: 60
|
||||||
|
1
compiler/rustc_codegen_cranelift/.gitignore
vendored
1
compiler/rustc_codegen_cranelift/.gitignore
vendored
@ -14,3 +14,4 @@ perf.data.old
|
|||||||
/dist
|
/dist
|
||||||
/rust
|
/rust
|
||||||
/download
|
/download
|
||||||
|
/git-fixed-subtree.sh
|
||||||
|
@ -57,18 +57,18 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cranelift-bforest"
|
name = "cranelift-bforest"
|
||||||
version = "0.92.0"
|
version = "0.93.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2f3d54eab028f5805ae3b26fd60eca3f3a9cfb76b989d9bab173be3f61356cc3"
|
checksum = "a7379abaacee0f14abf3204a7606118f0465785252169d186337bcb75030815a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cranelift-entity",
|
"cranelift-entity",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cranelift-codegen"
|
name = "cranelift-codegen"
|
||||||
version = "0.92.0"
|
version = "0.93.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2be1d5f2c3cca1efb691844bc1988b89c77291f13f778499a3f3c0cf49c0ed61"
|
checksum = "9489fa336927df749631f1008007ced2871068544f40a202ce6d93fbf2366a7b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
"bumpalo",
|
"bumpalo",
|
||||||
@ -87,30 +87,30 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cranelift-codegen-meta"
|
name = "cranelift-codegen-meta"
|
||||||
version = "0.92.0"
|
version = "0.93.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3f9b1b1089750ce4005893af7ee00bb08a2cf1c9779999c0f7164cbc8ad2e0d2"
|
checksum = "05bbb67da91ec721ed57cef2f7c5ef7728e1cd9bde9ffd3ef8601022e73e3239"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cranelift-codegen-shared",
|
"cranelift-codegen-shared",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cranelift-codegen-shared"
|
name = "cranelift-codegen-shared"
|
||||||
version = "0.92.0"
|
version = "0.93.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cc5fbaec51de47297fd7304986fd53c8c0030abbe69728a60d72e1c63559318d"
|
checksum = "418ecb2f36032f6665dc1a5e2060a143dbab41d83b784882e97710e890a7a16d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cranelift-entity"
|
name = "cranelift-entity"
|
||||||
version = "0.92.0"
|
version = "0.93.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dab984c94593f876090fae92e984bdcc74d9b1acf740ab5f79036001c65cba13"
|
checksum = "7cf583f7b093f291005f9fb1323e2c37f6ee4c7909e39ce016b2e8360d461705"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cranelift-frontend"
|
name = "cranelift-frontend"
|
||||||
version = "0.92.0"
|
version = "0.93.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6e0cb3102d21a2fe5f3210af608748ddd0cd09825ac12d42dc56ed5ed8725fe0"
|
checksum = "7d361ed0373cf5f086b49c499aa72227b646a64f899f32e34312f97c0fadff75"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cranelift-codegen",
|
"cranelift-codegen",
|
||||||
"log",
|
"log",
|
||||||
@ -120,15 +120,15 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cranelift-isle"
|
name = "cranelift-isle"
|
||||||
version = "0.92.0"
|
version = "0.93.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "72101dd1f441d629735143c41e00b3428f9267738176983ef588ff43382af0a0"
|
checksum = "649782a39ce99798dd6b4029e2bb318a2fbeaade1b4fa25330763c10c65bc358"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cranelift-jit"
|
name = "cranelift-jit"
|
||||||
version = "0.92.0"
|
version = "0.93.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6557f8ce44d498777f2495aa58d9692a4a37d6f84aa445750d666cef770b6a5c"
|
checksum = "9c9909222db472fcc98d9e4e7192fa9d064dac63a3fa657df8c6daae86fb2604"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"cranelift-codegen",
|
"cranelift-codegen",
|
||||||
@ -145,9 +145,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cranelift-module"
|
name = "cranelift-module"
|
||||||
version = "0.92.0"
|
version = "0.93.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "88807e1c0c47ec02fe433333ccbe56b480425418b1470e333205e11650697d72"
|
checksum = "68689b83e52e605ba48652882d3fccc2e2e136abf139eb64ae667888ba0d52f8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"cranelift-codegen",
|
"cranelift-codegen",
|
||||||
@ -155,9 +155,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cranelift-native"
|
name = "cranelift-native"
|
||||||
version = "0.92.0"
|
version = "0.93.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c22b0d9fcbe3fc5a1af9e7021b44ce42b930bcefac446ce22e02e8f9a0d67120"
|
checksum = "f98e4e99a353703475d5acb402b9c13482d41d8a4008b352559bd560afb90363"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cranelift-codegen",
|
"cranelift-codegen",
|
||||||
"libc",
|
"libc",
|
||||||
@ -166,9 +166,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cranelift-object"
|
name = "cranelift-object"
|
||||||
version = "0.92.0"
|
version = "0.93.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "341375758d7c3fedc0b5315f552e6f0feac46baf87c450a15e9455ef47c2b261"
|
checksum = "b7a006ce1d8dd11df67567d8673e5920f3a56441812aed52a007ffce8f1b20e9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"cranelift-codegen",
|
"cranelift-codegen",
|
||||||
@ -333,6 +333,7 @@ dependencies = [
|
|||||||
"cranelift-frontend",
|
"cranelift-frontend",
|
||||||
"cranelift-jit",
|
"cranelift-jit",
|
||||||
"cranelift-module",
|
"cranelift-module",
|
||||||
|
"cranelift-native",
|
||||||
"cranelift-object",
|
"cranelift-object",
|
||||||
"gimli",
|
"gimli",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
@ -381,9 +382,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasmtime-jit-icache-coherence"
|
name = "wasmtime-jit-icache-coherence"
|
||||||
version = "5.0.0"
|
version = "6.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "08fcba5ebd96da2a9f0747ab6337fe9788adfb3f63fa2c180520d665562d257e"
|
checksum = "ec1fd0f0dd79e7cc0f55b102e320d7c77ab76cd272008a8fd98e25b5777e2636"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"libc",
|
"libc",
|
||||||
|
@ -15,14 +15,12 @@ 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 = { version = "0.92", features = ["unwind", "all-arch"] }
|
cranelift-codegen = { version = "0.93", features = ["unwind", "all-arch"] }
|
||||||
cranelift-frontend = { version = "0.92" }
|
cranelift-frontend = { version = "0.93" }
|
||||||
cranelift-module = { version = "0.92" }
|
cranelift-module = { version = "0.93" }
|
||||||
# NOTE vendored as src/cranelift_native.rs
|
cranelift-native = { version = "0.93" }
|
||||||
# FIXME revert back to the external crate with Cranelift 0.93
|
cranelift-jit = { version = "0.93", optional = true }
|
||||||
#cranelift-native = { version = "0.92" }
|
cranelift-object = { version = "0.93" }
|
||||||
cranelift-jit = { version = "0.92", optional = true }
|
|
||||||
cranelift-object = { version = "0.92" }
|
|
||||||
target-lexicon = "0.12.0"
|
target-lexicon = "0.12.0"
|
||||||
gimli = { version = "0.26.0", default-features = false, features = ["write"]}
|
gimli = { version = "0.26.0", default-features = false, features = ["write"]}
|
||||||
object = { version = "0.29.0", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] }
|
object = { version = "0.29.0", default-features = false, features = ["std", "read_core", "write", "archive", "coff", "elf", "macho", "pe"] }
|
||||||
|
@ -50,9 +50,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "compiler_builtins"
|
name = "compiler_builtins"
|
||||||
version = "0.1.86"
|
version = "0.1.89"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5dae98c88e576098d7ab13ebcb40cc43e5114b2beafe61a87cda9200649ff205"
|
checksum = "9fc9c2080d347a2c316518840ac9194644a9993dfa1e9778ef38979a339f5d8b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rustc-std-workspace-core",
|
"rustc-std-workspace-core",
|
||||||
]
|
]
|
||||||
@ -117,21 +117,20 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hermit-abi"
|
name = "hermit-abi"
|
||||||
version = "0.2.6"
|
version = "0.3.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7"
|
checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"compiler_builtins",
|
"compiler_builtins",
|
||||||
"libc",
|
|
||||||
"rustc-std-workspace-alloc",
|
"rustc-std-workspace-alloc",
|
||||||
"rustc-std-workspace-core",
|
"rustc-std-workspace-core",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.139"
|
version = "0.2.140"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
|
checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rustc-std-workspace-core",
|
"rustc-std-workspace-core",
|
||||||
]
|
]
|
||||||
@ -282,10 +281,8 @@ dependencies = [
|
|||||||
name = "test"
|
name = "test"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
|
||||||
"core",
|
"core",
|
||||||
"getopts",
|
"getopts",
|
||||||
"libc",
|
|
||||||
"panic_abort",
|
"panic_abort",
|
||||||
"panic_unwind",
|
"panic_unwind",
|
||||||
"proc_macro",
|
"proc_macro",
|
||||||
|
@ -8,7 +8,7 @@ alloc = { path = "./sysroot_src/library/alloc" }
|
|||||||
std = { path = "./sysroot_src/library/std", features = ["panic_unwind", "backtrace"] }
|
std = { path = "./sysroot_src/library/std", features = ["panic_unwind", "backtrace"] }
|
||||||
test = { path = "./sysroot_src/library/test" }
|
test = { path = "./sysroot_src/library/test" }
|
||||||
|
|
||||||
compiler_builtins = { version = "0.1.39", default-features = false, features = ["no-asm"] }
|
compiler_builtins = { version = "0.1.87", default-features = false, features = ["no-asm"] }
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
rustc-std-workspace-core = { path = "./sysroot_src/library/rustc-std-workspace-core" }
|
rustc-std-workspace-core = { path = "./sysroot_src/library/rustc-std-workspace-core" }
|
||||||
|
@ -46,13 +46,15 @@ pub(crate) fn build_sysroot(
|
|||||||
let wrapper_name = wrapper_base_name.replace("____", wrapper);
|
let wrapper_name = wrapper_base_name.replace("____", wrapper);
|
||||||
|
|
||||||
let mut build_cargo_wrapper_cmd = Command::new(&bootstrap_host_compiler.rustc);
|
let mut build_cargo_wrapper_cmd = Command::new(&bootstrap_host_compiler.rustc);
|
||||||
|
let wrapper_path = DIST_DIR.to_path(dirs).join(&wrapper_name);
|
||||||
build_cargo_wrapper_cmd
|
build_cargo_wrapper_cmd
|
||||||
.env("TOOLCHAIN_NAME", toolchain_name.clone())
|
.env("TOOLCHAIN_NAME", toolchain_name.clone())
|
||||||
.arg(RelPath::SCRIPTS.to_path(dirs).join(&format!("{wrapper}.rs")))
|
.arg(RelPath::SCRIPTS.to_path(dirs).join(&format!("{wrapper}.rs")))
|
||||||
.arg("-o")
|
.arg("-o")
|
||||||
.arg(DIST_DIR.to_path(dirs).join(wrapper_name))
|
.arg(&wrapper_path)
|
||||||
.arg("-Cstrip=debuginfo");
|
.arg("-Cstrip=debuginfo");
|
||||||
spawn_and_wait(build_cargo_wrapper_cmd);
|
spawn_and_wait(build_cargo_wrapper_cmd);
|
||||||
|
try_hard_link(wrapper_path, BIN_DIR.to_path(dirs).join(wrapper_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
let host = build_sysroot_for_triple(
|
let host = build_sysroot_for_triple(
|
||||||
@ -247,6 +249,7 @@ fn build_clif_sysroot_for_triple(
|
|||||||
if channel == "release" {
|
if channel == "release" {
|
||||||
build_cmd.arg("--release");
|
build_cmd.arg("--release");
|
||||||
}
|
}
|
||||||
|
build_cmd.arg("--locked");
|
||||||
build_cmd.env("__CARGO_DEFAULT_LIB_METADATA", "cg_clif");
|
build_cmd.env("__CARGO_DEFAULT_LIB_METADATA", "cg_clif");
|
||||||
if compiler.triple.contains("apple") {
|
if compiler.triple.contains("apple") {
|
||||||
build_cmd.env("CARGO_PROFILE_RELEASE_SPLIT_DEBUGINFO", "packed");
|
build_cmd.env("CARGO_PROFILE_RELEASE_SPLIT_DEBUGINFO", "packed");
|
||||||
|
@ -6,6 +6,7 @@ use std::process::Command;
|
|||||||
use super::build_sysroot::{BUILD_SYSROOT, ORIG_BUILD_SYSROOT, SYSROOT_RUSTC_VERSION, SYSROOT_SRC};
|
use super::build_sysroot::{BUILD_SYSROOT, ORIG_BUILD_SYSROOT, SYSROOT_RUSTC_VERSION, SYSROOT_SRC};
|
||||||
use super::path::{Dirs, RelPath};
|
use super::path::{Dirs, RelPath};
|
||||||
use super::rustc_info::{get_default_sysroot, get_rustc_version};
|
use super::rustc_info::{get_default_sysroot, get_rustc_version};
|
||||||
|
use super::tests::LIBCORE_TESTS_SRC;
|
||||||
use super::utils::{copy_dir_recursively, git_command, retry_spawn_and_wait, spawn_and_wait};
|
use super::utils::{copy_dir_recursively, git_command, retry_spawn_and_wait, spawn_and_wait};
|
||||||
|
|
||||||
pub(crate) fn prepare(dirs: &Dirs) {
|
pub(crate) fn prepare(dirs: &Dirs) {
|
||||||
@ -13,8 +14,10 @@ pub(crate) fn prepare(dirs: &Dirs) {
|
|||||||
|
|
||||||
spawn_and_wait(super::build_backend::CG_CLIF.fetch("cargo", "rustc", dirs));
|
spawn_and_wait(super::build_backend::CG_CLIF.fetch("cargo", "rustc", dirs));
|
||||||
|
|
||||||
prepare_sysroot(dirs);
|
prepare_stdlib(dirs);
|
||||||
spawn_and_wait(super::build_sysroot::STANDARD_LIBRARY.fetch("cargo", "rustc", dirs));
|
spawn_and_wait(super::build_sysroot::STANDARD_LIBRARY.fetch("cargo", "rustc", dirs));
|
||||||
|
|
||||||
|
prepare_coretests(dirs);
|
||||||
spawn_and_wait(super::tests::LIBCORE_TESTS.fetch("cargo", "rustc", dirs));
|
spawn_and_wait(super::tests::LIBCORE_TESTS.fetch("cargo", "rustc", dirs));
|
||||||
|
|
||||||
super::tests::RAND_REPO.fetch(dirs);
|
super::tests::RAND_REPO.fetch(dirs);
|
||||||
@ -25,11 +28,11 @@ pub(crate) fn prepare(dirs: &Dirs) {
|
|||||||
spawn_and_wait(super::tests::PORTABLE_SIMD.fetch("cargo", "rustc", dirs));
|
spawn_and_wait(super::tests::PORTABLE_SIMD.fetch("cargo", "rustc", dirs));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prepare_sysroot(dirs: &Dirs) {
|
fn prepare_stdlib(dirs: &Dirs) {
|
||||||
let sysroot_src_orig = get_default_sysroot(Path::new("rustc")).join("lib/rustlib/src/rust");
|
let sysroot_src_orig = get_default_sysroot(Path::new("rustc")).join("lib/rustlib/src/rust");
|
||||||
assert!(sysroot_src_orig.exists());
|
assert!(sysroot_src_orig.exists());
|
||||||
|
|
||||||
eprintln!("[COPY] sysroot src");
|
eprintln!("[COPY] stdlib src");
|
||||||
|
|
||||||
// FIXME ensure builds error out or update the copy if any of the files copied here change
|
// FIXME ensure builds error out or update the copy if any of the files copied here change
|
||||||
BUILD_SYSROOT.ensure_fresh(dirs);
|
BUILD_SYSROOT.ensure_fresh(dirs);
|
||||||
@ -47,7 +50,25 @@ fn prepare_sysroot(dirs: &Dirs) {
|
|||||||
eprintln!("[GIT] init");
|
eprintln!("[GIT] init");
|
||||||
init_git_repo(&SYSROOT_SRC.to_path(dirs));
|
init_git_repo(&SYSROOT_SRC.to_path(dirs));
|
||||||
|
|
||||||
apply_patches(dirs, "sysroot", &SYSROOT_SRC.to_path(dirs));
|
apply_patches(dirs, "stdlib", &SYSROOT_SRC.to_path(dirs));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn prepare_coretests(dirs: &Dirs) {
|
||||||
|
let sysroot_src_orig = get_default_sysroot(Path::new("rustc")).join("lib/rustlib/src/rust");
|
||||||
|
assert!(sysroot_src_orig.exists());
|
||||||
|
|
||||||
|
eprintln!("[COPY] coretests src");
|
||||||
|
|
||||||
|
fs::create_dir_all(LIBCORE_TESTS_SRC.to_path(dirs)).unwrap();
|
||||||
|
copy_dir_recursively(
|
||||||
|
&sysroot_src_orig.join("library/core/tests"),
|
||||||
|
&LIBCORE_TESTS_SRC.to_path(dirs),
|
||||||
|
);
|
||||||
|
|
||||||
|
eprintln!("[GIT] init");
|
||||||
|
init_git_repo(&LIBCORE_TESTS_SRC.to_path(dirs));
|
||||||
|
|
||||||
|
apply_patches(dirs, "coretests", &LIBCORE_TESTS_SRC.to_path(dirs));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) struct GitRepo {
|
pub(crate) struct GitRepo {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use super::build_sysroot::{self, SYSROOT_SRC};
|
use super::build_sysroot;
|
||||||
use super::config;
|
use super::config;
|
||||||
use super::path::{Dirs, RelPath};
|
use super::path::{Dirs, RelPath};
|
||||||
use super::prepare::GitRepo;
|
use super::prepare::GitRepo;
|
||||||
@ -94,40 +94,42 @@ const BASE_SYSROOT_SUITE: &[TestCase] = &[
|
|||||||
TestCase::build_bin_and_run("aot.issue-72793", "example/issue-72793.rs", &[]),
|
TestCase::build_bin_and_run("aot.issue-72793", "example/issue-72793.rs", &[]),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// FIXME(rust-random/rand#1293): Newer rand versions fail to test on Windows. Update once this is
|
||||||
|
// fixed.
|
||||||
pub(crate) static RAND_REPO: GitRepo =
|
pub(crate) static RAND_REPO: GitRepo =
|
||||||
GitRepo::github("rust-random", "rand", "0f933f9c7176e53b2a3c7952ded484e1783f0bf1", "rand");
|
GitRepo::github("rust-random", "rand", "50b9a447410860af8d6db9a208c3576886955874", "rand");
|
||||||
|
|
||||||
pub(crate) static RAND: CargoProject = CargoProject::new(&RAND_REPO.source_dir(), "rand");
|
pub(crate) static RAND: CargoProject = CargoProject::new(&RAND_REPO.source_dir(), "rand");
|
||||||
|
|
||||||
pub(crate) static REGEX_REPO: GitRepo =
|
pub(crate) static REGEX_REPO: GitRepo =
|
||||||
GitRepo::github("rust-lang", "regex", "341f207c1071f7290e3f228c710817c280c8dca1", "regex");
|
GitRepo::github("rust-lang", "regex", "a9b2e02352db92ce1f6e5b7ecd41b8bbffbe161a", "regex");
|
||||||
|
|
||||||
pub(crate) static REGEX: CargoProject = CargoProject::new(®EX_REPO.source_dir(), "regex");
|
pub(crate) static REGEX: CargoProject = CargoProject::new(®EX_REPO.source_dir(), "regex");
|
||||||
|
|
||||||
pub(crate) static PORTABLE_SIMD_REPO: GitRepo = GitRepo::github(
|
pub(crate) static PORTABLE_SIMD_REPO: GitRepo = GitRepo::github(
|
||||||
"rust-lang",
|
"rust-lang",
|
||||||
"portable-simd",
|
"portable-simd",
|
||||||
"582239ac3b32007613df04d7ffa78dc30f4c5645",
|
"9bd30e77b3a3c699af102ebb3df0f6110f8aa02e",
|
||||||
"portable-simd",
|
"portable-simd",
|
||||||
);
|
);
|
||||||
|
|
||||||
pub(crate) static PORTABLE_SIMD: CargoProject =
|
pub(crate) static PORTABLE_SIMD: CargoProject =
|
||||||
CargoProject::new(&PORTABLE_SIMD_REPO.source_dir(), "portable_simd");
|
CargoProject::new(&PORTABLE_SIMD_REPO.source_dir(), "portable_simd");
|
||||||
|
|
||||||
pub(crate) static LIBCORE_TESTS: CargoProject =
|
pub(crate) static LIBCORE_TESTS_SRC: RelPath = RelPath::DOWNLOAD.join("coretests_src");
|
||||||
CargoProject::new(&SYSROOT_SRC.join("library/core/tests"), "core_tests");
|
|
||||||
|
pub(crate) static LIBCORE_TESTS: CargoProject = CargoProject::new(&LIBCORE_TESTS_SRC, "core_tests");
|
||||||
|
|
||||||
const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
|
const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
|
||||||
TestCase::custom("test.rust-random/rand", &|runner| {
|
TestCase::custom("test.rust-random/rand", &|runner| {
|
||||||
RAND.clean(&runner.dirs);
|
RAND.clean(&runner.dirs);
|
||||||
|
|
||||||
if runner.is_native {
|
if runner.is_native {
|
||||||
eprintln!("[TEST] rust-random/rand");
|
|
||||||
let mut test_cmd = RAND.test(&runner.target_compiler, &runner.dirs);
|
let mut test_cmd = RAND.test(&runner.target_compiler, &runner.dirs);
|
||||||
test_cmd.arg("--workspace");
|
test_cmd.arg("--workspace").arg("--").arg("-q");
|
||||||
spawn_and_wait(test_cmd);
|
spawn_and_wait(test_cmd);
|
||||||
} else {
|
} else {
|
||||||
eprintln!("[AOT] rust-random/rand");
|
eprintln!("Cross-Compiling: Not running tests");
|
||||||
let mut build_cmd = RAND.build(&runner.target_compiler, &runner.dirs);
|
let mut build_cmd = RAND.build(&runner.target_compiler, &runner.dirs);
|
||||||
build_cmd.arg("--workspace").arg("--tests");
|
build_cmd.arg("--workspace").arg("--tests");
|
||||||
spawn_and_wait(build_cmd);
|
spawn_and_wait(build_cmd);
|
||||||
@ -137,7 +139,9 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
|
|||||||
LIBCORE_TESTS.clean(&runner.dirs);
|
LIBCORE_TESTS.clean(&runner.dirs);
|
||||||
|
|
||||||
if runner.is_native {
|
if runner.is_native {
|
||||||
spawn_and_wait(LIBCORE_TESTS.test(&runner.target_compiler, &runner.dirs));
|
let mut test_cmd = LIBCORE_TESTS.test(&runner.target_compiler, &runner.dirs);
|
||||||
|
test_cmd.arg("--").arg("-q");
|
||||||
|
spawn_and_wait(test_cmd);
|
||||||
} else {
|
} else {
|
||||||
eprintln!("Cross-Compiling: Not running tests");
|
eprintln!("Cross-Compiling: Not running tests");
|
||||||
let mut build_cmd = LIBCORE_TESTS.build(&runner.target_compiler, &runner.dirs);
|
let mut build_cmd = LIBCORE_TESTS.build(&runner.target_compiler, &runner.dirs);
|
||||||
@ -148,18 +152,13 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
|
|||||||
TestCase::custom("test.regex-shootout-regex-dna", &|runner| {
|
TestCase::custom("test.regex-shootout-regex-dna", &|runner| {
|
||||||
REGEX.clean(&runner.dirs);
|
REGEX.clean(&runner.dirs);
|
||||||
|
|
||||||
// newer aho_corasick versions throw a deprecation warning
|
|
||||||
let lint_rust_flags = format!("{} --cap-lints warn", runner.target_compiler.rustflags);
|
|
||||||
|
|
||||||
let mut build_cmd = REGEX.build(&runner.target_compiler, &runner.dirs);
|
let mut build_cmd = REGEX.build(&runner.target_compiler, &runner.dirs);
|
||||||
build_cmd.arg("--example").arg("shootout-regex-dna");
|
build_cmd.arg("--example").arg("shootout-regex-dna");
|
||||||
build_cmd.env("RUSTFLAGS", lint_rust_flags.clone());
|
|
||||||
spawn_and_wait(build_cmd);
|
spawn_and_wait(build_cmd);
|
||||||
|
|
||||||
if runner.is_native {
|
if runner.is_native {
|
||||||
let mut run_cmd = REGEX.run(&runner.target_compiler, &runner.dirs);
|
let mut run_cmd = REGEX.run(&runner.target_compiler, &runner.dirs);
|
||||||
run_cmd.arg("--example").arg("shootout-regex-dna");
|
run_cmd.arg("--example").arg("shootout-regex-dna");
|
||||||
run_cmd.env("RUSTFLAGS", lint_rust_flags);
|
|
||||||
|
|
||||||
let input = fs::read_to_string(
|
let input = fs::read_to_string(
|
||||||
REGEX.source_dir(&runner.dirs).join("examples").join("regexdna-input.txt"),
|
REGEX.source_dir(&runner.dirs).join("examples").join("regexdna-input.txt"),
|
||||||
@ -171,13 +170,6 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let output = spawn_and_wait_with_input(run_cmd, input);
|
let output = spawn_and_wait_with_input(run_cmd, input);
|
||||||
// Make sure `[codegen mono items] start` doesn't poison the diff
|
|
||||||
let output = output
|
|
||||||
.lines()
|
|
||||||
.filter(|line| !line.contains("codegen mono items"))
|
|
||||||
.chain(Some("")) // This just adds the trailing newline
|
|
||||||
.collect::<Vec<&str>>()
|
|
||||||
.join("\r\n");
|
|
||||||
|
|
||||||
let output_matches = expected.lines().eq(output.lines());
|
let output_matches = expected.lines().eq(output.lines());
|
||||||
if !output_matches {
|
if !output_matches {
|
||||||
@ -192,27 +184,14 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
|
|||||||
TestCase::custom("test.regex", &|runner| {
|
TestCase::custom("test.regex", &|runner| {
|
||||||
REGEX.clean(&runner.dirs);
|
REGEX.clean(&runner.dirs);
|
||||||
|
|
||||||
// newer aho_corasick versions throw a deprecation warning
|
|
||||||
let lint_rust_flags = format!("{} --cap-lints warn", runner.target_compiler.rustflags);
|
|
||||||
|
|
||||||
if runner.is_native {
|
if runner.is_native {
|
||||||
let mut run_cmd = REGEX.test(&runner.target_compiler, &runner.dirs);
|
let mut run_cmd = REGEX.test(&runner.target_compiler, &runner.dirs);
|
||||||
run_cmd.args([
|
run_cmd.args(["--workspace", "--", "-q"]);
|
||||||
"--tests",
|
|
||||||
"--",
|
|
||||||
"--exclude-should-panic",
|
|
||||||
"--test-threads",
|
|
||||||
"1",
|
|
||||||
"-Zunstable-options",
|
|
||||||
"-q",
|
|
||||||
]);
|
|
||||||
run_cmd.env("RUSTFLAGS", lint_rust_flags);
|
|
||||||
spawn_and_wait(run_cmd);
|
spawn_and_wait(run_cmd);
|
||||||
} else {
|
} else {
|
||||||
eprintln!("Cross-Compiling: Not running tests");
|
eprintln!("Cross-Compiling: Not running tests");
|
||||||
let mut build_cmd = REGEX.build(&runner.target_compiler, &runner.dirs);
|
let mut build_cmd = REGEX.build(&runner.target_compiler, &runner.dirs);
|
||||||
build_cmd.arg("--tests");
|
build_cmd.arg("--tests");
|
||||||
build_cmd.env("RUSTFLAGS", lint_rust_flags.clone());
|
|
||||||
spawn_and_wait(build_cmd);
|
spawn_and_wait(build_cmd);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
@ -518,6 +518,17 @@ pub struct Box<T: ?Sized>(Unique<T>, ());
|
|||||||
|
|
||||||
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {}
|
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {}
|
||||||
|
|
||||||
|
impl<T> Box<T> {
|
||||||
|
pub fn new(val: T) -> Box<T> {
|
||||||
|
unsafe {
|
||||||
|
let size = intrinsics::size_of::<T>();
|
||||||
|
let ptr = libc::malloc(size);
|
||||||
|
intrinsics::copy(&val as *const T as *const u8, ptr, size);
|
||||||
|
Box(Unique { pointer: NonNull(ptr as *const T), _marker: PhantomData }, ())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: ?Sized> Drop for Box<T> {
|
impl<T: ?Sized> Drop for Box<T> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
// drop is currently performed by compiler.
|
// drop is currently performed by compiler.
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
#![feature(no_core, lang_items, never_type, linkage, extern_types, thread_local)]
|
#![feature(no_core, lang_items, never_type, linkage, extern_types, thread_local, repr_simd)]
|
||||||
#![no_core]
|
#![no_core]
|
||||||
#![allow(dead_code, non_camel_case_types)]
|
#![allow(dead_code, non_camel_case_types)]
|
||||||
|
|
||||||
extern crate mini_core;
|
extern crate mini_core;
|
||||||
|
|
||||||
use mini_core::*;
|
|
||||||
use mini_core::libc::*;
|
use mini_core::libc::*;
|
||||||
|
use mini_core::*;
|
||||||
|
|
||||||
macro_rules! assert {
|
macro_rules! assert {
|
||||||
($e:expr) => {
|
($e:expr) => {
|
||||||
if !$e {
|
if !$e {
|
||||||
panic(stringify!(! $e));
|
panic(stringify!(!$e));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -20,7 +20,7 @@ macro_rules! assert_eq {
|
|||||||
if $l != $r {
|
if $l != $r {
|
||||||
panic(stringify!($l != $r));
|
panic(stringify!($l != $r));
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[lang = "termination"]
|
#[lang = "termination"]
|
||||||
@ -96,9 +96,15 @@ fn start<T: Termination + 'static>(
|
|||||||
_sigpipe: u8,
|
_sigpipe: u8,
|
||||||
) -> isize {
|
) -> isize {
|
||||||
if argc == 3 {
|
if argc == 3 {
|
||||||
unsafe { puts(*argv as *const i8); }
|
unsafe {
|
||||||
unsafe { puts(*((argv as usize + intrinsics::size_of::<*const u8>()) as *const *const i8)); }
|
puts(*argv as *const i8);
|
||||||
unsafe { puts(*((argv as usize + 2 * intrinsics::size_of::<*const u8>()) as *const *const i8)); }
|
}
|
||||||
|
unsafe {
|
||||||
|
puts(*((argv as usize + intrinsics::size_of::<*const u8>()) as *const *const i8));
|
||||||
|
}
|
||||||
|
unsafe {
|
||||||
|
puts(*((argv as usize + 2 * intrinsics::size_of::<*const u8>()) as *const *const i8));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
main().report() as isize
|
main().report() as isize
|
||||||
@ -107,7 +113,6 @@ fn start<T: Termination + 'static>(
|
|||||||
static mut NUM: u8 = 6 * 7;
|
static mut NUM: u8 = 6 * 7;
|
||||||
static NUM_REF: &'static u8 = unsafe { &NUM };
|
static NUM_REF: &'static u8 = unsafe { &NUM };
|
||||||
|
|
||||||
|
|
||||||
unsafe fn zeroed<T>() -> T {
|
unsafe fn zeroed<T>() -> T {
|
||||||
let mut uninit = MaybeUninit { uninit: () };
|
let mut uninit = MaybeUninit { uninit: () };
|
||||||
intrinsics::write_bytes(&mut uninit.value.value as *mut T, 0, 1);
|
intrinsics::write_bytes(&mut uninit.value.value as *mut T, 0, 1);
|
||||||
@ -144,10 +149,7 @@ extern "C" fn bool_struct_in_11(_arg0: bool_11) {}
|
|||||||
|
|
||||||
#[allow(unreachable_code)] // FIXME false positive
|
#[allow(unreachable_code)] // FIXME false positive
|
||||||
fn main() {
|
fn main() {
|
||||||
take_unique(Unique {
|
take_unique(Unique { pointer: unsafe { NonNull(1 as *mut ()) }, _marker: PhantomData });
|
||||||
pointer: unsafe { NonNull(1 as *mut ()) },
|
|
||||||
_marker: PhantomData,
|
|
||||||
});
|
|
||||||
take_f32(0.1);
|
take_f32(0.1);
|
||||||
|
|
||||||
call_return_u128_pair();
|
call_return_u128_pair();
|
||||||
@ -202,17 +204,17 @@ fn main() {
|
|||||||
assert_eq!(intrinsics::size_of_val(&0u32) as u8, 4);
|
assert_eq!(intrinsics::size_of_val(&0u32) as u8, 4);
|
||||||
|
|
||||||
assert_eq!(intrinsics::min_align_of::<u16>() as u8, 2);
|
assert_eq!(intrinsics::min_align_of::<u16>() as u8, 2);
|
||||||
assert_eq!(intrinsics::min_align_of_val(&a) as u8, intrinsics::min_align_of::<&str>() as u8);
|
assert_eq!(
|
||||||
|
intrinsics::min_align_of_val(&a) as u8,
|
||||||
|
intrinsics::min_align_of::<&str>() as u8
|
||||||
|
);
|
||||||
|
|
||||||
assert!(!intrinsics::needs_drop::<u8>());
|
assert!(!intrinsics::needs_drop::<u8>());
|
||||||
assert!(!intrinsics::needs_drop::<[u8]>());
|
assert!(!intrinsics::needs_drop::<[u8]>());
|
||||||
assert!(intrinsics::needs_drop::<NoisyDrop>());
|
assert!(intrinsics::needs_drop::<NoisyDrop>());
|
||||||
assert!(intrinsics::needs_drop::<NoisyDropUnsized>());
|
assert!(intrinsics::needs_drop::<NoisyDropUnsized>());
|
||||||
|
|
||||||
Unique {
|
Unique { pointer: NonNull(1 as *mut &str), _marker: PhantomData } as Unique<dyn SomeTrait>;
|
||||||
pointer: NonNull(1 as *mut &str),
|
|
||||||
_marker: PhantomData,
|
|
||||||
} as Unique<dyn SomeTrait>;
|
|
||||||
|
|
||||||
struct MyDst<T: ?Sized>(T);
|
struct MyDst<T: ?Sized>(T);
|
||||||
|
|
||||||
@ -238,19 +240,17 @@ fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = Box::new(NoisyDrop {
|
let _ = Box::new(NoisyDrop { text: "Boxed outer got dropped!\0", inner: NoisyDropInner })
|
||||||
text: "Boxed outer got dropped!\0",
|
as Box<dyn SomeTrait>;
|
||||||
inner: NoisyDropInner,
|
|
||||||
}) as Box<dyn SomeTrait>;
|
|
||||||
|
|
||||||
const FUNC_REF: Option<fn()> = Some(main);
|
const FUNC_REF: Option<fn()> = Some(main);
|
||||||
match FUNC_REF {
|
match FUNC_REF {
|
||||||
Some(_) => {},
|
Some(_) => {}
|
||||||
None => assert!(false),
|
None => assert!(false),
|
||||||
}
|
}
|
||||||
|
|
||||||
match Ordering::Less {
|
match Ordering::Less {
|
||||||
Ordering::Less => {},
|
Ordering::Less => {}
|
||||||
_ => assert!(false),
|
_ => assert!(false),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,19 +266,21 @@ fn main() {
|
|||||||
|
|
||||||
#[cfg(not(any(jit, windows)))]
|
#[cfg(not(any(jit, windows)))]
|
||||||
{
|
{
|
||||||
extern {
|
extern "C" {
|
||||||
#[linkage = "extern_weak"]
|
#[linkage = "extern_weak"]
|
||||||
static ABC: *const u8;
|
static ABC: *const u8;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
extern {
|
extern "C" {
|
||||||
#[linkage = "extern_weak"]
|
#[linkage = "extern_weak"]
|
||||||
static ABC: *const u8;
|
static ABC: *const u8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe { assert_eq!(ABC as usize, 0); }
|
unsafe {
|
||||||
|
assert_eq!(ABC as usize, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&mut (|| Some(0 as *const ())) as &mut dyn FnMut() -> Option<*const ()>;
|
&mut (|| Some(0 as *const ())) as &mut dyn FnMut() -> Option<*const ()>;
|
||||||
@ -339,7 +341,13 @@ fn main() {
|
|||||||
|
|
||||||
assert_eq!(unsafe { intrinsics::size_of_val(x) }, 0);
|
assert_eq!(unsafe { intrinsics::size_of_val(x) }, 0);
|
||||||
assert_eq!(unsafe { intrinsics::min_align_of_val(x) }, 1);
|
assert_eq!(unsafe { intrinsics::min_align_of_val(x) }, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[repr(simd)]
|
||||||
|
struct V([f64; 2]);
|
||||||
|
|
||||||
|
let f = V([0.0, 1.0]);
|
||||||
|
let _a = f.0[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(not(jit), target_arch = "x86_64", any(target_os = "linux", target_os = "darwin")))]
|
#[cfg(all(not(jit), target_arch = "x86_64", any(target_os = "linux", target_os = "darwin")))]
|
||||||
@ -392,13 +400,10 @@ extern "C" {
|
|||||||
native: *mut pthread_t,
|
native: *mut pthread_t,
|
||||||
attr: *const pthread_attr_t,
|
attr: *const pthread_attr_t,
|
||||||
f: extern "C" fn(_: *mut c_void) -> *mut c_void,
|
f: extern "C" fn(_: *mut c_void) -> *mut c_void,
|
||||||
value: *mut c_void
|
value: *mut c_void,
|
||||||
) -> c_int;
|
) -> c_int;
|
||||||
|
|
||||||
fn pthread_join(
|
fn pthread_join(native: pthread_t, value: *mut *mut c_void) -> c_int;
|
||||||
native: pthread_t,
|
|
||||||
value: *mut *mut c_void
|
|
||||||
) -> c_int;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type DWORD = u32;
|
type DWORD = u32;
|
||||||
@ -410,10 +415,7 @@ type HANDLE = *mut c_void;
|
|||||||
#[link(name = "msvcrt")]
|
#[link(name = "msvcrt")]
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
fn WaitForSingleObject(
|
fn WaitForSingleObject(hHandle: LPVOID, dwMilliseconds: DWORD) -> DWORD;
|
||||||
hHandle: LPVOID,
|
|
||||||
dwMilliseconds: DWORD
|
|
||||||
) -> DWORD;
|
|
||||||
|
|
||||||
fn CreateThread(
|
fn CreateThread(
|
||||||
lpThreadAttributes: LPVOID, // Technically LPSECURITY_ATTRIBUTES, but we don't use it anyway
|
lpThreadAttributes: LPVOID, // Technically LPSECURITY_ATTRIBUTES, but we don't use it anyway
|
||||||
@ -421,7 +423,7 @@ extern "C" {
|
|||||||
lpStartAddress: extern "C" fn(_: *mut c_void) -> *mut c_void,
|
lpStartAddress: extern "C" fn(_: *mut c_void) -> *mut c_void,
|
||||||
lpParameter: LPVOID,
|
lpParameter: LPVOID,
|
||||||
dwCreationFlags: DWORD,
|
dwCreationFlags: DWORD,
|
||||||
lpThreadId: LPDWORD
|
lpThreadId: LPDWORD,
|
||||||
) -> HANDLE;
|
) -> HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,9 +449,7 @@ impl Thread {
|
|||||||
assert!(false);
|
assert!(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread {
|
Thread { handle: thread }
|
||||||
handle: thread,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
@ -460,13 +460,10 @@ impl Thread {
|
|||||||
assert!(false);
|
assert!(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread {
|
Thread { handle }
|
||||||
handle,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsafe fn join(self) {
|
unsafe fn join(self) {
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
{
|
{
|
||||||
@ -483,16 +480,15 @@ impl Thread {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[thread_local]
|
#[thread_local]
|
||||||
#[cfg(not(jit))]
|
#[cfg(not(jit))]
|
||||||
static mut TLS: u8 = 42;
|
static mut TLS: u8 = 42;
|
||||||
|
|
||||||
#[cfg(not(jit))]
|
#[cfg(not(jit))]
|
||||||
extern "C" fn mutate_tls(_: *mut c_void) -> *mut c_void {
|
extern "C" fn mutate_tls(_: *mut c_void) -> *mut c_void {
|
||||||
unsafe { TLS = 0; }
|
unsafe {
|
||||||
|
TLS = 0;
|
||||||
|
}
|
||||||
0 as *mut c_void
|
0 as *mut c_void
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -531,44 +527,267 @@ pub enum E1 {
|
|||||||
pub enum E2<X> {
|
pub enum E2<X> {
|
||||||
V1 { f: bool },
|
V1 { f: bool },
|
||||||
|
|
||||||
/*_00*/ _01(X), _02(X), _03(X), _04(X), _05(X), _06(X), _07(X),
|
/*_00*/ _01(X),
|
||||||
_08(X), _09(X), _0A(X), _0B(X), _0C(X), _0D(X), _0E(X), _0F(X),
|
_02(X),
|
||||||
_10(X), _11(X), _12(X), _13(X), _14(X), _15(X), _16(X), _17(X),
|
_03(X),
|
||||||
_18(X), _19(X), _1A(X), _1B(X), _1C(X), _1D(X), _1E(X), _1F(X),
|
_04(X),
|
||||||
_20(X), _21(X), _22(X), _23(X), _24(X), _25(X), _26(X), _27(X),
|
_05(X),
|
||||||
_28(X), _29(X), _2A(X), _2B(X), _2C(X), _2D(X), _2E(X), _2F(X),
|
_06(X),
|
||||||
_30(X), _31(X), _32(X), _33(X), _34(X), _35(X), _36(X), _37(X),
|
_07(X),
|
||||||
_38(X), _39(X), _3A(X), _3B(X), _3C(X), _3D(X), _3E(X), _3F(X),
|
_08(X),
|
||||||
_40(X), _41(X), _42(X), _43(X), _44(X), _45(X), _46(X), _47(X),
|
_09(X),
|
||||||
_48(X), _49(X), _4A(X), _4B(X), _4C(X), _4D(X), _4E(X), _4F(X),
|
_0A(X),
|
||||||
_50(X), _51(X), _52(X), _53(X), _54(X), _55(X), _56(X), _57(X),
|
_0B(X),
|
||||||
_58(X), _59(X), _5A(X), _5B(X), _5C(X), _5D(X), _5E(X), _5F(X),
|
_0C(X),
|
||||||
_60(X), _61(X), _62(X), _63(X), _64(X), _65(X), _66(X), _67(X),
|
_0D(X),
|
||||||
_68(X), _69(X), _6A(X), _6B(X), _6C(X), _6D(X), _6E(X), _6F(X),
|
_0E(X),
|
||||||
_70(X), _71(X), _72(X), _73(X), _74(X), _75(X), _76(X), _77(X),
|
_0F(X),
|
||||||
_78(X), _79(X), _7A(X), _7B(X), _7C(X), _7D(X), _7E(X), _7F(X),
|
_10(X),
|
||||||
_80(X), _81(X), _82(X), _83(X), _84(X), _85(X), _86(X), _87(X),
|
_11(X),
|
||||||
_88(X), _89(X), _8A(X), _8B(X), _8C(X), _8D(X), _8E(X), _8F(X),
|
_12(X),
|
||||||
_90(X), _91(X), _92(X), _93(X), _94(X), _95(X), _96(X), _97(X),
|
_13(X),
|
||||||
_98(X), _99(X), _9A(X), _9B(X), _9C(X), _9D(X), _9E(X), _9F(X),
|
_14(X),
|
||||||
_A0(X), _A1(X), _A2(X), _A3(X), _A4(X), _A5(X), _A6(X), _A7(X),
|
_15(X),
|
||||||
_A8(X), _A9(X), _AA(X), _AB(X), _AC(X), _AD(X), _AE(X), _AF(X),
|
_16(X),
|
||||||
_B0(X), _B1(X), _B2(X), _B3(X), _B4(X), _B5(X), _B6(X), _B7(X),
|
_17(X),
|
||||||
_B8(X), _B9(X), _BA(X), _BB(X), _BC(X), _BD(X), _BE(X), _BF(X),
|
_18(X),
|
||||||
_C0(X), _C1(X), _C2(X), _C3(X), _C4(X), _C5(X), _C6(X), _C7(X),
|
_19(X),
|
||||||
_C8(X), _C9(X), _CA(X), _CB(X), _CC(X), _CD(X), _CE(X), _CF(X),
|
_1A(X),
|
||||||
_D0(X), _D1(X), _D2(X), _D3(X), _D4(X), _D5(X), _D6(X), _D7(X),
|
_1B(X),
|
||||||
_D8(X), _D9(X), _DA(X), _DB(X), _DC(X), _DD(X), _DE(X), _DF(X),
|
_1C(X),
|
||||||
_E0(X), _E1(X), _E2(X), _E3(X), _E4(X), _E5(X), _E6(X), _E7(X),
|
_1D(X),
|
||||||
_E8(X), _E9(X), _EA(X), _EB(X), _EC(X), _ED(X), _EE(X), _EF(X),
|
_1E(X),
|
||||||
_F0(X), _F1(X), _F2(X), _F3(X), _F4(X), _F5(X), _F6(X), _F7(X),
|
_1F(X),
|
||||||
_F8(X), _F9(X), _FA(X), _FB(X), _FC(X), _FD(X), _FE(X), _FF(X),
|
_20(X),
|
||||||
|
_21(X),
|
||||||
|
_22(X),
|
||||||
|
_23(X),
|
||||||
|
_24(X),
|
||||||
|
_25(X),
|
||||||
|
_26(X),
|
||||||
|
_27(X),
|
||||||
|
_28(X),
|
||||||
|
_29(X),
|
||||||
|
_2A(X),
|
||||||
|
_2B(X),
|
||||||
|
_2C(X),
|
||||||
|
_2D(X),
|
||||||
|
_2E(X),
|
||||||
|
_2F(X),
|
||||||
|
_30(X),
|
||||||
|
_31(X),
|
||||||
|
_32(X),
|
||||||
|
_33(X),
|
||||||
|
_34(X),
|
||||||
|
_35(X),
|
||||||
|
_36(X),
|
||||||
|
_37(X),
|
||||||
|
_38(X),
|
||||||
|
_39(X),
|
||||||
|
_3A(X),
|
||||||
|
_3B(X),
|
||||||
|
_3C(X),
|
||||||
|
_3D(X),
|
||||||
|
_3E(X),
|
||||||
|
_3F(X),
|
||||||
|
_40(X),
|
||||||
|
_41(X),
|
||||||
|
_42(X),
|
||||||
|
_43(X),
|
||||||
|
_44(X),
|
||||||
|
_45(X),
|
||||||
|
_46(X),
|
||||||
|
_47(X),
|
||||||
|
_48(X),
|
||||||
|
_49(X),
|
||||||
|
_4A(X),
|
||||||
|
_4B(X),
|
||||||
|
_4C(X),
|
||||||
|
_4D(X),
|
||||||
|
_4E(X),
|
||||||
|
_4F(X),
|
||||||
|
_50(X),
|
||||||
|
_51(X),
|
||||||
|
_52(X),
|
||||||
|
_53(X),
|
||||||
|
_54(X),
|
||||||
|
_55(X),
|
||||||
|
_56(X),
|
||||||
|
_57(X),
|
||||||
|
_58(X),
|
||||||
|
_59(X),
|
||||||
|
_5A(X),
|
||||||
|
_5B(X),
|
||||||
|
_5C(X),
|
||||||
|
_5D(X),
|
||||||
|
_5E(X),
|
||||||
|
_5F(X),
|
||||||
|
_60(X),
|
||||||
|
_61(X),
|
||||||
|
_62(X),
|
||||||
|
_63(X),
|
||||||
|
_64(X),
|
||||||
|
_65(X),
|
||||||
|
_66(X),
|
||||||
|
_67(X),
|
||||||
|
_68(X),
|
||||||
|
_69(X),
|
||||||
|
_6A(X),
|
||||||
|
_6B(X),
|
||||||
|
_6C(X),
|
||||||
|
_6D(X),
|
||||||
|
_6E(X),
|
||||||
|
_6F(X),
|
||||||
|
_70(X),
|
||||||
|
_71(X),
|
||||||
|
_72(X),
|
||||||
|
_73(X),
|
||||||
|
_74(X),
|
||||||
|
_75(X),
|
||||||
|
_76(X),
|
||||||
|
_77(X),
|
||||||
|
_78(X),
|
||||||
|
_79(X),
|
||||||
|
_7A(X),
|
||||||
|
_7B(X),
|
||||||
|
_7C(X),
|
||||||
|
_7D(X),
|
||||||
|
_7E(X),
|
||||||
|
_7F(X),
|
||||||
|
_80(X),
|
||||||
|
_81(X),
|
||||||
|
_82(X),
|
||||||
|
_83(X),
|
||||||
|
_84(X),
|
||||||
|
_85(X),
|
||||||
|
_86(X),
|
||||||
|
_87(X),
|
||||||
|
_88(X),
|
||||||
|
_89(X),
|
||||||
|
_8A(X),
|
||||||
|
_8B(X),
|
||||||
|
_8C(X),
|
||||||
|
_8D(X),
|
||||||
|
_8E(X),
|
||||||
|
_8F(X),
|
||||||
|
_90(X),
|
||||||
|
_91(X),
|
||||||
|
_92(X),
|
||||||
|
_93(X),
|
||||||
|
_94(X),
|
||||||
|
_95(X),
|
||||||
|
_96(X),
|
||||||
|
_97(X),
|
||||||
|
_98(X),
|
||||||
|
_99(X),
|
||||||
|
_9A(X),
|
||||||
|
_9B(X),
|
||||||
|
_9C(X),
|
||||||
|
_9D(X),
|
||||||
|
_9E(X),
|
||||||
|
_9F(X),
|
||||||
|
_A0(X),
|
||||||
|
_A1(X),
|
||||||
|
_A2(X),
|
||||||
|
_A3(X),
|
||||||
|
_A4(X),
|
||||||
|
_A5(X),
|
||||||
|
_A6(X),
|
||||||
|
_A7(X),
|
||||||
|
_A8(X),
|
||||||
|
_A9(X),
|
||||||
|
_AA(X),
|
||||||
|
_AB(X),
|
||||||
|
_AC(X),
|
||||||
|
_AD(X),
|
||||||
|
_AE(X),
|
||||||
|
_AF(X),
|
||||||
|
_B0(X),
|
||||||
|
_B1(X),
|
||||||
|
_B2(X),
|
||||||
|
_B3(X),
|
||||||
|
_B4(X),
|
||||||
|
_B5(X),
|
||||||
|
_B6(X),
|
||||||
|
_B7(X),
|
||||||
|
_B8(X),
|
||||||
|
_B9(X),
|
||||||
|
_BA(X),
|
||||||
|
_BB(X),
|
||||||
|
_BC(X),
|
||||||
|
_BD(X),
|
||||||
|
_BE(X),
|
||||||
|
_BF(X),
|
||||||
|
_C0(X),
|
||||||
|
_C1(X),
|
||||||
|
_C2(X),
|
||||||
|
_C3(X),
|
||||||
|
_C4(X),
|
||||||
|
_C5(X),
|
||||||
|
_C6(X),
|
||||||
|
_C7(X),
|
||||||
|
_C8(X),
|
||||||
|
_C9(X),
|
||||||
|
_CA(X),
|
||||||
|
_CB(X),
|
||||||
|
_CC(X),
|
||||||
|
_CD(X),
|
||||||
|
_CE(X),
|
||||||
|
_CF(X),
|
||||||
|
_D0(X),
|
||||||
|
_D1(X),
|
||||||
|
_D2(X),
|
||||||
|
_D3(X),
|
||||||
|
_D4(X),
|
||||||
|
_D5(X),
|
||||||
|
_D6(X),
|
||||||
|
_D7(X),
|
||||||
|
_D8(X),
|
||||||
|
_D9(X),
|
||||||
|
_DA(X),
|
||||||
|
_DB(X),
|
||||||
|
_DC(X),
|
||||||
|
_DD(X),
|
||||||
|
_DE(X),
|
||||||
|
_DF(X),
|
||||||
|
_E0(X),
|
||||||
|
_E1(X),
|
||||||
|
_E2(X),
|
||||||
|
_E3(X),
|
||||||
|
_E4(X),
|
||||||
|
_E5(X),
|
||||||
|
_E6(X),
|
||||||
|
_E7(X),
|
||||||
|
_E8(X),
|
||||||
|
_E9(X),
|
||||||
|
_EA(X),
|
||||||
|
_EB(X),
|
||||||
|
_EC(X),
|
||||||
|
_ED(X),
|
||||||
|
_EE(X),
|
||||||
|
_EF(X),
|
||||||
|
_F0(X),
|
||||||
|
_F1(X),
|
||||||
|
_F2(X),
|
||||||
|
_F3(X),
|
||||||
|
_F4(X),
|
||||||
|
_F5(X),
|
||||||
|
_F6(X),
|
||||||
|
_F7(X),
|
||||||
|
_F8(X),
|
||||||
|
_F9(X),
|
||||||
|
_FA(X),
|
||||||
|
_FB(X),
|
||||||
|
_FC(X),
|
||||||
|
_FD(X),
|
||||||
|
_FE(X),
|
||||||
|
_FF(X),
|
||||||
|
|
||||||
V3,
|
V3,
|
||||||
V4,
|
V4,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_niche_behavior () {
|
fn check_niche_behavior() {
|
||||||
if let E1::V2 { .. } = (E1::V1 { f: true }) {
|
if let E1::V2 { .. } = (E1::V1 { f: true }) {
|
||||||
intrinsics::abort();
|
intrinsics::abort();
|
||||||
}
|
}
|
||||||
|
@ -58,8 +58,9 @@ fn main() {
|
|||||||
assert_eq!(0b0000000000000000000000000010000000000000000000000000000000000000_0000000000000000000000000000000000001000000000000000000010000000u128.trailing_zeros(), 7);
|
assert_eq!(0b0000000000000000000000000010000000000000000000000000000000000000_0000000000000000000000000000000000001000000000000000000010000000u128.trailing_zeros(), 7);
|
||||||
assert_eq!(core::intrinsics::saturating_sub(0, -170141183460469231731687303715884105728i128), 170141183460469231731687303715884105727i128);
|
assert_eq!(core::intrinsics::saturating_sub(0, -170141183460469231731687303715884105728i128), 170141183460469231731687303715884105727i128);
|
||||||
|
|
||||||
let _d = 0i128.checked_div(2i128);
|
std::hint::black_box(std::hint::black_box(7571400400375753350092698930310845914i128) * 10);
|
||||||
let _d = 0u128.checked_div(2u128);
|
assert!(0i128.checked_div(2i128).is_some());
|
||||||
|
assert!(0u128.checked_div(2u128).is_some());
|
||||||
assert_eq!(1u128 + 2, 3);
|
assert_eq!(1u128 + 2, 3);
|
||||||
|
|
||||||
assert_eq!(0b100010000000000000000000000000000u128 >> 10, 0b10001000000000000000000u128);
|
assert_eq!(0b100010000000000000000000000000000u128 >> 10, 0b10001000000000000000000u128);
|
||||||
|
@ -19,8 +19,8 @@ index 217899e..9cedeb7 100644
|
|||||||
+ // This is broken on x86_64-pc-windows-gnu presumably due to a broken powf implementation
|
+ // This is broken on x86_64-pc-windows-gnu presumably due to a broken powf implementation
|
||||||
+ #[cfg_attr(all(target_os = "windows", target_env = "gnu"), ignore)]
|
+ #[cfg_attr(all(target_os = "windows", target_env = "gnu"), ignore)]
|
||||||
fn value_stability() {
|
fn value_stability() {
|
||||||
fn test_samples<F: Float + core::fmt::Debug, D: Distribution<F>>(
|
fn test_samples<F: Float + Debug + Display + LowerExp, D: Distribution<F>>(
|
||||||
distr: D, zero: F, expected: &[F],
|
distr: D, thresh: F, expected: &[F],
|
||||||
diff --git a/rand_distr/tests/value_stability.rs b/rand_distr/tests/value_stability.rs
|
diff --git a/rand_distr/tests/value_stability.rs b/rand_distr/tests/value_stability.rs
|
||||||
index 192ba74..0101ace 100644
|
index 192ba74..0101ace 100644
|
||||||
--- a/rand_distr/tests/value_stability.rs
|
--- a/rand_distr/tests/value_stability.rs
|
||||||
|
@ -13,14 +13,14 @@ Subject: [PATCH] [core] Disable not compiling tests
|
|||||||
6 files changed, 16 insertions(+), 1 deletion(-)
|
6 files changed, 16 insertions(+), 1 deletion(-)
|
||||||
create mode 100644 library/core/tests/Cargo.toml
|
create mode 100644 library/core/tests/Cargo.toml
|
||||||
|
|
||||||
diff --git a/library/core/tests/Cargo.toml b/library/core/tests/Cargo.toml
|
diff --git a/Cargo.toml b/Cargo.toml
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..46fd999
|
index 0000000..46fd999
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/library/core/tests/Cargo.toml
|
+++ b/Cargo.toml
|
||||||
@@ -0,0 +1,12 @@
|
@@ -0,0 +1,12 @@
|
||||||
+[package]
|
+[package]
|
||||||
+name = "core"
|
+name = "coretests"
|
||||||
+version = "0.0.0"
|
+version = "0.0.0"
|
||||||
+edition = "2021"
|
+edition = "2021"
|
||||||
+
|
+
|
||||||
@ -31,5 +31,14 @@ index 0000000..46fd999
|
|||||||
+[dependencies]
|
+[dependencies]
|
||||||
+rand = { version = "0.8.5", default-features = false }
|
+rand = { version = "0.8.5", default-features = false }
|
||||||
+rand_xorshift = { version = "0.3.0", default-features = false }
|
+rand_xorshift = { version = "0.3.0", default-features = false }
|
||||||
|
diff --git a/lib.rs b/lib.rs
|
||||||
|
index 42a26ae..5ac1042 100644
|
||||||
|
--- a/lib.rs
|
||||||
|
+++ b/lib.rs
|
||||||
|
@@ -1,3 +1,4 @@
|
||||||
|
+#![cfg(test)]
|
||||||
|
#![feature(alloc_layout_extra)]
|
||||||
|
#![feature(array_chunks)]
|
||||||
|
#![feature(array_methods)]
|
||||||
--
|
--
|
||||||
2.21.0 (Apple Git-122)
|
2.21.0 (Apple Git-122)
|
@ -10,10 +10,10 @@ Subject: [PATCH] [core] Ignore failing tests
|
|||||||
library/core/tests/time.rs | 1 +
|
library/core/tests/time.rs | 1 +
|
||||||
4 files changed, 18 insertions(+), 2 deletions(-)
|
4 files changed, 18 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
diff --git a/library/core/tests/array.rs b/library/core/tests/array.rs
|
diff --git a/array.rs b/array.rs
|
||||||
index 4bc44e9..8e3c7a4 100644
|
index 4bc44e9..8e3c7a4 100644
|
||||||
--- a/library/core/tests/array.rs
|
--- a/array.rs
|
||||||
+++ b/library/core/tests/array.rs
|
+++ b/array.rs
|
||||||
@@ -242,6 +242,7 @@ fn iterator_drops() {
|
@@ -242,6 +242,7 @@ fn iterator_drops() {
|
||||||
assert_eq!(i.get(), 5);
|
assert_eq!(i.get(), 5);
|
||||||
}
|
}
|
||||||
@ -46,10 +46,10 @@ index 4bc44e9..8e3c7a4 100644
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cell_allows_array_cycle() {
|
fn cell_allows_array_cycle() {
|
||||||
diff --git a/library/core/tests/atomic.rs b/library/core/tests/atomic.rs
|
diff --git a/atomic.rs b/atomic.rs
|
||||||
index 13b12db..96fe4b9 100644
|
index 13b12db..96fe4b9 100644
|
||||||
--- a/library/core/tests/atomic.rs
|
--- a/atomic.rs
|
||||||
+++ b/library/core/tests/atomic.rs
|
+++ b/atomic.rs
|
||||||
@@ -185,6 +185,7 @@ fn ptr_bitops() {
|
@@ -185,6 +185,7 @@ fn ptr_bitops() {
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
|||||||
|
From ad7ffe71baba46865f2e65266ab025920dfdc20b Mon Sep 17 00:00:00 2001
|
||||||
|
From: bjorn3 <bjorn3@users.noreply.github.com>
|
||||||
|
Date: Thu, 18 Feb 2021 18:45:28 +0100
|
||||||
|
Subject: [PATCH] Disable 128bit atomic operations
|
||||||
|
|
||||||
|
Cranelift doesn't support them yet
|
||||||
|
---
|
||||||
|
library/core/src/panic/unwind_safe.rs | 6 -----
|
||||||
|
library/core/src/sync/atomic.rs | 38 ---------------------------
|
||||||
|
library/core/tests/atomic.rs | 4 ---
|
||||||
|
4 files changed, 4 insertions(+), 50 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/atomic.rs b/atomic.rs
|
||||||
|
index b735957..ea728b6 100644
|
||||||
|
--- a/atomic.rs
|
||||||
|
+++ b/atomic.rs
|
||||||
|
@@ -185,10 +185,6 @@ fn atomic_alignment() {
|
||||||
|
assert_eq!(align_of::<AtomicU64>(), size_of::<AtomicU64>());
|
||||||
|
#[cfg(target_has_atomic = "64")]
|
||||||
|
assert_eq!(align_of::<AtomicI64>(), size_of::<AtomicI64>());
|
||||||
|
- #[cfg(target_has_atomic = "128")]
|
||||||
|
- assert_eq!(align_of::<AtomicU128>(), size_of::<AtomicU128>());
|
||||||
|
- #[cfg(target_has_atomic = "128")]
|
||||||
|
- assert_eq!(align_of::<AtomicI128>(), size_of::<AtomicI128>());
|
||||||
|
#[cfg(target_has_atomic = "ptr")]
|
||||||
|
assert_eq!(align_of::<AtomicUsize>(), size_of::<AtomicUsize>());
|
||||||
|
#[cfg(target_has_atomic = "ptr")]
|
||||||
|
--
|
||||||
|
2.26.2.7.g19db9cfb68
|
||||||
|
|
@ -85,21 +85,6 @@ index d9de37e..8293fce 100644
|
|||||||
|
|
||||||
macro_rules! atomic_int_ptr_sized {
|
macro_rules! atomic_int_ptr_sized {
|
||||||
( $($target_pointer_width:literal $align:literal)* ) => { $(
|
( $($target_pointer_width:literal $align:literal)* ) => { $(
|
||||||
diff --git a/library/core/tests/atomic.rs b/library/core/tests/atomic.rs
|
|
||||||
index b735957..ea728b6 100644
|
|
||||||
--- a/library/core/tests/atomic.rs
|
|
||||||
+++ b/library/core/tests/atomic.rs
|
|
||||||
@@ -185,10 +185,6 @@ fn atomic_alignment() {
|
|
||||||
assert_eq!(align_of::<AtomicU64>(), size_of::<AtomicU64>());
|
|
||||||
#[cfg(target_has_atomic = "64")]
|
|
||||||
assert_eq!(align_of::<AtomicI64>(), size_of::<AtomicI64>());
|
|
||||||
- #[cfg(target_has_atomic = "128")]
|
|
||||||
- assert_eq!(align_of::<AtomicU128>(), size_of::<AtomicU128>());
|
|
||||||
- #[cfg(target_has_atomic = "128")]
|
|
||||||
- assert_eq!(align_of::<AtomicI128>(), size_of::<AtomicI128>());
|
|
||||||
#[cfg(target_has_atomic = "ptr")]
|
|
||||||
assert_eq!(align_of::<AtomicUsize>(), size_of::<AtomicUsize>());
|
|
||||||
#[cfg(target_has_atomic = "ptr")]
|
|
||||||
--
|
--
|
||||||
2.26.2.7.g19db9cfb68
|
2.26.2.7.g19db9cfb68
|
||||||
|
|
@ -7,10 +7,10 @@ Subject: [PATCH] Disable long running tests
|
|||||||
library/core/tests/slice.rs | 2 ++
|
library/core/tests/slice.rs | 2 ++
|
||||||
1 file changed, 2 insertions(+)
|
1 file changed, 2 insertions(+)
|
||||||
|
|
||||||
diff --git a/library/core/tests/slice.rs b/library/core/tests/slice.rs
|
diff --git a/slice.rs b/slice.rs
|
||||||
index 8402833..84592e0 100644
|
index 8402833..84592e0 100644
|
||||||
--- a/library/core/tests/slice.rs
|
--- a/slice.rs
|
||||||
+++ b/library/core/tests/slice.rs
|
+++ b/slice.rs
|
||||||
@@ -1809,6 +1809,7 @@ fn sort_unstable() {
|
@@ -1809,6 +1809,7 @@ fn sort_unstable() {
|
||||||
assert!(v == [0xDEADBEEF]);
|
assert!(v == [0xDEADBEEF]);
|
||||||
}
|
}
|
@ -1,3 +1,3 @@
|
|||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "nightly-2023-02-06"
|
channel = "nightly-2023-03-15"
|
||||||
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
|
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
use std::env;
|
use std::env;
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use std::os::unix::process::CommandExt;
|
use std::os::unix::process::CommandExt;
|
||||||
use std::path::PathBuf;
|
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let sysroot = PathBuf::from(env::current_exe().unwrap().parent().unwrap());
|
let current_exe = env::current_exe().unwrap();
|
||||||
|
let mut sysroot = current_exe.parent().unwrap();
|
||||||
|
if sysroot.file_name().unwrap().to_str().unwrap() == "bin" {
|
||||||
|
sysroot = sysroot.parent().unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
let mut rustflags = String::new();
|
let mut rustflags = String::new();
|
||||||
rustflags.push_str(" -Cpanic=abort -Zpanic-abort-tests -Zcodegen-backend=");
|
rustflags.push_str(" -Cpanic=abort -Zpanic-abort-tests -Zcodegen-backend=");
|
||||||
|
@ -2,11 +2,14 @@ use std::env;
|
|||||||
use std::ffi::OsString;
|
use std::ffi::OsString;
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use std::os::unix::process::CommandExt;
|
use std::os::unix::process::CommandExt;
|
||||||
use std::path::PathBuf;
|
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let sysroot = PathBuf::from(env::current_exe().unwrap().parent().unwrap());
|
let current_exe = env::current_exe().unwrap();
|
||||||
|
let mut sysroot = current_exe.parent().unwrap();
|
||||||
|
if sysroot.file_name().unwrap().to_str().unwrap() == "bin" {
|
||||||
|
sysroot = sysroot.parent().unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
let cg_clif_dylib_path = sysroot.join(if cfg!(windows) { "bin" } else { "lib" }).join(
|
let cg_clif_dylib_path = sysroot.join(if cfg!(windows) { "bin" } else { "lib" }).join(
|
||||||
env::consts::DLL_PREFIX.to_string() + "rustc_codegen_cranelift" + env::consts::DLL_SUFFIX,
|
env::consts::DLL_PREFIX.to_string() + "rustc_codegen_cranelift" + env::consts::DLL_SUFFIX,
|
||||||
|
@ -2,11 +2,14 @@ use std::env;
|
|||||||
use std::ffi::OsString;
|
use std::ffi::OsString;
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use std::os::unix::process::CommandExt;
|
use std::os::unix::process::CommandExt;
|
||||||
use std::path::PathBuf;
|
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let sysroot = PathBuf::from(env::current_exe().unwrap().parent().unwrap());
|
let current_exe = env::current_exe().unwrap();
|
||||||
|
let mut sysroot = current_exe.parent().unwrap();
|
||||||
|
if sysroot.file_name().unwrap().to_str().unwrap() == "bin" {
|
||||||
|
sysroot = sysroot.parent().unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
let cg_clif_dylib_path = sysroot.join(if cfg!(windows) { "bin" } else { "lib" }).join(
|
let cg_clif_dylib_path = sysroot.join(if cfg!(windows) { "bin" } else { "lib" }).join(
|
||||||
env::consts::DLL_PREFIX.to_string() + "rustc_codegen_cranelift" + env::consts::DLL_SUFFIX,
|
env::consts::DLL_PREFIX.to_string() + "rustc_codegen_cranelift" + env::consts::DLL_SUFFIX,
|
||||||
|
@ -2,10 +2,24 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
TOOLCHAIN=${TOOLCHAIN:-$(date +%Y-%m-%d)}
|
||||||
|
|
||||||
|
function check_git_fixed_subtree() {
|
||||||
|
if [[ ! -e ./git-fixed-subtree.sh ]]; then
|
||||||
|
echo "Missing git-fixed-subtree.sh. Please run the following commands to download it:"
|
||||||
|
echo "curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/bjorn3/git/tqc-subtree-portable/contrib/subtree/git-subtree.sh -o git-fixed-subtree.sh"
|
||||||
|
echo "chmod u+x git-fixed-subtree.sh"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ ! -x ./git-fixed-subtree.sh ]]; then
|
||||||
|
echo "git-fixed-subtree.sh is not executable. Please run the following command to make it executable:"
|
||||||
|
echo "chmod u+x git-fixed-subtree.sh"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
"prepare")
|
"prepare")
|
||||||
TOOLCHAIN=$(date +%Y-%m-%d)
|
|
||||||
|
|
||||||
echo "=> Installing new nightly"
|
echo "=> Installing new nightly"
|
||||||
rustup toolchain install --profile minimal "nightly-${TOOLCHAIN}" # Sanity check to see if the nightly exists
|
rustup toolchain install --profile minimal "nightly-${TOOLCHAIN}" # Sanity check to see if the nightly exists
|
||||||
sed -i "s/\"nightly-.*\"/\"nightly-${TOOLCHAIN}\"/" rust-toolchain
|
sed -i "s/\"nightly-.*\"/\"nightly-${TOOLCHAIN}\"/" rust-toolchain
|
||||||
@ -27,28 +41,35 @@ case $1 in
|
|||||||
git commit -m "Rustup to $(rustc -V)"
|
git commit -m "Rustup to $(rustc -V)"
|
||||||
;;
|
;;
|
||||||
"push")
|
"push")
|
||||||
|
check_git_fixed_subtree
|
||||||
|
|
||||||
cg_clif=$(pwd)
|
cg_clif=$(pwd)
|
||||||
pushd ../rust
|
pushd ../rust
|
||||||
git pull origin master
|
git pull origin master
|
||||||
branch=sync_cg_clif-$(date +%Y-%m-%d)
|
branch=sync_cg_clif-$(date +%Y-%m-%d)
|
||||||
git checkout -b "$branch"
|
git checkout -b "$branch"
|
||||||
git subtree pull --prefix=compiler/rustc_codegen_cranelift/ https://github.com/bjorn3/rustc_codegen_cranelift.git master
|
"$cg_clif/git-fixed-subtree.sh" pull --prefix=compiler/rustc_codegen_cranelift/ https://github.com/bjorn3/rustc_codegen_cranelift.git master
|
||||||
git push -u my "$branch"
|
git push -u my "$branch"
|
||||||
|
|
||||||
# immediately merge the merge commit into cg_clif to prevent merge conflicts when syncing
|
# immediately merge the merge commit into cg_clif to prevent merge conflicts when syncing
|
||||||
# from rust-lang/rust later
|
# from rust-lang/rust later
|
||||||
git subtree push --prefix=compiler/rustc_codegen_cranelift/ "$cg_clif" sync_from_rust
|
"$cg_clif/git-fixed-subtree.sh" push --prefix=compiler/rustc_codegen_cranelift/ "$cg_clif" sync_from_rust
|
||||||
popd
|
popd
|
||||||
git merge sync_from_rust
|
git merge sync_from_rust
|
||||||
;;
|
;;
|
||||||
"pull")
|
"pull")
|
||||||
|
check_git_fixed_subtree
|
||||||
|
|
||||||
|
RUST_VERS=$(curl "https://static.rust-lang.org/dist/$TOOLCHAIN/channel-rust-nightly-git-commit-hash.txt")
|
||||||
|
echo "Pulling $RUST_VERS ($TOOLCHAIN)"
|
||||||
|
|
||||||
cg_clif=$(pwd)
|
cg_clif=$(pwd)
|
||||||
pushd ../rust
|
pushd ../rust
|
||||||
git pull origin master
|
git fetch origin master
|
||||||
rust_vers="$(git rev-parse HEAD)"
|
git checkout "$RUST_VERS"
|
||||||
git subtree push --prefix=compiler/rustc_codegen_cranelift/ "$cg_clif" sync_from_rust
|
"$cg_clif/git-fixed-subtree.sh" push --prefix=compiler/rustc_codegen_cranelift/ "$cg_clif" sync_from_rust
|
||||||
popd
|
popd
|
||||||
git merge sync_from_rust -m "Sync from rust $rust_vers"
|
git merge sync_from_rust -m "Sync from rust $RUST_VERS"
|
||||||
git branch -d sync_from_rust
|
git branch -d sync_from_rust
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
@ -10,7 +10,7 @@ git fetch
|
|||||||
git checkout -- .
|
git checkout -- .
|
||||||
git checkout "$(rustc -V | cut -d' ' -f3 | tr -d '(')"
|
git checkout "$(rustc -V | cut -d' ' -f3 | tr -d '(')"
|
||||||
|
|
||||||
git -c user.name=Dummy -c user.email=dummy@example.com am ../patches/*-sysroot-*.patch
|
git -c user.name=Dummy -c user.email=dummy@example.com am ../patches/*-stdlib-*.patch
|
||||||
|
|
||||||
git apply - <<EOF
|
git apply - <<EOF
|
||||||
diff --git a/library/alloc/Cargo.toml b/library/alloc/Cargo.toml
|
diff --git a/library/alloc/Cargo.toml b/library/alloc/Cargo.toml
|
||||||
@ -36,7 +36,7 @@ changelog-seen = 2
|
|||||||
ninja = false
|
ninja = false
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
rustc = "$(pwd)/../dist/rustc-clif"
|
rustc = "$(pwd)/../dist/bin/rustc-clif"
|
||||||
cargo = "$(rustup which cargo)"
|
cargo = "$(rustup which cargo)"
|
||||||
full-bootstrap = true
|
full-bootstrap = true
|
||||||
local-rebuild = true
|
local-rebuild = true
|
||||||
|
@ -21,6 +21,7 @@ done
|
|||||||
|
|
||||||
git checkout -- tests/ui/issues/auxiliary/issue-3136-a.rs # contains //~ERROR, but shouldn't be removed
|
git checkout -- tests/ui/issues/auxiliary/issue-3136-a.rs # contains //~ERROR, but shouldn't be removed
|
||||||
git checkout -- tests/ui/proc-macro/pretty-print-hack/
|
git checkout -- tests/ui/proc-macro/pretty-print-hack/
|
||||||
|
rm tests/ui/parser/unclosed-delimiter-in-dep.rs # submodule contains //~ERROR
|
||||||
|
|
||||||
# missing features
|
# missing features
|
||||||
# ================
|
# ================
|
||||||
@ -80,6 +81,7 @@ rm tests/ui/layout/valid_range_oob.rs # different ICE message
|
|||||||
|
|
||||||
rm tests/ui/consts/issue-miri-1910.rs # different error message
|
rm tests/ui/consts/issue-miri-1910.rs # different error message
|
||||||
rm tests/ui/consts/offset_ub.rs # same
|
rm tests/ui/consts/offset_ub.rs # same
|
||||||
|
rm tests/ui/consts/const-eval/ub-slice-get-unchecked.rs # same
|
||||||
rm tests/ui/intrinsics/panic-uninitialized-zeroed.rs # same
|
rm tests/ui/intrinsics/panic-uninitialized-zeroed.rs # same
|
||||||
rm tests/ui/lint/lint-const-item-mutation.rs # same
|
rm tests/ui/lint/lint-const-item-mutation.rs # same
|
||||||
rm tests/ui/pattern/usefulness/doc-hidden-non-exhaustive.rs # same
|
rm tests/ui/pattern/usefulness/doc-hidden-non-exhaustive.rs # same
|
||||||
@ -110,12 +112,9 @@ rm tests/incremental/spike-neg2.rs # same
|
|||||||
|
|
||||||
rm tests/ui/simd/intrinsic/generic-reduction-pass.rs # simd_reduce_add_unordered doesn't accept an accumulator for integer vectors
|
rm tests/ui/simd/intrinsic/generic-reduction-pass.rs # simd_reduce_add_unordered doesn't accept an accumulator for integer vectors
|
||||||
|
|
||||||
rm tests/ui/simd/intrinsic/generic-as.rs # crash when accessing vector type filed (#1318)
|
rm tests/ui/simd/intrinsic/generic-as.rs # crash when accessing vector type field (#1318)
|
||||||
rm tests/ui/simd/simd-bitmask.rs # crash
|
rm tests/ui/simd/simd-bitmask.rs # crash
|
||||||
|
|
||||||
rm tests/ui/dyn-star/dyn-star-to-dyn.rs
|
|
||||||
rm tests/ui/dyn-star/dispatch-on-pin-mut.rs
|
|
||||||
|
|
||||||
# bugs in the test suite
|
# bugs in the test suite
|
||||||
# ======================
|
# ======================
|
||||||
rm tests/ui/backtrace.rs # TODO warning
|
rm tests/ui/backtrace.rs # TODO warning
|
||||||
|
@ -4,6 +4,8 @@ mod comments;
|
|||||||
mod pass_mode;
|
mod pass_mode;
|
||||||
mod returning;
|
mod returning;
|
||||||
|
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use cranelift_module::ModuleError;
|
use cranelift_module::ModuleError;
|
||||||
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
|
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
|
||||||
use rustc_middle::ty::layout::FnAbiOf;
|
use rustc_middle::ty::layout::FnAbiOf;
|
||||||
@ -25,7 +27,7 @@ fn clif_sig_from_fn_abi<'tcx>(
|
|||||||
) -> Signature {
|
) -> Signature {
|
||||||
let call_conv = conv_to_call_conv(tcx.sess, fn_abi.conv, default_call_conv);
|
let call_conv = conv_to_call_conv(tcx.sess, fn_abi.conv, default_call_conv);
|
||||||
|
|
||||||
let inputs = fn_abi.args.iter().map(|arg_abi| arg_abi.get_abi_param(tcx).into_iter()).flatten();
|
let inputs = fn_abi.args.iter().flat_map(|arg_abi| arg_abi.get_abi_param(tcx).into_iter());
|
||||||
|
|
||||||
let (return_ptr, returns) = fn_abi.ret.get_abi_return(tcx);
|
let (return_ptr, returns) = fn_abi.ret.get_abi_return(tcx);
|
||||||
// Sometimes the first param is an pointer to the place where the return value needs to be stored.
|
// Sometimes the first param is an pointer to the place where the return value needs to be stored.
|
||||||
@ -116,7 +118,52 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
|
|||||||
params: Vec<AbiParam>,
|
params: Vec<AbiParam>,
|
||||||
returns: Vec<AbiParam>,
|
returns: Vec<AbiParam>,
|
||||||
args: &[Value],
|
args: &[Value],
|
||||||
) -> &[Value] {
|
) -> Cow<'_, [Value]> {
|
||||||
|
if self.tcx.sess.target.is_like_windows {
|
||||||
|
let (mut params, mut args): (Vec<_>, Vec<_>) =
|
||||||
|
params
|
||||||
|
.into_iter()
|
||||||
|
.zip(args)
|
||||||
|
.map(|(param, &arg)| {
|
||||||
|
if param.value_type == types::I128 {
|
||||||
|
let arg_ptr = Pointer::stack_slot(self.bcx.create_sized_stack_slot(
|
||||||
|
StackSlotData { kind: StackSlotKind::ExplicitSlot, size: 16 },
|
||||||
|
));
|
||||||
|
arg_ptr.store(self, arg, MemFlags::trusted());
|
||||||
|
(AbiParam::new(self.pointer_type), arg_ptr.get_addr(self))
|
||||||
|
} else {
|
||||||
|
(param, arg)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.unzip();
|
||||||
|
|
||||||
|
let indirect_ret_val = returns.len() == 1 && returns[0].value_type == types::I128;
|
||||||
|
|
||||||
|
if indirect_ret_val {
|
||||||
|
params.insert(0, AbiParam::new(self.pointer_type));
|
||||||
|
let ret_ptr =
|
||||||
|
Pointer::stack_slot(self.bcx.create_sized_stack_slot(StackSlotData {
|
||||||
|
kind: StackSlotKind::ExplicitSlot,
|
||||||
|
size: 16,
|
||||||
|
}));
|
||||||
|
args.insert(0, ret_ptr.get_addr(self));
|
||||||
|
self.lib_call_unadjusted(name, params, vec![], &args);
|
||||||
|
return Cow::Owned(vec![ret_ptr.load(self, types::I128, MemFlags::trusted())]);
|
||||||
|
} else {
|
||||||
|
return self.lib_call_unadjusted(name, params, returns, &args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self.lib_call_unadjusted(name, params, returns, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn lib_call_unadjusted(
|
||||||
|
&mut self,
|
||||||
|
name: &str,
|
||||||
|
params: Vec<AbiParam>,
|
||||||
|
returns: Vec<AbiParam>,
|
||||||
|
args: &[Value],
|
||||||
|
) -> Cow<'_, [Value]> {
|
||||||
let sig = Signature { params, returns, call_conv: self.target_config.default_call_conv };
|
let sig = Signature { params, returns, call_conv: self.target_config.default_call_conv };
|
||||||
let func_id = self.module.declare_function(name, Linkage::Import, &sig).unwrap();
|
let func_id = self.module.declare_function(name, Linkage::Import, &sig).unwrap();
|
||||||
let func_ref = self.module.declare_func_in_func(func_id, &mut self.bcx.func);
|
let func_ref = self.module.declare_func_in_func(func_id, &mut self.bcx.func);
|
||||||
@ -125,41 +172,11 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
|
|||||||
}
|
}
|
||||||
let call_inst = self.bcx.ins().call(func_ref, args);
|
let call_inst = self.bcx.ins().call(func_ref, args);
|
||||||
if self.clif_comments.enabled() {
|
if self.clif_comments.enabled() {
|
||||||
self.add_comment(call_inst, format!("easy_call {}", name));
|
self.add_comment(call_inst, format!("lib_call {}", name));
|
||||||
}
|
}
|
||||||
let results = self.bcx.inst_results(call_inst);
|
let results = self.bcx.inst_results(call_inst);
|
||||||
assert!(results.len() <= 2, "{}", results.len());
|
assert!(results.len() <= 2, "{}", results.len());
|
||||||
results
|
Cow::Borrowed(results)
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn easy_call(
|
|
||||||
&mut self,
|
|
||||||
name: &str,
|
|
||||||
args: &[CValue<'tcx>],
|
|
||||||
return_ty: Ty<'tcx>,
|
|
||||||
) -> CValue<'tcx> {
|
|
||||||
let (input_tys, args): (Vec<_>, Vec<_>) = args
|
|
||||||
.iter()
|
|
||||||
.map(|arg| {
|
|
||||||
(AbiParam::new(self.clif_type(arg.layout().ty).unwrap()), arg.load_scalar(self))
|
|
||||||
})
|
|
||||||
.unzip();
|
|
||||||
let return_layout = self.layout_of(return_ty);
|
|
||||||
let return_tys = if let ty::Tuple(tup) = return_ty.kind() {
|
|
||||||
tup.iter().map(|ty| AbiParam::new(self.clif_type(ty).unwrap())).collect()
|
|
||||||
} else {
|
|
||||||
vec![AbiParam::new(self.clif_type(return_ty).unwrap())]
|
|
||||||
};
|
|
||||||
let ret_vals = self.lib_call(name, input_tys, return_tys, &args);
|
|
||||||
match *ret_vals {
|
|
||||||
[] => CValue::by_ref(
|
|
||||||
Pointer::const_addr(self, i64::from(self.pointer_type.bytes())),
|
|
||||||
return_layout,
|
|
||||||
),
|
|
||||||
[val] => CValue::by_val(val, return_layout),
|
|
||||||
[val, extra] => CValue::by_val_pair(val, extra, return_layout),
|
|
||||||
_ => unreachable!(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,10 +292,6 @@ pub(crate) fn codegen_fn_prelude<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, start_
|
|||||||
self::comments::add_locals_header_comment(fx);
|
self::comments::add_locals_header_comment(fx);
|
||||||
|
|
||||||
for (local, arg_kind, ty) in func_params {
|
for (local, arg_kind, ty) in func_params {
|
||||||
let layout = fx.layout_of(ty);
|
|
||||||
|
|
||||||
let is_ssa = ssa_analyzed[local] == crate::analyze::SsaKind::Ssa;
|
|
||||||
|
|
||||||
// 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.
|
||||||
if let ArgKind::Normal(Some(val)) = arg_kind {
|
if let ArgKind::Normal(Some(val)) = arg_kind {
|
||||||
@ -300,6 +313,8 @@ pub(crate) fn codegen_fn_prelude<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, start_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let layout = fx.layout_of(ty);
|
||||||
|
let is_ssa = ssa_analyzed[local].is_ssa(fx, ty);
|
||||||
let place = make_local_place(fx, local, layout, is_ssa);
|
let place = make_local_place(fx, local, layout, is_ssa);
|
||||||
assert_eq!(fx.local_map.push(place), local);
|
assert_eq!(fx.local_map.push(place), local);
|
||||||
|
|
||||||
@ -323,7 +338,7 @@ pub(crate) fn codegen_fn_prelude<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, start_
|
|||||||
let ty = fx.monomorphize(fx.mir.local_decls[local].ty);
|
let ty = fx.monomorphize(fx.mir.local_decls[local].ty);
|
||||||
let layout = fx.layout_of(ty);
|
let layout = fx.layout_of(ty);
|
||||||
|
|
||||||
let is_ssa = ssa_analyzed[local] == crate::analyze::SsaKind::Ssa;
|
let is_ssa = ssa_analyzed[local].is_ssa(fx, ty);
|
||||||
|
|
||||||
let place = make_local_place(fx, local, layout, is_ssa);
|
let place = make_local_place(fx, local, layout, is_ssa);
|
||||||
assert_eq!(fx.local_map.push(place), local);
|
assert_eq!(fx.local_map.push(place), local);
|
||||||
@ -515,10 +530,9 @@ pub(crate) fn codegen_terminator_call<'tcx>(
|
|||||||
args.into_iter()
|
args.into_iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.skip(if first_arg_override.is_some() { 1 } else { 0 })
|
.skip(if first_arg_override.is_some() { 1 } else { 0 })
|
||||||
.map(|(i, arg)| {
|
.flat_map(|(i, arg)| {
|
||||||
adjust_arg_for_abi(fx, arg.value, &fn_abi.args[i], arg.is_owned).into_iter()
|
adjust_arg_for_abi(fx, arg.value, &fn_abi.args[i], arg.is_owned).into_iter()
|
||||||
})
|
}),
|
||||||
.flatten(),
|
|
||||||
)
|
)
|
||||||
.collect::<Vec<Value>>();
|
.collect::<Vec<Value>>();
|
||||||
|
|
||||||
|
@ -14,7 +14,8 @@ pub(super) fn codegen_return_param<'tcx>(
|
|||||||
) -> CPlace<'tcx> {
|
) -> CPlace<'tcx> {
|
||||||
let (ret_place, ret_param): (_, SmallVec<[_; 2]>) = match fx.fn_abi.as_ref().unwrap().ret.mode {
|
let (ret_place, ret_param): (_, SmallVec<[_; 2]>) = match fx.fn_abi.as_ref().unwrap().ret.mode {
|
||||||
PassMode::Ignore | PassMode::Direct(_) | PassMode::Pair(_, _) | PassMode::Cast(..) => {
|
PassMode::Ignore | PassMode::Direct(_) | PassMode::Pair(_, _) | PassMode::Cast(..) => {
|
||||||
let is_ssa = ssa_analyzed[RETURN_PLACE] == crate::analyze::SsaKind::Ssa;
|
let is_ssa =
|
||||||
|
ssa_analyzed[RETURN_PLACE].is_ssa(fx, fx.fn_abi.as_ref().unwrap().ret.layout.ty);
|
||||||
(
|
(
|
||||||
super::make_local_place(
|
super::make_local_place(
|
||||||
fx,
|
fx,
|
||||||
|
@ -4,34 +4,30 @@ use crate::prelude::*;
|
|||||||
|
|
||||||
use rustc_index::vec::IndexVec;
|
use rustc_index::vec::IndexVec;
|
||||||
use rustc_middle::mir::StatementKind::*;
|
use rustc_middle::mir::StatementKind::*;
|
||||||
|
use rustc_middle::ty::Ty;
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
pub(crate) enum SsaKind {
|
pub(crate) enum SsaKind {
|
||||||
NotSsa,
|
NotSsa,
|
||||||
Ssa,
|
MaybeSsa,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SsaKind {
|
||||||
|
pub(crate) fn is_ssa<'tcx>(self, fx: &FunctionCx<'_, '_, 'tcx>, ty: Ty<'tcx>) -> bool {
|
||||||
|
self == SsaKind::MaybeSsa && (fx.clif_type(ty).is_some() || fx.clif_pair_type(ty).is_some())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn analyze(fx: &FunctionCx<'_, '_, '_>) -> IndexVec<Local, SsaKind> {
|
pub(crate) fn analyze(fx: &FunctionCx<'_, '_, '_>) -> IndexVec<Local, SsaKind> {
|
||||||
let mut flag_map = fx
|
let mut flag_map =
|
||||||
.mir
|
fx.mir.local_decls.iter().map(|_| SsaKind::MaybeSsa).collect::<IndexVec<Local, SsaKind>>();
|
||||||
.local_decls
|
|
||||||
.iter()
|
|
||||||
.map(|local_decl| {
|
|
||||||
let ty = fx.monomorphize(local_decl.ty);
|
|
||||||
if fx.clif_type(ty).is_some() || fx.clif_pair_type(ty).is_some() {
|
|
||||||
SsaKind::Ssa
|
|
||||||
} else {
|
|
||||||
SsaKind::NotSsa
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect::<IndexVec<Local, SsaKind>>();
|
|
||||||
|
|
||||||
for bb in fx.mir.basic_blocks.iter() {
|
for bb in fx.mir.basic_blocks.iter() {
|
||||||
for stmt in bb.statements.iter() {
|
for stmt in bb.statements.iter() {
|
||||||
match &stmt.kind {
|
match &stmt.kind {
|
||||||
Assign(place_and_rval) => match &place_and_rval.1 {
|
Assign(place_and_rval) => match &place_and_rval.1 {
|
||||||
Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => {
|
Rvalue::Ref(_, _, place) | Rvalue::AddressOf(_, place) => {
|
||||||
not_ssa(&mut flag_map, place.local)
|
flag_map[place.local] = SsaKind::NotSsa;
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
@ -42,7 +38,3 @@ pub(crate) fn analyze(fx: &FunctionCx<'_, '_, '_>) -> IndexVec<Local, SsaKind> {
|
|||||||
|
|
||||||
flag_map
|
flag_map
|
||||||
}
|
}
|
||||||
|
|
||||||
fn not_ssa(flag_map: &mut IndexVec<Local, SsaKind>, local: Local) {
|
|
||||||
flag_map[local] = SsaKind::NotSsa;
|
|
||||||
}
|
|
||||||
|
@ -192,7 +192,7 @@ pub(crate) fn compile_fn(
|
|||||||
let pass_times = cranelift_codegen::timing::take_current();
|
let pass_times = cranelift_codegen::timing::take_current();
|
||||||
// Replace newlines with | as measureme doesn't allow control characters like
|
// Replace newlines with | as measureme doesn't allow control characters like
|
||||||
// newlines inside strings.
|
// newlines inside strings.
|
||||||
recorder.record_arg(format!("{}", pass_times).replace("\n", " | "));
|
recorder.record_arg(format!("{}", pass_times).replace('\n', " | "));
|
||||||
recording_args = true;
|
recording_args = true;
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@ -365,11 +365,10 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
|
|||||||
fx.bcx.set_cold_block(failure);
|
fx.bcx.set_cold_block(failure);
|
||||||
|
|
||||||
if *expected {
|
if *expected {
|
||||||
fx.bcx.ins().brz(cond, failure, &[]);
|
fx.bcx.ins().brif(cond, target, &[], failure, &[]);
|
||||||
} else {
|
} else {
|
||||||
fx.bcx.ins().brnz(cond, failure, &[]);
|
fx.bcx.ins().brif(cond, failure, &[], target, &[]);
|
||||||
};
|
};
|
||||||
fx.bcx.ins().jump(target, &[]);
|
|
||||||
|
|
||||||
fx.bcx.switch_to_block(failure);
|
fx.bcx.switch_to_block(failure);
|
||||||
fx.bcx.ins().nop();
|
fx.bcx.ins().nop();
|
||||||
@ -425,11 +424,9 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if test_zero {
|
if test_zero {
|
||||||
fx.bcx.ins().brz(discr, then_block, &[]);
|
fx.bcx.ins().brif(discr, else_block, &[], then_block, &[]);
|
||||||
fx.bcx.ins().jump(else_block, &[]);
|
|
||||||
} else {
|
} else {
|
||||||
fx.bcx.ins().brnz(discr, then_block, &[]);
|
fx.bcx.ins().brif(discr, then_block, &[], else_block, &[]);
|
||||||
fx.bcx.ins().jump(else_block, &[]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -750,8 +747,7 @@ fn codegen_stmt<'tcx>(
|
|||||||
|
|
||||||
fx.bcx.switch_to_block(loop_block);
|
fx.bcx.switch_to_block(loop_block);
|
||||||
let done = fx.bcx.ins().icmp_imm(IntCC::Equal, index, times as i64);
|
let done = fx.bcx.ins().icmp_imm(IntCC::Equal, index, times as i64);
|
||||||
fx.bcx.ins().brnz(done, done_block, &[]);
|
fx.bcx.ins().brif(done, done_block, &[], loop_block2, &[]);
|
||||||
fx.bcx.ins().jump(loop_block2, &[]);
|
|
||||||
|
|
||||||
fx.bcx.switch_to_block(loop_block2);
|
fx.bcx.switch_to_block(loop_block2);
|
||||||
let to = lval.place_index(fx, index);
|
let to = lval.place_index(fx, index);
|
||||||
@ -997,7 +993,7 @@ fn codegen_panic_inner<'tcx>(
|
|||||||
let symbol_name = fx.tcx.symbol_name(instance).name;
|
let symbol_name = fx.tcx.symbol_name(instance).name;
|
||||||
|
|
||||||
fx.lib_call(
|
fx.lib_call(
|
||||||
&*symbol_name,
|
symbol_name,
|
||||||
args.iter().map(|&arg| AbiParam::new(fx.bcx.func.dfg.value_type(arg))).collect(),
|
args.iter().map(|&arg| AbiParam::new(fx.bcx.func.dfg.value_type(arg))).collect(),
|
||||||
vec![],
|
vec![],
|
||||||
args,
|
args,
|
||||||
|
@ -64,17 +64,12 @@ pub(crate) fn clif_int_or_float_cast(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
let from_rust_ty = if from_signed { fx.tcx.types.i128 } else { fx.tcx.types.u128 };
|
return fx.lib_call(
|
||||||
|
&name,
|
||||||
let to_rust_ty = match to_ty {
|
vec![AbiParam::new(types::I128)],
|
||||||
types::F32 => fx.tcx.types.f32,
|
vec![AbiParam::new(to_ty)],
|
||||||
types::F64 => fx.tcx.types.f64,
|
&[from],
|
||||||
_ => unreachable!(),
|
)[0];
|
||||||
};
|
|
||||||
|
|
||||||
return fx
|
|
||||||
.easy_call(&name, &[CValue::by_val(from, fx.layout_of(from_rust_ty))], to_rust_ty)
|
|
||||||
.load_scalar(fx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// int-like -> float
|
// int-like -> float
|
||||||
@ -101,16 +96,29 @@ pub(crate) fn clif_int_or_float_cast(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
let from_rust_ty = match from_ty {
|
if fx.tcx.sess.target.is_like_windows {
|
||||||
types::F32 => fx.tcx.types.f32,
|
let ret = fx.lib_call(
|
||||||
types::F64 => fx.tcx.types.f64,
|
&name,
|
||||||
_ => unreachable!(),
|
vec![AbiParam::new(from_ty)],
|
||||||
};
|
vec![AbiParam::new(types::I64X2)],
|
||||||
|
&[from],
|
||||||
let to_rust_ty = if to_signed { fx.tcx.types.i128 } else { fx.tcx.types.u128 };
|
)[0];
|
||||||
|
// FIXME use bitcast instead of store to get from i64x2 to i128
|
||||||
fx.easy_call(&name, &[CValue::by_val(from, fx.layout_of(from_rust_ty))], to_rust_ty)
|
let stack_slot = fx.bcx.create_sized_stack_slot(StackSlotData {
|
||||||
.load_scalar(fx)
|
kind: StackSlotKind::ExplicitSlot,
|
||||||
|
size: 16,
|
||||||
|
});
|
||||||
|
let ret_ptr = Pointer::stack_slot(stack_slot);
|
||||||
|
ret_ptr.store(fx, ret, MemFlags::trusted());
|
||||||
|
ret_ptr.load(fx, types::I128, MemFlags::trusted())
|
||||||
|
} else {
|
||||||
|
fx.lib_call(
|
||||||
|
&name,
|
||||||
|
vec![AbiParam::new(from_ty)],
|
||||||
|
vec![AbiParam::new(types::I128)],
|
||||||
|
&[from],
|
||||||
|
)[0]
|
||||||
|
}
|
||||||
} else if to_ty == types::I8 || to_ty == types::I16 {
|
} else if to_ty == types::I8 || to_ty == types::I16 {
|
||||||
// FIXME implement fcvt_to_*int_sat.i8/i16
|
// FIXME implement fcvt_to_*int_sat.i8/i16
|
||||||
let val = if to_signed {
|
let val = if to_signed {
|
||||||
|
@ -29,39 +29,24 @@ pub(crate) fn maybe_codegen<'tcx>(
|
|||||||
BinOp::Add | BinOp::Sub if !checked => None,
|
BinOp::Add | BinOp::Sub if !checked => None,
|
||||||
BinOp::Mul if !checked || is_signed => {
|
BinOp::Mul if !checked || is_signed => {
|
||||||
if !checked {
|
if !checked {
|
||||||
let val_ty = if is_signed { fx.tcx.types.i128 } else { fx.tcx.types.u128 };
|
let args = [lhs.load_scalar(fx), rhs.load_scalar(fx)];
|
||||||
if fx.tcx.sess.target.is_like_windows {
|
let ret_val = fx.lib_call(
|
||||||
let ret_place = CPlace::new_stack_slot(fx, lhs.layout());
|
"__multi3",
|
||||||
let (lhs_ptr, lhs_extra) = lhs.force_stack(fx);
|
vec![AbiParam::new(types::I128), AbiParam::new(types::I128)],
|
||||||
let (rhs_ptr, rhs_extra) = rhs.force_stack(fx);
|
vec![AbiParam::new(types::I128)],
|
||||||
assert!(lhs_extra.is_none());
|
&args,
|
||||||
assert!(rhs_extra.is_none());
|
)[0];
|
||||||
let args = [
|
Some(CValue::by_val(
|
||||||
ret_place.to_ptr().get_addr(fx),
|
ret_val,
|
||||||
lhs_ptr.get_addr(fx),
|
fx.layout_of(if is_signed { fx.tcx.types.i128 } else { fx.tcx.types.u128 }),
|
||||||
rhs_ptr.get_addr(fx),
|
))
|
||||||
];
|
|
||||||
fx.lib_call(
|
|
||||||
"__multi3",
|
|
||||||
vec![
|
|
||||||
AbiParam::special(fx.pointer_type, ArgumentPurpose::StructReturn),
|
|
||||||
AbiParam::new(fx.pointer_type),
|
|
||||||
AbiParam::new(fx.pointer_type),
|
|
||||||
],
|
|
||||||
vec![],
|
|
||||||
&args,
|
|
||||||
);
|
|
||||||
Some(ret_place.to_cvalue(fx))
|
|
||||||
} else {
|
|
||||||
Some(fx.easy_call("__multi3", &[lhs, rhs], val_ty))
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
let out_ty = fx.tcx.mk_tup(&[lhs.layout().ty, fx.tcx.types.bool]);
|
let out_ty = fx.tcx.mk_tup(&[lhs.layout().ty, fx.tcx.types.bool]);
|
||||||
let oflow = CPlace::new_stack_slot(fx, fx.layout_of(fx.tcx.types.i32));
|
let oflow = CPlace::new_stack_slot(fx, fx.layout_of(fx.tcx.types.i32));
|
||||||
let lhs = lhs.load_scalar(fx);
|
let lhs = lhs.load_scalar(fx);
|
||||||
let rhs = rhs.load_scalar(fx);
|
let rhs = rhs.load_scalar(fx);
|
||||||
let oflow_ptr = oflow.to_ptr().get_addr(fx);
|
let oflow_ptr = oflow.to_ptr().get_addr(fx);
|
||||||
let res = fx.lib_call(
|
let res = fx.lib_call_unadjusted(
|
||||||
"__muloti4",
|
"__muloti4",
|
||||||
vec![
|
vec![
|
||||||
AbiParam::new(types::I128),
|
AbiParam::new(types::I128),
|
||||||
@ -80,29 +65,12 @@ pub(crate) fn maybe_codegen<'tcx>(
|
|||||||
assert!(checked);
|
assert!(checked);
|
||||||
let out_ty = fx.tcx.mk_tup(&[lhs.layout().ty, fx.tcx.types.bool]);
|
let out_ty = fx.tcx.mk_tup(&[lhs.layout().ty, fx.tcx.types.bool]);
|
||||||
let out_place = CPlace::new_stack_slot(fx, fx.layout_of(out_ty));
|
let out_place = CPlace::new_stack_slot(fx, fx.layout_of(out_ty));
|
||||||
let (param_types, args) = if fx.tcx.sess.target.is_like_windows {
|
let param_types = vec![
|
||||||
let (lhs_ptr, lhs_extra) = lhs.force_stack(fx);
|
AbiParam::special(fx.pointer_type, ArgumentPurpose::StructReturn),
|
||||||
let (rhs_ptr, rhs_extra) = rhs.force_stack(fx);
|
AbiParam::new(types::I128),
|
||||||
assert!(lhs_extra.is_none());
|
AbiParam::new(types::I128),
|
||||||
assert!(rhs_extra.is_none());
|
];
|
||||||
(
|
let args = [out_place.to_ptr().get_addr(fx), lhs.load_scalar(fx), rhs.load_scalar(fx)];
|
||||||
vec![
|
|
||||||
AbiParam::special(fx.pointer_type, ArgumentPurpose::StructReturn),
|
|
||||||
AbiParam::new(fx.pointer_type),
|
|
||||||
AbiParam::new(fx.pointer_type),
|
|
||||||
],
|
|
||||||
[out_place.to_ptr().get_addr(fx), lhs_ptr.get_addr(fx), rhs_ptr.get_addr(fx)],
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
(
|
|
||||||
vec![
|
|
||||||
AbiParam::special(fx.pointer_type, ArgumentPurpose::StructReturn),
|
|
||||||
AbiParam::new(types::I128),
|
|
||||||
AbiParam::new(types::I128),
|
|
||||||
],
|
|
||||||
[out_place.to_ptr().get_addr(fx), lhs.load_scalar(fx), rhs.load_scalar(fx)],
|
|
||||||
)
|
|
||||||
};
|
|
||||||
let name = match (bin_op, is_signed) {
|
let name = match (bin_op, is_signed) {
|
||||||
(BinOp::Add, false) => "__rust_u128_addo",
|
(BinOp::Add, false) => "__rust_u128_addo",
|
||||||
(BinOp::Add, true) => "__rust_i128_addo",
|
(BinOp::Add, true) => "__rust_i128_addo",
|
||||||
@ -125,14 +93,10 @@ pub(crate) fn maybe_codegen<'tcx>(
|
|||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
if fx.tcx.sess.target.is_like_windows {
|
if fx.tcx.sess.target.is_like_windows {
|
||||||
let (lhs_ptr, lhs_extra) = lhs.force_stack(fx);
|
let args = [lhs.load_scalar(fx), rhs.load_scalar(fx)];
|
||||||
let (rhs_ptr, rhs_extra) = rhs.force_stack(fx);
|
|
||||||
assert!(lhs_extra.is_none());
|
|
||||||
assert!(rhs_extra.is_none());
|
|
||||||
let args = [lhs_ptr.get_addr(fx), rhs_ptr.get_addr(fx)];
|
|
||||||
let ret = fx.lib_call(
|
let ret = fx.lib_call(
|
||||||
name,
|
name,
|
||||||
vec![AbiParam::new(fx.pointer_type), AbiParam::new(fx.pointer_type)],
|
vec![AbiParam::new(types::I128), AbiParam::new(types::I128)],
|
||||||
vec![AbiParam::new(types::I64X2)],
|
vec![AbiParam::new(types::I64X2)],
|
||||||
&args,
|
&args,
|
||||||
)[0];
|
)[0];
|
||||||
@ -141,7 +105,14 @@ pub(crate) fn maybe_codegen<'tcx>(
|
|||||||
ret_place.to_ptr().store(fx, ret, MemFlags::trusted());
|
ret_place.to_ptr().store(fx, ret, MemFlags::trusted());
|
||||||
Some(ret_place.to_cvalue(fx))
|
Some(ret_place.to_cvalue(fx))
|
||||||
} else {
|
} else {
|
||||||
Some(fx.easy_call(name, &[lhs, rhs], lhs.layout().ty))
|
let args = [lhs.load_scalar(fx), rhs.load_scalar(fx)];
|
||||||
|
let ret_val = fx.lib_call(
|
||||||
|
name,
|
||||||
|
vec![AbiParam::new(types::I128), AbiParam::new(types::I128)],
|
||||||
|
vec![AbiParam::new(types::I128)],
|
||||||
|
&args,
|
||||||
|
)[0];
|
||||||
|
Some(CValue::by_val(ret_val, lhs.layout()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BinOp::Lt | BinOp::Le | BinOp::Eq | BinOp::Ge | BinOp::Gt | BinOp::Ne => {
|
BinOp::Lt | BinOp::Le | BinOp::Eq | BinOp::Ge | BinOp::Gt | BinOp::Ne => {
|
||||||
|
@ -75,7 +75,7 @@ fn clif_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option<types::Typ
|
|||||||
ty::Adt(adt_def, _) if adt_def.repr().simd() => {
|
ty::Adt(adt_def, _) if adt_def.repr().simd() => {
|
||||||
let (element, count) = match &tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap().abi
|
let (element, count) = match &tcx.layout_of(ParamEnv::reveal_all().and(ty)).unwrap().abi
|
||||||
{
|
{
|
||||||
Abi::Vector { element, count } => (element.clone(), *count),
|
Abi::Vector { element, count } => (*element, *count),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@ builtin_functions! {
|
|||||||
|
|
||||||
// integers
|
// integers
|
||||||
fn __multi3(a: i128, b: i128) -> i128;
|
fn __multi3(a: i128, b: i128) -> i128;
|
||||||
|
fn __muloti4(n: i128, d: i128, oflow: &mut i32) -> i128;
|
||||||
fn __udivti3(n: u128, d: u128) -> u128;
|
fn __udivti3(n: u128, d: u128) -> u128;
|
||||||
fn __divti3(n: i128, d: i128) -> i128;
|
fn __divti3(n: i128, d: i128) -> i128;
|
||||||
fn __umodti3(n: u128, d: u128) -> u128;
|
fn __umodti3(n: u128, d: u128) -> u128;
|
||||||
|
@ -32,7 +32,7 @@ impl ConcurrencyLimiter {
|
|||||||
ConcurrencyLimiter {
|
ConcurrencyLimiter {
|
||||||
helper_thread: Some(helper_thread),
|
helper_thread: Some(helper_thread),
|
||||||
state,
|
state,
|
||||||
available_token_condvar: Arc::new(Condvar::new()),
|
available_token_condvar,
|
||||||
finished: false,
|
finished: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -290,7 +290,7 @@ fn data_id_for_static(
|
|||||||
};
|
};
|
||||||
|
|
||||||
let data_id = match module.declare_data(
|
let data_id = match module.declare_data(
|
||||||
&*symbol_name,
|
symbol_name,
|
||||||
linkage,
|
linkage,
|
||||||
is_mutable,
|
is_mutable,
|
||||||
attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL),
|
attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL),
|
||||||
@ -338,7 +338,7 @@ fn data_id_for_static(
|
|||||||
};
|
};
|
||||||
|
|
||||||
let data_id = match module.declare_data(
|
let data_id = match module.declare_data(
|
||||||
&*symbol_name,
|
symbol_name,
|
||||||
linkage,
|
linkage,
|
||||||
is_mutable,
|
is_mutable,
|
||||||
attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL),
|
attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL),
|
||||||
|
@ -1,248 +0,0 @@
|
|||||||
// Vendored from https://github.com/bytecodealliance/wasmtime/blob/b58a197d33f044193c3d608010f5e6ec394ac07e/cranelift/native/src/lib.rs
|
|
||||||
// which is licensed as
|
|
||||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
||||||
// unlike rustc_codegen_cranelift itself. Also applies a small change to remove #![cfg_attr] that
|
|
||||||
// rust's CI complains about and to fix formatting to match rustc.
|
|
||||||
// FIXME revert back to the external crate with Cranelift 0.93
|
|
||||||
#![allow(warnings)]
|
|
||||||
|
|
||||||
//! Performs autodetection of the host for the purposes of running
|
|
||||||
//! Cranelift to generate code to run on the same machine.
|
|
||||||
|
|
||||||
#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates, unstable_features)]
|
|
||||||
#![warn(unused_import_braces)]
|
|
||||||
|
|
||||||
use cranelift_codegen::isa;
|
|
||||||
use target_lexicon::Triple;
|
|
||||||
|
|
||||||
/// Return an `isa` builder configured for the current host
|
|
||||||
/// machine, or `Err(())` if the host machine is not supported
|
|
||||||
/// in the current configuration.
|
|
||||||
pub fn builder() -> Result<isa::Builder, &'static str> {
|
|
||||||
builder_with_options(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return an `isa` builder configured for the current host
|
|
||||||
/// machine, or `Err(())` if the host machine is not supported
|
|
||||||
/// in the current configuration.
|
|
||||||
///
|
|
||||||
/// Selects the given backend variant specifically; this is
|
|
||||||
/// useful when more than oen backend exists for a given target
|
|
||||||
/// (e.g., on x86-64).
|
|
||||||
pub fn builder_with_options(infer_native_flags: bool) -> Result<isa::Builder, &'static str> {
|
|
||||||
let mut isa_builder = isa::lookup(Triple::host()).map_err(|err| match err {
|
|
||||||
isa::LookupError::SupportDisabled => "support for architecture disabled at compile time",
|
|
||||||
isa::LookupError::Unsupported => "unsupported architecture",
|
|
||||||
})?;
|
|
||||||
|
|
||||||
#[cfg(target_arch = "x86_64")]
|
|
||||||
{
|
|
||||||
use cranelift_codegen::settings::Configurable;
|
|
||||||
|
|
||||||
if !std::is_x86_feature_detected!("sse2") {
|
|
||||||
return Err("x86 support requires SSE2");
|
|
||||||
}
|
|
||||||
|
|
||||||
if !infer_native_flags {
|
|
||||||
return Ok(isa_builder);
|
|
||||||
}
|
|
||||||
|
|
||||||
// These are temporarily enabled by default (see #3810 for
|
|
||||||
// more) so that a default-constructed `Flags` can work with
|
|
||||||
// default Wasmtime features. Otherwise, the user must
|
|
||||||
// explicitly use native flags or turn these on when on x86-64
|
|
||||||
// platforms to avoid a configuration panic. In order for the
|
|
||||||
// "enable if detected" logic below to work, we must turn them
|
|
||||||
// *off* (differing from the default) and then re-enable below
|
|
||||||
// if present.
|
|
||||||
isa_builder.set("has_sse3", "false").unwrap();
|
|
||||||
isa_builder.set("has_ssse3", "false").unwrap();
|
|
||||||
isa_builder.set("has_sse41", "false").unwrap();
|
|
||||||
isa_builder.set("has_sse42", "false").unwrap();
|
|
||||||
|
|
||||||
if std::is_x86_feature_detected!("sse3") {
|
|
||||||
isa_builder.enable("has_sse3").unwrap();
|
|
||||||
}
|
|
||||||
if std::is_x86_feature_detected!("ssse3") {
|
|
||||||
isa_builder.enable("has_ssse3").unwrap();
|
|
||||||
}
|
|
||||||
if std::is_x86_feature_detected!("sse4.1") {
|
|
||||||
isa_builder.enable("has_sse41").unwrap();
|
|
||||||
}
|
|
||||||
if std::is_x86_feature_detected!("sse4.2") {
|
|
||||||
isa_builder.enable("has_sse42").unwrap();
|
|
||||||
}
|
|
||||||
if std::is_x86_feature_detected!("popcnt") {
|
|
||||||
isa_builder.enable("has_popcnt").unwrap();
|
|
||||||
}
|
|
||||||
if std::is_x86_feature_detected!("avx") {
|
|
||||||
isa_builder.enable("has_avx").unwrap();
|
|
||||||
}
|
|
||||||
if std::is_x86_feature_detected!("avx2") {
|
|
||||||
isa_builder.enable("has_avx2").unwrap();
|
|
||||||
}
|
|
||||||
if std::is_x86_feature_detected!("fma") {
|
|
||||||
isa_builder.enable("has_fma").unwrap();
|
|
||||||
}
|
|
||||||
if std::is_x86_feature_detected!("bmi1") {
|
|
||||||
isa_builder.enable("has_bmi1").unwrap();
|
|
||||||
}
|
|
||||||
if std::is_x86_feature_detected!("bmi2") {
|
|
||||||
isa_builder.enable("has_bmi2").unwrap();
|
|
||||||
}
|
|
||||||
if std::is_x86_feature_detected!("avx512bitalg") {
|
|
||||||
isa_builder.enable("has_avx512bitalg").unwrap();
|
|
||||||
}
|
|
||||||
if std::is_x86_feature_detected!("avx512dq") {
|
|
||||||
isa_builder.enable("has_avx512dq").unwrap();
|
|
||||||
}
|
|
||||||
if std::is_x86_feature_detected!("avx512f") {
|
|
||||||
isa_builder.enable("has_avx512f").unwrap();
|
|
||||||
}
|
|
||||||
if std::is_x86_feature_detected!("avx512vl") {
|
|
||||||
isa_builder.enable("has_avx512vl").unwrap();
|
|
||||||
}
|
|
||||||
if std::is_x86_feature_detected!("avx512vbmi") {
|
|
||||||
isa_builder.enable("has_avx512vbmi").unwrap();
|
|
||||||
}
|
|
||||||
if std::is_x86_feature_detected!("lzcnt") {
|
|
||||||
isa_builder.enable("has_lzcnt").unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(target_arch = "aarch64")]
|
|
||||||
{
|
|
||||||
use cranelift_codegen::settings::Configurable;
|
|
||||||
|
|
||||||
if !infer_native_flags {
|
|
||||||
return Ok(isa_builder);
|
|
||||||
}
|
|
||||||
|
|
||||||
if std::arch::is_aarch64_feature_detected!("lse") {
|
|
||||||
isa_builder.enable("has_lse").unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
if std::arch::is_aarch64_feature_detected!("paca") {
|
|
||||||
isa_builder.enable("has_pauth").unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
if cfg!(target_os = "macos") {
|
|
||||||
// Pointer authentication is always available on Apple Silicon.
|
|
||||||
isa_builder.enable("sign_return_address").unwrap();
|
|
||||||
// macOS enforces the use of the B key for return addresses.
|
|
||||||
isa_builder.enable("sign_return_address_with_bkey").unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// There is no is_s390x_feature_detected macro yet, so for now
|
|
||||||
// we use getauxval from the libc crate directly.
|
|
||||||
#[cfg(all(target_arch = "s390x", target_os = "linux"))]
|
|
||||||
{
|
|
||||||
use cranelift_codegen::settings::Configurable;
|
|
||||||
|
|
||||||
if !infer_native_flags {
|
|
||||||
return Ok(isa_builder);
|
|
||||||
}
|
|
||||||
|
|
||||||
let v = unsafe { libc::getauxval(libc::AT_HWCAP) };
|
|
||||||
const HWCAP_S390X_VXRS_EXT2: libc::c_ulong = 32768;
|
|
||||||
if (v & HWCAP_S390X_VXRS_EXT2) != 0 {
|
|
||||||
isa_builder.enable("has_vxrs_ext2").unwrap();
|
|
||||||
// There is no separate HWCAP bit for mie2, so assume
|
|
||||||
// that any machine with vxrs_ext2 also has mie2.
|
|
||||||
isa_builder.enable("has_mie2").unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// `is_riscv_feature_detected` is nightly only for now, use
|
|
||||||
// getauxval from the libc crate directly as a temporary measure.
|
|
||||||
#[cfg(all(target_arch = "riscv64", target_os = "linux"))]
|
|
||||||
{
|
|
||||||
use cranelift_codegen::settings::Configurable;
|
|
||||||
|
|
||||||
if !infer_native_flags {
|
|
||||||
return Ok(isa_builder);
|
|
||||||
}
|
|
||||||
|
|
||||||
let v = unsafe { libc::getauxval(libc::AT_HWCAP) };
|
|
||||||
|
|
||||||
const HWCAP_RISCV_EXT_A: libc::c_ulong = 1 << (b'a' - b'a');
|
|
||||||
const HWCAP_RISCV_EXT_C: libc::c_ulong = 1 << (b'c' - b'a');
|
|
||||||
const HWCAP_RISCV_EXT_D: libc::c_ulong = 1 << (b'd' - b'a');
|
|
||||||
const HWCAP_RISCV_EXT_F: libc::c_ulong = 1 << (b'f' - b'a');
|
|
||||||
const HWCAP_RISCV_EXT_M: libc::c_ulong = 1 << (b'm' - b'a');
|
|
||||||
const HWCAP_RISCV_EXT_V: libc::c_ulong = 1 << (b'v' - b'a');
|
|
||||||
|
|
||||||
if (v & HWCAP_RISCV_EXT_A) != 0 {
|
|
||||||
isa_builder.enable("has_a").unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (v & HWCAP_RISCV_EXT_C) != 0 {
|
|
||||||
isa_builder.enable("has_c").unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (v & HWCAP_RISCV_EXT_D) != 0 {
|
|
||||||
isa_builder.enable("has_d").unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (v & HWCAP_RISCV_EXT_F) != 0 {
|
|
||||||
isa_builder.enable("has_f").unwrap();
|
|
||||||
|
|
||||||
// TODO: There doesn't seem to be a bit associated with this extension
|
|
||||||
// rust enables it with the `f` extension:
|
|
||||||
// https://github.com/rust-lang/stdarch/blob/790411f93c4b5eada3c23abb4c9a063fb0b24d99/crates/std_detect/src/detect/os/linux/riscv.rs#L43
|
|
||||||
isa_builder.enable("has_zicsr").unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (v & HWCAP_RISCV_EXT_M) != 0 {
|
|
||||||
isa_builder.enable("has_m").unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (v & HWCAP_RISCV_EXT_V) != 0 {
|
|
||||||
isa_builder.enable("has_v").unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: ZiFencei does not have a bit associated with it
|
|
||||||
// TODO: Zbkb does not have a bit associated with it
|
|
||||||
}
|
|
||||||
|
|
||||||
// squelch warnings about unused mut/variables on some platforms.
|
|
||||||
drop(&mut isa_builder);
|
|
||||||
drop(infer_native_flags);
|
|
||||||
|
|
||||||
Ok(isa_builder)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::builder;
|
|
||||||
use cranelift_codegen::isa::CallConv;
|
|
||||||
use cranelift_codegen::settings;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test() {
|
|
||||||
if let Ok(isa_builder) = builder() {
|
|
||||||
let flag_builder = settings::builder();
|
|
||||||
let isa = isa_builder.finish(settings::Flags::new(flag_builder)).unwrap();
|
|
||||||
|
|
||||||
if cfg!(all(target_os = "macos", target_arch = "aarch64")) {
|
|
||||||
assert_eq!(isa.default_call_conv(), CallConv::AppleAarch64);
|
|
||||||
} else if cfg!(any(unix, target_os = "nebulet")) {
|
|
||||||
assert_eq!(isa.default_call_conv(), CallConv::SystemV);
|
|
||||||
} else if cfg!(windows) {
|
|
||||||
assert_eq!(isa.default_call_conv(), CallConv::WindowsFastcall);
|
|
||||||
}
|
|
||||||
|
|
||||||
if cfg!(target_pointer_width = "64") {
|
|
||||||
assert_eq!(isa.pointer_bits(), 64);
|
|
||||||
} else if cfg!(target_pointer_width = "32") {
|
|
||||||
assert_eq!(isa.pointer_bits(), 32);
|
|
||||||
} else if cfg!(target_pointer_width = "16") {
|
|
||||||
assert_eq!(isa.pointer_bits(), 16);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Version number of this crate.
|
|
||||||
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
|
@ -113,7 +113,7 @@ impl Writer for WriterRelocate {
|
|||||||
offset: offset as u32,
|
offset: offset as u32,
|
||||||
size,
|
size,
|
||||||
name: DebugRelocName::Symbol(symbol),
|
name: DebugRelocName::Symbol(symbol),
|
||||||
addend: addend as i64,
|
addend,
|
||||||
kind: object::RelocationKind::Absolute,
|
kind: object::RelocationKind::Absolute,
|
||||||
});
|
});
|
||||||
self.write_udata(0, size)
|
self.write_udata(0, size)
|
||||||
|
@ -377,7 +377,7 @@ pub(crate) fn run_aot(
|
|||||||
};
|
};
|
||||||
|
|
||||||
if tcx.dep_graph.is_fully_enabled() {
|
if tcx.dep_graph.is_fully_enabled() {
|
||||||
for cgu in &*cgus {
|
for cgu in cgus {
|
||||||
tcx.ensure().codegen_unit(cgu.name());
|
tcx.ensure().codegen_unit(cgu.name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -417,7 +417,7 @@ pub(crate) fn run_aot(
|
|||||||
CguReuse::PreLto => unreachable!(),
|
CguReuse::PreLto => unreachable!(),
|
||||||
CguReuse::PostLto => {
|
CguReuse::PostLto => {
|
||||||
concurrency_limiter.job_already_done();
|
concurrency_limiter.job_already_done();
|
||||||
OngoingModuleCodegen::Sync(reuse_workproduct_for_cgu(tcx, &*cgu))
|
OngoingModuleCodegen::Sync(reuse_workproduct_for_cgu(tcx, cgu))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -311,7 +311,11 @@ fn dep_symbol_lookup_fn(
|
|||||||
.find(|(crate_type, _data)| *crate_type == rustc_session::config::CrateType::Executable)
|
.find(|(crate_type, _data)| *crate_type == rustc_session::config::CrateType::Executable)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.1;
|
.1;
|
||||||
for &cnum in &crate_info.used_crates {
|
// `used_crates` is in reverse postorder in terms of dependencies. Reverse the order here to
|
||||||
|
// get a postorder which ensures that all dependencies of a dylib are loaded before the dylib
|
||||||
|
// itself. This helps the dynamic linker to find dylibs not in the regular dynamic library
|
||||||
|
// search path.
|
||||||
|
for &cnum in crate_info.used_crates.iter().rev() {
|
||||||
let src = &crate_info.used_crate_source[&cnum];
|
let src = &crate_info.used_crate_source[&cnum];
|
||||||
match data[cnum.as_usize() - 1] {
|
match data[cnum.as_usize() - 1] {
|
||||||
Linkage::NotLinked | Linkage::IncludedFromDylib => {}
|
Linkage::NotLinked | Linkage::IncludedFromDylib => {}
|
||||||
|
@ -125,7 +125,7 @@ pub(crate) fn compile_global_asm(
|
|||||||
let output_object_file = config.output_filenames.temp_path(OutputType::Object, Some(cgu_name));
|
let output_object_file = config.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, ".asm");
|
||||||
let mut child = Command::new(&config.assembler)
|
let mut child = Command::new(&config.assembler)
|
||||||
.arg("-o")
|
.arg("-o")
|
||||||
.arg(&global_asm_object_file)
|
.arg(&global_asm_object_file)
|
||||||
|
@ -242,7 +242,7 @@ pub(crate) fn codegen_inline_asm<'tcx>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
InlineAsmOperand::Const { ref value } => {
|
InlineAsmOperand::Const { ref value } => {
|
||||||
let (const_value, ty) = crate::constant::eval_mir_constant(fx, &*value)
|
let (const_value, ty) = crate::constant::eval_mir_constant(fx, value)
|
||||||
.unwrap_or_else(|| span_bug!(span, "asm const cannot be resolved"));
|
.unwrap_or_else(|| span_bug!(span, "asm const cannot be resolved"));
|
||||||
let value = rustc_codegen_ssa::common::asm_const_to_str(
|
let value = rustc_codegen_ssa::common::asm_const_to_str(
|
||||||
fx.tcx,
|
fx.tcx,
|
||||||
@ -334,13 +334,13 @@ pub(crate) fn codegen_inline_asm<'tcx>(
|
|||||||
}
|
}
|
||||||
CInlineAsmOperand::Out { reg: _, late: _, place } => {
|
CInlineAsmOperand::Out { reg: _, late: _, place } => {
|
||||||
if let Some(place) = place {
|
if let Some(place) = place {
|
||||||
outputs.push((asm_gen.stack_slots_output[i].unwrap(), place.clone()));
|
outputs.push((asm_gen.stack_slots_output[i].unwrap(), *place));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CInlineAsmOperand::InOut { reg: _, _late: _, in_value, out_place } => {
|
CInlineAsmOperand::InOut { reg: _, _late: _, in_value, out_place } => {
|
||||||
inputs.push((asm_gen.stack_slots_input[i].unwrap(), in_value.load_scalar(fx)));
|
inputs.push((asm_gen.stack_slots_input[i].unwrap(), in_value.load_scalar(fx)));
|
||||||
if let Some(out_place) = out_place {
|
if let Some(out_place) = out_place {
|
||||||
outputs.push((asm_gen.stack_slots_output[i].unwrap(), out_place.clone()));
|
outputs.push((asm_gen.stack_slots_output[i].unwrap(), *out_place));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CInlineAsmOperand::Const { value: _ } | CInlineAsmOperand::Symbol { symbol: _ } => {}
|
CInlineAsmOperand::Const { value: _ } | CInlineAsmOperand::Symbol { symbol: _ } => {}
|
||||||
|
@ -23,7 +23,7 @@ pub(crate) use llvm::codegen_llvm_intrinsic_call;
|
|||||||
|
|
||||||
use rustc_middle::ty;
|
use rustc_middle::ty;
|
||||||
use rustc_middle::ty::layout::{HasParamEnv, ValidityRequirement};
|
use rustc_middle::ty::layout::{HasParamEnv, ValidityRequirement};
|
||||||
use rustc_middle::ty::print::with_no_trimmed_paths;
|
use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths};
|
||||||
use rustc_middle::ty::subst::SubstsRef;
|
use rustc_middle::ty::subst::SubstsRef;
|
||||||
use rustc_span::symbol::{kw, sym, Symbol};
|
use rustc_span::symbol::{kw, sym, Symbol};
|
||||||
|
|
||||||
@ -252,45 +252,45 @@ fn codegen_float_intrinsic_call<'tcx>(
|
|||||||
args: &[mir::Operand<'tcx>],
|
args: &[mir::Operand<'tcx>],
|
||||||
ret: CPlace<'tcx>,
|
ret: CPlace<'tcx>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let (name, arg_count, ty) = match intrinsic {
|
let (name, arg_count, ty, clif_ty) = match intrinsic {
|
||||||
sym::expf32 => ("expf", 1, fx.tcx.types.f32),
|
sym::expf32 => ("expf", 1, fx.tcx.types.f32, types::F32),
|
||||||
sym::expf64 => ("exp", 1, fx.tcx.types.f64),
|
sym::expf64 => ("exp", 1, fx.tcx.types.f64, types::F64),
|
||||||
sym::exp2f32 => ("exp2f", 1, fx.tcx.types.f32),
|
sym::exp2f32 => ("exp2f", 1, fx.tcx.types.f32, types::F32),
|
||||||
sym::exp2f64 => ("exp2", 1, fx.tcx.types.f64),
|
sym::exp2f64 => ("exp2", 1, fx.tcx.types.f64, types::F64),
|
||||||
sym::sqrtf32 => ("sqrtf", 1, fx.tcx.types.f32),
|
sym::sqrtf32 => ("sqrtf", 1, fx.tcx.types.f32, types::F32),
|
||||||
sym::sqrtf64 => ("sqrt", 1, fx.tcx.types.f64),
|
sym::sqrtf64 => ("sqrt", 1, fx.tcx.types.f64, types::F64),
|
||||||
sym::powif32 => ("__powisf2", 2, fx.tcx.types.f32), // compiler-builtins
|
sym::powif32 => ("__powisf2", 2, fx.tcx.types.f32, types::F32), // compiler-builtins
|
||||||
sym::powif64 => ("__powidf2", 2, fx.tcx.types.f64), // compiler-builtins
|
sym::powif64 => ("__powidf2", 2, fx.tcx.types.f64, types::F64), // compiler-builtins
|
||||||
sym::powf32 => ("powf", 2, fx.tcx.types.f32),
|
sym::powf32 => ("powf", 2, fx.tcx.types.f32, types::F32),
|
||||||
sym::powf64 => ("pow", 2, fx.tcx.types.f64),
|
sym::powf64 => ("pow", 2, fx.tcx.types.f64, types::F64),
|
||||||
sym::logf32 => ("logf", 1, fx.tcx.types.f32),
|
sym::logf32 => ("logf", 1, fx.tcx.types.f32, types::F32),
|
||||||
sym::logf64 => ("log", 1, fx.tcx.types.f64),
|
sym::logf64 => ("log", 1, fx.tcx.types.f64, types::F64),
|
||||||
sym::log2f32 => ("log2f", 1, fx.tcx.types.f32),
|
sym::log2f32 => ("log2f", 1, fx.tcx.types.f32, types::F32),
|
||||||
sym::log2f64 => ("log2", 1, fx.tcx.types.f64),
|
sym::log2f64 => ("log2", 1, fx.tcx.types.f64, types::F64),
|
||||||
sym::log10f32 => ("log10f", 1, fx.tcx.types.f32),
|
sym::log10f32 => ("log10f", 1, fx.tcx.types.f32, types::F32),
|
||||||
sym::log10f64 => ("log10", 1, fx.tcx.types.f64),
|
sym::log10f64 => ("log10", 1, fx.tcx.types.f64, types::F64),
|
||||||
sym::fabsf32 => ("fabsf", 1, fx.tcx.types.f32),
|
sym::fabsf32 => ("fabsf", 1, fx.tcx.types.f32, types::F32),
|
||||||
sym::fabsf64 => ("fabs", 1, fx.tcx.types.f64),
|
sym::fabsf64 => ("fabs", 1, fx.tcx.types.f64, types::F64),
|
||||||
sym::fmaf32 => ("fmaf", 3, fx.tcx.types.f32),
|
sym::fmaf32 => ("fmaf", 3, fx.tcx.types.f32, types::F32),
|
||||||
sym::fmaf64 => ("fma", 3, fx.tcx.types.f64),
|
sym::fmaf64 => ("fma", 3, fx.tcx.types.f64, types::F64),
|
||||||
sym::copysignf32 => ("copysignf", 2, fx.tcx.types.f32),
|
sym::copysignf32 => ("copysignf", 2, fx.tcx.types.f32, types::F32),
|
||||||
sym::copysignf64 => ("copysign", 2, fx.tcx.types.f64),
|
sym::copysignf64 => ("copysign", 2, fx.tcx.types.f64, types::F64),
|
||||||
sym::floorf32 => ("floorf", 1, fx.tcx.types.f32),
|
sym::floorf32 => ("floorf", 1, fx.tcx.types.f32, types::F32),
|
||||||
sym::floorf64 => ("floor", 1, fx.tcx.types.f64),
|
sym::floorf64 => ("floor", 1, fx.tcx.types.f64, types::F64),
|
||||||
sym::ceilf32 => ("ceilf", 1, fx.tcx.types.f32),
|
sym::ceilf32 => ("ceilf", 1, fx.tcx.types.f32, types::F32),
|
||||||
sym::ceilf64 => ("ceil", 1, fx.tcx.types.f64),
|
sym::ceilf64 => ("ceil", 1, fx.tcx.types.f64, types::F64),
|
||||||
sym::truncf32 => ("truncf", 1, fx.tcx.types.f32),
|
sym::truncf32 => ("truncf", 1, fx.tcx.types.f32, types::F32),
|
||||||
sym::truncf64 => ("trunc", 1, fx.tcx.types.f64),
|
sym::truncf64 => ("trunc", 1, fx.tcx.types.f64, types::F64),
|
||||||
sym::rintf32 => ("rintf", 1, fx.tcx.types.f32),
|
sym::rintf32 => ("rintf", 1, fx.tcx.types.f32, types::F32),
|
||||||
sym::rintf64 => ("rint", 1, fx.tcx.types.f64),
|
sym::rintf64 => ("rint", 1, fx.tcx.types.f64, types::F64),
|
||||||
sym::roundf32 => ("roundf", 1, fx.tcx.types.f32),
|
sym::roundf32 => ("roundf", 1, fx.tcx.types.f32, types::F32),
|
||||||
sym::roundf64 => ("round", 1, fx.tcx.types.f64),
|
sym::roundf64 => ("round", 1, fx.tcx.types.f64, types::F64),
|
||||||
sym::roundevenf32 => ("roundevenf", 1, fx.tcx.types.f32),
|
sym::roundevenf32 => ("roundevenf", 1, fx.tcx.types.f32, types::F32),
|
||||||
sym::roundevenf64 => ("roundeven", 1, fx.tcx.types.f64),
|
sym::roundevenf64 => ("roundeven", 1, fx.tcx.types.f64, types::F64),
|
||||||
sym::sinf32 => ("sinf", 1, fx.tcx.types.f32),
|
sym::sinf32 => ("sinf", 1, fx.tcx.types.f32, types::F32),
|
||||||
sym::sinf64 => ("sin", 1, fx.tcx.types.f64),
|
sym::sinf64 => ("sin", 1, fx.tcx.types.f64, types::F64),
|
||||||
sym::cosf32 => ("cosf", 1, fx.tcx.types.f32),
|
sym::cosf32 => ("cosf", 1, fx.tcx.types.f32, types::F32),
|
||||||
sym::cosf64 => ("cos", 1, fx.tcx.types.f64),
|
sym::cosf64 => ("cos", 1, fx.tcx.types.f64, types::F64),
|
||||||
_ => return false,
|
_ => return false,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -301,15 +301,19 @@ fn codegen_float_intrinsic_call<'tcx>(
|
|||||||
let (a, b, c);
|
let (a, b, c);
|
||||||
let args = match args {
|
let args = match args {
|
||||||
[x] => {
|
[x] => {
|
||||||
a = [codegen_operand(fx, x)];
|
a = [codegen_operand(fx, x).load_scalar(fx)];
|
||||||
&a as &[_]
|
&a as &[_]
|
||||||
}
|
}
|
||||||
[x, y] => {
|
[x, y] => {
|
||||||
b = [codegen_operand(fx, x), codegen_operand(fx, y)];
|
b = [codegen_operand(fx, x).load_scalar(fx), codegen_operand(fx, y).load_scalar(fx)];
|
||||||
&b
|
&b
|
||||||
}
|
}
|
||||||
[x, y, z] => {
|
[x, y, z] => {
|
||||||
c = [codegen_operand(fx, x), codegen_operand(fx, y), codegen_operand(fx, z)];
|
c = [
|
||||||
|
codegen_operand(fx, x).load_scalar(fx),
|
||||||
|
codegen_operand(fx, y).load_scalar(fx),
|
||||||
|
codegen_operand(fx, z).load_scalar(fx),
|
||||||
|
];
|
||||||
&c
|
&c
|
||||||
}
|
}
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
@ -318,15 +322,10 @@ fn codegen_float_intrinsic_call<'tcx>(
|
|||||||
let layout = fx.layout_of(ty);
|
let layout = fx.layout_of(ty);
|
||||||
let res = match intrinsic {
|
let res = match intrinsic {
|
||||||
sym::fmaf32 | sym::fmaf64 => {
|
sym::fmaf32 | sym::fmaf64 => {
|
||||||
let a = args[0].load_scalar(fx);
|
CValue::by_val(fx.bcx.ins().fma(args[0], args[1], args[2]), layout)
|
||||||
let b = args[1].load_scalar(fx);
|
|
||||||
let c = args[2].load_scalar(fx);
|
|
||||||
CValue::by_val(fx.bcx.ins().fma(a, b, c), layout)
|
|
||||||
}
|
}
|
||||||
sym::copysignf32 | sym::copysignf64 => {
|
sym::copysignf32 | sym::copysignf64 => {
|
||||||
let a = args[0].load_scalar(fx);
|
CValue::by_val(fx.bcx.ins().fcopysign(args[0], args[1]), layout)
|
||||||
let b = args[1].load_scalar(fx);
|
|
||||||
CValue::by_val(fx.bcx.ins().fcopysign(a, b), layout)
|
|
||||||
}
|
}
|
||||||
sym::fabsf32
|
sym::fabsf32
|
||||||
| sym::fabsf64
|
| sym::fabsf64
|
||||||
@ -336,21 +335,29 @@ fn codegen_float_intrinsic_call<'tcx>(
|
|||||||
| sym::ceilf64
|
| sym::ceilf64
|
||||||
| sym::truncf32
|
| sym::truncf32
|
||||||
| sym::truncf64 => {
|
| sym::truncf64 => {
|
||||||
let a = args[0].load_scalar(fx);
|
|
||||||
|
|
||||||
let val = match intrinsic {
|
let val = match intrinsic {
|
||||||
sym::fabsf32 | sym::fabsf64 => fx.bcx.ins().fabs(a),
|
sym::fabsf32 | sym::fabsf64 => fx.bcx.ins().fabs(args[0]),
|
||||||
sym::floorf32 | sym::floorf64 => fx.bcx.ins().floor(a),
|
sym::floorf32 | sym::floorf64 => fx.bcx.ins().floor(args[0]),
|
||||||
sym::ceilf32 | sym::ceilf64 => fx.bcx.ins().ceil(a),
|
sym::ceilf32 | sym::ceilf64 => fx.bcx.ins().ceil(args[0]),
|
||||||
sym::truncf32 | sym::truncf64 => fx.bcx.ins().trunc(a),
|
sym::truncf32 | sym::truncf64 => fx.bcx.ins().trunc(args[0]),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
CValue::by_val(val, layout)
|
CValue::by_val(val, layout)
|
||||||
}
|
}
|
||||||
|
|
||||||
// These intrinsics aren't supported natively by Cranelift.
|
// These intrinsics aren't supported natively by Cranelift.
|
||||||
// Lower them to a libcall.
|
// Lower them to a libcall.
|
||||||
_ => fx.easy_call(name, &args, ty),
|
sym::powif32 | sym::powif64 => {
|
||||||
|
let input_tys: Vec<_> = vec![AbiParam::new(clif_ty), AbiParam::new(types::I32)];
|
||||||
|
let ret_val = fx.lib_call(name, input_tys, vec![AbiParam::new(clif_ty)], &args)[0];
|
||||||
|
CValue::by_val(ret_val, fx.layout_of(ty))
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
let input_tys: Vec<_> = args.iter().map(|_| AbiParam::new(clif_ty)).collect();
|
||||||
|
let ret_val = fx.lib_call(name, input_tys, vec![AbiParam::new(clif_ty)], &args)[0];
|
||||||
|
CValue::by_val(ret_val, fx.layout_of(ty))
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ret.write_cvalue(fx, res);
|
ret.write_cvalue(fx, res);
|
||||||
@ -385,7 +392,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
|
|||||||
|
|
||||||
fx.bcx.ins().debugtrap();
|
fx.bcx.ins().debugtrap();
|
||||||
}
|
}
|
||||||
sym::copy | sym::copy_nonoverlapping => {
|
sym::copy => {
|
||||||
intrinsic_args!(fx, args => (src, dst, count); intrinsic);
|
intrinsic_args!(fx, args => (src, dst, count); intrinsic);
|
||||||
let src = src.load_scalar(fx);
|
let src = src.load_scalar(fx);
|
||||||
let dst = dst.load_scalar(fx);
|
let dst = dst.load_scalar(fx);
|
||||||
@ -397,13 +404,8 @@ fn codegen_regular_intrinsic_call<'tcx>(
|
|||||||
let byte_amount =
|
let byte_amount =
|
||||||
if elem_size != 1 { fx.bcx.ins().imul_imm(count, elem_size as i64) } else { count };
|
if elem_size != 1 { fx.bcx.ins().imul_imm(count, elem_size as i64) } else { count };
|
||||||
|
|
||||||
if intrinsic == sym::copy_nonoverlapping {
|
// FIXME emit_small_memmove
|
||||||
// FIXME emit_small_memcpy
|
fx.bcx.call_memmove(fx.target_config, dst, src, byte_amount);
|
||||||
fx.bcx.call_memcpy(fx.target_config, dst, src, byte_amount);
|
|
||||||
} else {
|
|
||||||
// FIXME emit_small_memmove
|
|
||||||
fx.bcx.call_memmove(fx.target_config, dst, src, byte_amount);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
sym::volatile_copy_memory | sym::volatile_copy_nonoverlapping_memory => {
|
sym::volatile_copy_memory | sym::volatile_copy_nonoverlapping_memory => {
|
||||||
// NOTE: the volatile variants have src and dst swapped
|
// NOTE: the volatile variants have src and dst swapped
|
||||||
@ -643,26 +645,25 @@ fn codegen_regular_intrinsic_call<'tcx>(
|
|||||||
|
|
||||||
if do_panic {
|
if do_panic {
|
||||||
let layout = fx.layout_of(ty);
|
let layout = fx.layout_of(ty);
|
||||||
|
let msg_str = with_no_visible_paths!({
|
||||||
with_no_trimmed_paths!({
|
with_no_trimmed_paths!({
|
||||||
crate::base::codegen_panic_nounwind(
|
if layout.abi.is_uninhabited() {
|
||||||
fx,
|
// Use this error even for the other intrinsics as it is more precise.
|
||||||
&if layout.abi.is_uninhabited() {
|
format!("attempted to instantiate uninhabited type `{}`", ty)
|
||||||
format!("attempted to instantiate uninhabited type `{}`", layout.ty)
|
} else if intrinsic == sym::assert_zero_valid {
|
||||||
} else if requirement == ValidityRequirement::Zero {
|
|
||||||
format!(
|
format!(
|
||||||
"attempted to zero-initialize type `{}`, which is invalid",
|
"attempted to zero-initialize type `{}`, which is invalid",
|
||||||
layout.ty
|
ty
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
format!(
|
format!(
|
||||||
"attempted to leave type `{}` uninitialized, which is invalid",
|
"attempted to leave type `{}` uninitialized, which is invalid",
|
||||||
layout.ty
|
ty
|
||||||
)
|
)
|
||||||
},
|
}
|
||||||
source_info,
|
})
|
||||||
)
|
|
||||||
});
|
});
|
||||||
|
crate::base::codegen_panic_nounwind(fx, &msg_str, source_info);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -279,9 +279,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
|||||||
fx.tcx.sess.span_warn(span, "Index argument for `simd_extract` is not a constant");
|
fx.tcx.sess.span_warn(span, "Index argument for `simd_extract` is not a constant");
|
||||||
let trap_block = fx.bcx.create_block();
|
let trap_block = fx.bcx.create_block();
|
||||||
let true_ = fx.bcx.ins().iconst(types::I8, 1);
|
let true_ = fx.bcx.ins().iconst(types::I8, 1);
|
||||||
fx.bcx.ins().brnz(true_, trap_block, &[]);
|
|
||||||
let ret_block = fx.get_block(target);
|
let ret_block = fx.get_block(target);
|
||||||
fx.bcx.ins().jump(ret_block, &[]);
|
fx.bcx.ins().brif(true_, trap_block, &[], ret_block, &[]);
|
||||||
fx.bcx.switch_to_block(trap_block);
|
fx.bcx.switch_to_block(trap_block);
|
||||||
crate::trap::trap_unimplemented(
|
crate::trap::trap_unimplemented(
|
||||||
fx,
|
fx,
|
||||||
@ -825,8 +824,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
|||||||
let next = fx.bcx.create_block();
|
let next = fx.bcx.create_block();
|
||||||
let res_lane = fx.bcx.append_block_param(next, lane_clif_ty);
|
let res_lane = fx.bcx.append_block_param(next, lane_clif_ty);
|
||||||
|
|
||||||
fx.bcx.ins().brnz(mask_lane, if_enabled, &[]);
|
fx.bcx.ins().brif(mask_lane, if_enabled, &[], if_disabled, &[]);
|
||||||
fx.bcx.ins().jump(if_disabled, &[]);
|
|
||||||
fx.bcx.seal_block(if_enabled);
|
fx.bcx.seal_block(if_enabled);
|
||||||
fx.bcx.seal_block(if_disabled);
|
fx.bcx.seal_block(if_disabled);
|
||||||
|
|
||||||
@ -864,8 +862,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
|||||||
let if_enabled = fx.bcx.create_block();
|
let if_enabled = fx.bcx.create_block();
|
||||||
let next = fx.bcx.create_block();
|
let next = fx.bcx.create_block();
|
||||||
|
|
||||||
fx.bcx.ins().brnz(mask_lane, if_enabled, &[]);
|
fx.bcx.ins().brif(mask_lane, if_enabled, &[], next, &[]);
|
||||||
fx.bcx.ins().jump(next, &[]);
|
|
||||||
fx.bcx.seal_block(if_enabled);
|
fx.bcx.seal_block(if_enabled);
|
||||||
|
|
||||||
fx.bcx.switch_to_block(if_enabled);
|
fx.bcx.switch_to_block(if_enabled);
|
||||||
|
@ -57,8 +57,6 @@ mod compiler_builtins;
|
|||||||
mod concurrency_limiter;
|
mod concurrency_limiter;
|
||||||
mod config;
|
mod config;
|
||||||
mod constant;
|
mod constant;
|
||||||
// FIXME revert back to the external crate with Cranelift 0.93
|
|
||||||
mod cranelift_native;
|
|
||||||
mod debuginfo;
|
mod debuginfo;
|
||||||
mod discriminant;
|
mod discriminant;
|
||||||
mod driver;
|
mod driver;
|
||||||
@ -251,7 +249,7 @@ fn target_triple(sess: &Session) -> target_lexicon::Triple {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_isa(sess: &Session, backend_config: &BackendConfig) -> Box<dyn isa::TargetIsa + 'static> {
|
fn build_isa(sess: &Session, backend_config: &BackendConfig) -> Arc<dyn isa::TargetIsa + 'static> {
|
||||||
use target_lexicon::BinaryFormat;
|
use target_lexicon::BinaryFormat;
|
||||||
|
|
||||||
let target_triple = crate::target_triple(sess);
|
let target_triple = crate::target_triple(sess);
|
||||||
@ -285,14 +283,17 @@ fn build_isa(sess: &Session, backend_config: &BackendConfig) -> Box<dyn isa::Tar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let target_lexicon::Architecture::Aarch64(_) | target_lexicon::Architecture::X86_64 =
|
if let target_lexicon::Architecture::Aarch64(_)
|
||||||
target_triple.architecture
|
| target_lexicon::Architecture::Riscv64(_)
|
||||||
|
| target_lexicon::Architecture::X86_64 = target_triple.architecture
|
||||||
{
|
{
|
||||||
// Windows depends on stack probes to grow the committed part of the stack
|
// Windows depends on stack probes to grow the committed part of the stack.
|
||||||
|
// On other platforms it helps prevents stack smashing.
|
||||||
flags_builder.enable("enable_probestack").unwrap();
|
flags_builder.enable("enable_probestack").unwrap();
|
||||||
flags_builder.set("probestack_strategy", "inline").unwrap();
|
flags_builder.set("probestack_strategy", "inline").unwrap();
|
||||||
} else {
|
} else {
|
||||||
// __cranelift_probestack is not provided and inline stack probes are only supported on AArch64 and x86_64
|
// __cranelift_probestack is not provided and inline stack probes are only supported on
|
||||||
|
// AArch64, Riscv64 and x86_64.
|
||||||
flags_builder.set("enable_probestack", "false").unwrap();
|
flags_builder.set("enable_probestack", "false").unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ pub(crate) fn maybe_create_entry_wrapper(
|
|||||||
|
|
||||||
if main_def_id.is_local() {
|
if main_def_id.is_local() {
|
||||||
let instance = Instance::mono(tcx, main_def_id).polymorphize(tcx);
|
let instance = Instance::mono(tcx, main_def_id).polymorphize(tcx);
|
||||||
if !is_jit && module.get_name(&*tcx.symbol_name(instance).name).is_none() {
|
if !is_jit && module.get_name(tcx.symbol_name(instance).name).is_none() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if !is_primary_cgu {
|
} else if !is_primary_cgu {
|
||||||
|
@ -347,12 +347,20 @@ pub(crate) fn codegen_float_binop<'tcx>(
|
|||||||
BinOp::Mul => b.fmul(lhs, rhs),
|
BinOp::Mul => b.fmul(lhs, rhs),
|
||||||
BinOp::Div => b.fdiv(lhs, rhs),
|
BinOp::Div => b.fdiv(lhs, rhs),
|
||||||
BinOp::Rem => {
|
BinOp::Rem => {
|
||||||
let name = match in_lhs.layout().ty.kind() {
|
let (name, ty) = match in_lhs.layout().ty.kind() {
|
||||||
ty::Float(FloatTy::F32) => "fmodf",
|
ty::Float(FloatTy::F32) => ("fmodf", types::F32),
|
||||||
ty::Float(FloatTy::F64) => "fmod",
|
ty::Float(FloatTy::F64) => ("fmod", types::F64),
|
||||||
_ => bug!(),
|
_ => bug!(),
|
||||||
};
|
};
|
||||||
return fx.easy_call(name, &[in_lhs, in_rhs], in_lhs.layout().ty);
|
|
||||||
|
let ret_val = fx.lib_call(
|
||||||
|
name,
|
||||||
|
vec![AbiParam::new(ty), AbiParam::new(ty)],
|
||||||
|
vec![AbiParam::new(ty)],
|
||||||
|
&[lhs, rhs],
|
||||||
|
)[0];
|
||||||
|
|
||||||
|
return CValue::by_val(ret_val, in_lhs.layout());
|
||||||
}
|
}
|
||||||
BinOp::Eq | BinOp::Lt | BinOp::Le | BinOp::Ne | BinOp::Ge | BinOp::Gt => {
|
BinOp::Eq | BinOp::Lt | BinOp::Le | BinOp::Ne | BinOp::Ge | BinOp::Gt => {
|
||||||
let fltcc = match bin_op {
|
let fltcc = match bin_op {
|
||||||
|
@ -30,11 +30,6 @@ impl Pointer {
|
|||||||
Pointer { base: PointerBase::Stack(stack_slot), offset: Offset32::new(0) }
|
Pointer { base: PointerBase::Stack(stack_slot), offset: Offset32::new(0) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn const_addr(fx: &mut FunctionCx<'_, '_, '_>, addr: i64) -> Self {
|
|
||||||
let addr = fx.bcx.ins().iconst(fx.pointer_type, addr);
|
|
||||||
Pointer { base: PointerBase::Addr(addr), offset: Offset32::new(0) }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn dangling(align: Align) -> Self {
|
pub(crate) fn dangling(align: Align) -> Self {
|
||||||
Pointer { base: PointerBase::Dangling(align), offset: Offset32::new(0) }
|
Pointer { base: PointerBase::Dangling(align), offset: Offset32::new(0) }
|
||||||
}
|
}
|
||||||
|
@ -245,7 +245,7 @@ pub(crate) fn write_clif_file(
|
|||||||
for flag in isa.flags().iter() {
|
for flag in isa.flags().iter() {
|
||||||
writeln!(file, "set {}", flag)?;
|
writeln!(file, "set {}", flag)?;
|
||||||
}
|
}
|
||||||
write!(file, "target {}", isa.triple().architecture.to_string())?;
|
write!(file, "target {}", isa.triple().architecture)?;
|
||||||
for isa_flag in isa.isa_flags().iter() {
|
for isa_flag in isa.isa_flags().iter() {
|
||||||
write!(file, " {}", isa_flag)?;
|
write!(file, " {}", isa_flag)?;
|
||||||
}
|
}
|
||||||
|
@ -28,9 +28,7 @@ pub(crate) fn unsized_info<'tcx>(
|
|||||||
(
|
(
|
||||||
&ty::Dynamic(ref data_a, _, src_dyn_kind),
|
&ty::Dynamic(ref data_a, _, src_dyn_kind),
|
||||||
&ty::Dynamic(ref data_b, _, target_dyn_kind),
|
&ty::Dynamic(ref data_b, _, target_dyn_kind),
|
||||||
) => {
|
) if src_dyn_kind == target_dyn_kind => {
|
||||||
assert_eq!(src_dyn_kind, target_dyn_kind);
|
|
||||||
|
|
||||||
let old_info =
|
let old_info =
|
||||||
old_info.expect("unsized_info: missing old info for trait upcasting coercion");
|
old_info.expect("unsized_info: missing old info for trait upcasting coercion");
|
||||||
if data_a.principal_def_id() == data_b.principal_def_id() {
|
if data_a.principal_def_id() == data_b.principal_def_id() {
|
||||||
@ -55,7 +53,7 @@ pub(crate) fn unsized_info<'tcx>(
|
|||||||
old_info
|
old_info
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(_, &ty::Dynamic(ref data, ..)) => crate::vtable::get_vtable(fx, source, data.principal()),
|
(_, ty::Dynamic(data, ..)) => crate::vtable::get_vtable(fx, source, data.principal()),
|
||||||
_ => bug!("unsized_info: invalid unsizing {:?} -> {:?}", source, target),
|
_ => bug!("unsized_info: invalid unsizing {:?} -> {:?}", source, target),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
use cranelift_codegen::ir::immediates::Offset32;
|
use cranelift_codegen::ir::immediates::Offset32;
|
||||||
|
use cranelift_codegen::ir::{InstructionData, Opcode};
|
||||||
|
|
||||||
fn codegen_field<'tcx>(
|
fn codegen_field<'tcx>(
|
||||||
fx: &mut FunctionCx<'_, '_, 'tcx>,
|
fx: &mut FunctionCx<'_, '_, 'tcx>,
|
||||||
@ -457,6 +458,7 @@ impl<'tcx> CPlace<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[track_caller]
|
||||||
pub(crate) fn to_ptr(self) -> Pointer {
|
pub(crate) fn to_ptr(self) -> Pointer {
|
||||||
match self.to_ptr_maybe_unsized() {
|
match self.to_ptr_maybe_unsized() {
|
||||||
(ptr, None) => ptr,
|
(ptr, None) => ptr,
|
||||||
@ -464,6 +466,7 @@ impl<'tcx> CPlace<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[track_caller]
|
||||||
pub(crate) fn to_ptr_maybe_unsized(self) -> (Pointer, Option<Value>) {
|
pub(crate) fn to_ptr_maybe_unsized(self) -> (Pointer, Option<Value>) {
|
||||||
match self.inner {
|
match self.inner {
|
||||||
CPlaceInner::Addr(ptr, extra) => (ptr, extra),
|
CPlaceInner::Addr(ptr, extra) => (ptr, extra),
|
||||||
@ -787,7 +790,36 @@ impl<'tcx> CPlace<'tcx> {
|
|||||||
index: Value,
|
index: Value,
|
||||||
) -> CPlace<'tcx> {
|
) -> CPlace<'tcx> {
|
||||||
let (elem_layout, ptr) = match self.layout().ty.kind() {
|
let (elem_layout, ptr) = match self.layout().ty.kind() {
|
||||||
ty::Array(elem_ty, _) => (fx.layout_of(*elem_ty), self.to_ptr()),
|
ty::Array(elem_ty, _) => {
|
||||||
|
let elem_layout = fx.layout_of(*elem_ty);
|
||||||
|
match self.inner {
|
||||||
|
CPlaceInner::Var(local, var) => {
|
||||||
|
// This is a hack to handle `vector_val.0[1]`. It doesn't allow dynamic
|
||||||
|
// indexing.
|
||||||
|
let lane_idx = match fx.bcx.func.dfg.insts
|
||||||
|
[fx.bcx.func.dfg.value_def(index).unwrap_inst()]
|
||||||
|
{
|
||||||
|
InstructionData::UnaryImm { opcode: Opcode::Iconst, imm } => imm,
|
||||||
|
_ => bug!(
|
||||||
|
"Dynamic indexing into a vector type is not supported: {self:?}[{index}]"
|
||||||
|
),
|
||||||
|
};
|
||||||
|
return CPlace {
|
||||||
|
inner: CPlaceInner::VarLane(
|
||||||
|
local,
|
||||||
|
var,
|
||||||
|
lane_idx.bits().try_into().unwrap(),
|
||||||
|
),
|
||||||
|
layout: elem_layout,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
CPlaceInner::Addr(addr, None) => (elem_layout, addr),
|
||||||
|
CPlaceInner::Addr(_, Some(_))
|
||||||
|
| CPlaceInner::VarPair(_, _, _)
|
||||||
|
| CPlaceInner::VarLane(_, _, _) => bug!("Can't index into {self:?}"),
|
||||||
|
}
|
||||||
|
// FIXME use VarLane in case of Var with simd type
|
||||||
|
}
|
||||||
ty::Slice(elem_ty) => (fx.layout_of(*elem_ty), self.to_ptr_maybe_unsized().0),
|
ty::Slice(elem_ty) => (fx.layout_of(*elem_ty), self.to_ptr_maybe_unsized().0),
|
||||||
_ => bug!("place_index({:?})", self.layout().ty),
|
_ => bug!("place_index({:?})", self.layout().ty),
|
||||||
};
|
};
|
||||||
|
@ -43,10 +43,29 @@ pub(crate) fn min_align_of_obj(fx: &mut FunctionCx<'_, '_, '_>, vtable: Value) -
|
|||||||
|
|
||||||
pub(crate) fn get_ptr_and_method_ref<'tcx>(
|
pub(crate) fn get_ptr_and_method_ref<'tcx>(
|
||||||
fx: &mut FunctionCx<'_, '_, 'tcx>,
|
fx: &mut FunctionCx<'_, '_, 'tcx>,
|
||||||
arg: CValue<'tcx>,
|
mut arg: CValue<'tcx>,
|
||||||
idx: usize,
|
idx: usize,
|
||||||
) -> (Pointer, Value) {
|
) -> (Pointer, Value) {
|
||||||
let (ptr, vtable) = 'block: {
|
let (ptr, vtable) = 'block: {
|
||||||
|
if let Abi::Scalar(_) = arg.layout().abi {
|
||||||
|
'descend_newtypes: while !arg.layout().ty.is_unsafe_ptr()
|
||||||
|
&& !arg.layout().ty.is_region_ptr()
|
||||||
|
{
|
||||||
|
for i in 0..arg.layout().fields.count() {
|
||||||
|
let field = arg.value_field(fx, mir::Field::new(i));
|
||||||
|
if !field.layout().is_zst() {
|
||||||
|
// we found the one non-zero-sized field that is allowed
|
||||||
|
// now find *its* non-zero-sized field, or stop if it's a
|
||||||
|
// pointer
|
||||||
|
arg = field;
|
||||||
|
continue 'descend_newtypes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bug!("receiver has no non-zero-sized fields {:?}", arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let ty::Ref(_, ty, _) = arg.layout().ty.kind() {
|
if let ty::Ref(_, ty, _) = arg.layout().ty.kind() {
|
||||||
if ty.is_dyn_star() {
|
if ty.is_dyn_star() {
|
||||||
let inner_layout = fx.layout_of(arg.layout().ty.builtin_deref(true).unwrap().ty);
|
let inner_layout = fx.layout_of(arg.layout().ty.builtin_deref(true).unwrap().ty);
|
||||||
|
Loading…
Reference in New Issue
Block a user