From 37c7638e13180c6bdfe3883643277d5b81998f70 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 17 Jan 2024 14:50:32 +0100 Subject: [PATCH 1/5] Update to LLVM 18 --- src/llvm-project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llvm-project b/src/llvm-project index 700fbf978e6c5..43607c5b87f46 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 700fbf978e6c5bb297d12963206f7487722de480 +Subproject commit 43607c5b87f464218cf3a18843d64d4c0f9c421a From 4efaa09684548226bf24cced4b982f0b6d94f25e Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 17 Jan 2024 15:05:18 +0100 Subject: [PATCH 2/5] Use MCSubtargetInfo::getAllProcessorFeatures() This method is now available in upstream LLVM \o/ --- .gitmodules | 4 ++-- compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitmodules b/.gitmodules index 9bb68b37081f5..69f0bc9e082ad 100644 --- a/.gitmodules +++ b/.gitmodules @@ -32,8 +32,8 @@ shallow = true [submodule "src/llvm-project"] path = src/llvm-project - url = https://github.com/rust-lang/llvm-project.git - branch = rustc/17.0-2023-12-14 + url = https://github.com/nikic/llvm-project.git + branch = rust-llvm-18 shallow = true [submodule "src/doc/embedded-book"] path = src/doc/embedded-book diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index 6114f7c867807..44f103609e3a7 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -368,10 +368,10 @@ extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM, } extern "C" size_t LLVMRustGetTargetFeaturesCount(LLVMTargetMachineRef TM) { -#ifdef LLVM_RUSTLLVM +#if LLVM_VERSION_GE(18, 0) const TargetMachine *Target = unwrap(TM); const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo(); - const ArrayRef FeatTable = MCInfo->getFeatureTable(); + const ArrayRef FeatTable = MCInfo->getAllProcessorFeatures(); return FeatTable.size(); #else return 0; @@ -380,10 +380,10 @@ extern "C" size_t LLVMRustGetTargetFeaturesCount(LLVMTargetMachineRef TM) { extern "C" void LLVMRustGetTargetFeature(LLVMTargetMachineRef TM, size_t Index, const char** Feature, const char** Desc) { -#ifdef LLVM_RUSTLLVM +#if LLVM_VERSION_GE(18, 0) const TargetMachine *Target = unwrap(TM); const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo(); - const ArrayRef FeatTable = MCInfo->getFeatureTable(); + const ArrayRef FeatTable = MCInfo->getAllProcessorFeatures(); const SubtargetFeatureKV Feat = FeatTable[Index]; *Feature = Feat.Key; *Desc = Feat.Desc; From f4670650105418f24fecbc79d563b110fd4577b3 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 22 Jan 2024 12:59:41 +0100 Subject: [PATCH 3/5] Use patched compiler-builtins --- Cargo.lock | 5 ++--- Cargo.toml | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 74f96983b3149..c44279853a121 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -723,9 +723,8 @@ checksum = "55b672471b4e9f9e95499ea597ff64941a309b2cdbffcc46f2cc5e2d971fd335" [[package]] name = "compiler_builtins" -version = "0.1.105" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3686cc48897ce1950aa70fd595bd2dc9f767a3c4cca4cd17b2cb52a2d37e6eb4" +version = "0.1.106" +source = "git+https://github.com/nikic/compiler-builtins.git?branch=cpu-model-moved#ae3ba6e1b9ec6cacb0c4aad7e1e6d76481265bf9" dependencies = [ "cc", "rustc-std-workspace-core", diff --git a/Cargo.toml b/Cargo.toml index 2ea16c2266615..38fd8417b0900 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -119,5 +119,7 @@ rustc-std-workspace-core = { path = 'library/rustc-std-workspace-core' } rustc-std-workspace-alloc = { path = 'library/rustc-std-workspace-alloc' } rustc-std-workspace-std = { path = 'library/rustc-std-workspace-std' } +compiler_builtins = { git = "https://github.com/nikic/compiler-builtins.git", branch = "cpu-model-moved" } + [patch."https://github.com/rust-lang/rust-clippy"] clippy_lints = { path = "src/tools/clippy/clippy_lints" } From 89bd18424aa80277a394aabd9749b91e9152f692 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 26 Jan 2024 14:46:17 +0100 Subject: [PATCH 4/5] Update codegen test for LLVM 18 --- tests/codegen/pow_of_two.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/codegen/pow_of_two.rs b/tests/codegen/pow_of_two.rs index a8c0550e33263..372360dfd12c7 100644 --- a/tests/codegen/pow_of_two.rs +++ b/tests/codegen/pow_of_two.rs @@ -4,7 +4,7 @@ #[no_mangle] pub fn a(exp: u32) -> u64 { // CHECK: %{{[^ ]+}} = icmp ugt i32 %exp, 64 - // CHECK: %{{[^ ]+}} = zext i32 %exp to i64 + // CHECK: %{{[^ ]+}} = zext{{( nneg)?}} i32 %exp to i64 // CHECK: %{{[^ ]+}} = shl nuw i64 {{[^ ]+}}, %{{[^ ]+}} // CHECK: ret i64 %{{[^ ]+}} 2u64.pow(exp) @@ -14,7 +14,7 @@ pub fn a(exp: u32) -> u64 { #[no_mangle] pub fn b(exp: u32) -> i64 { // CHECK: %{{[^ ]+}} = icmp ugt i32 %exp, 64 - // CHECK: %{{[^ ]+}} = zext i32 %exp to i64 + // CHECK: %{{[^ ]+}} = zext{{( nneg)?}} i32 %exp to i64 // CHECK: %{{[^ ]+}} = shl nuw i64 {{[^ ]+}}, %{{[^ ]+}} // CHECK: ret i64 %{{[^ ]+}} 2i64.pow(exp) From c57f99efe81e32b29e93582f4c322e25edbc21af Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 26 Jan 2024 15:12:39 +0100 Subject: [PATCH 5/5] [do not merge] run msvc/mingw jobs on try --- .github/workflows/ci.yml | 26 +++++++++++++++++++++++--- src/ci/github-actions/ci.yml | 35 +++++++++++++++++++++++++++++++---- 2 files changed, 54 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index caf97abf78d9e..11a43c0cdadd9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -567,10 +567,30 @@ jobs: strategy: matrix: include: - - name: dist-x86_64-linux + - name: x86_64-msvc env: - CODEGEN_BACKENDS: "llvm,cranelift" - os: ubuntu-20.04-16core-64gb + RUST_CONFIGURE_ARGS: "--build=x86_64-pc-windows-msvc --enable-profiler" + SCRIPT: make ci-msvc + os: windows-2019-8core-32gb + - name: i686-msvc + env: + RUST_CONFIGURE_ARGS: "--build=i686-pc-windows-msvc" + SCRIPT: make ci-msvc + os: windows-2019-8core-32gb + - name: i686-mingw + env: + RUST_CONFIGURE_ARGS: "--build=i686-pc-windows-gnu" + SCRIPT: make ci-mingw + NO_DOWNLOAD_CI_LLVM: 1 + CUSTOM_MINGW: 1 + os: windows-2019-8core-32gb + - name: x86_64-mingw + env: + SCRIPT: make ci-mingw + RUST_CONFIGURE_ARGS: "--build=x86_64-pc-windows-gnu --enable-profiler" + NO_DOWNLOAD_CI_LLVM: 1 + CUSTOM_MINGW: 1 + os: windows-2019-8core-32gb timeout-minutes: 600 runs-on: "${{ matrix.os }}" steps: diff --git a/src/ci/github-actions/ci.yml b/src/ci/github-actions/ci.yml index 68a3afc910f22..3a33f82803f2a 100644 --- a/src/ci/github-actions/ci.yml +++ b/src/ci/github-actions/ci.yml @@ -724,12 +724,39 @@ jobs: strategy: matrix: include: - - &dist-x86_64-linux - name: dist-x86_64-linux + - name: x86_64-msvc env: - CODEGEN_BACKENDS: llvm,cranelift - <<: *job-linux-16c + RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc --enable-profiler + SCRIPT: make ci-msvc + <<: *job-windows-8c + + - name: i686-msvc + env: + RUST_CONFIGURE_ARGS: --build=i686-pc-windows-msvc + SCRIPT: make ci-msvc + <<: *job-windows-8c + - name: i686-mingw + env: + RUST_CONFIGURE_ARGS: --build=i686-pc-windows-gnu + SCRIPT: make ci-mingw + # We are intentionally allowing an old toolchain on this builder (and that's + # incompatible with LLVM downloads today). + NO_DOWNLOAD_CI_LLVM: 1 + CUSTOM_MINGW: 1 + <<: *job-windows-8c + + - name: x86_64-mingw + env: + SCRIPT: make ci-mingw + RUST_CONFIGURE_ARGS: >- + --build=x86_64-pc-windows-gnu + --enable-profiler + # We are intentionally allowing an old toolchain on this builder (and that's + # incompatible with LLVM downloads today). + NO_DOWNLOAD_CI_LLVM: 1 + CUSTOM_MINGW: 1 + <<: *job-windows-8c master: name: master