From 599a03c9b590aea4f5be933f56bf6c254794e105 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 2 Feb 2022 09:35:11 +0100 Subject: [PATCH 1/8] Update LLVM submodule --- .gitmodules | 2 +- src/llvm-project | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index c60a0dd2c7c43..9f54ed5bdab6d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -34,7 +34,7 @@ [submodule "src/llvm-project"] path = src/llvm-project url = https://github.com/rust-lang/llvm-project.git - branch = rustc/13.0-2021-09-30 + branch = rustc/14.0-2022-02-09 [submodule "src/doc/embedded-book"] path = src/doc/embedded-book url = https://github.com/rust-embedded/book.git diff --git a/src/llvm-project b/src/llvm-project index fdc8f411ec925..e29ac13bc97e2 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit fdc8f411ec9253d4eeb7a572b058be4f2131fd1c +Subproject commit e29ac13bc97e26f886c3bfe72f9135e994c3cd0a From f34914141ed23d6b21638ee5792ac21c301ca3f2 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 2 Feb 2022 09:53:45 +0100 Subject: [PATCH 2/8] Update optimization remark test for LLVM 14 The format of the remark changed slightly. --- src/test/ui/optimization-remark.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/ui/optimization-remark.rs b/src/test/ui/optimization-remark.rs index 36549cbc554bf..d4b39c670162d 100644 --- a/src/test/ui/optimization-remark.rs +++ b/src/test/ui/optimization-remark.rs @@ -1,6 +1,6 @@ // build-pass // ignore-pass -// no-system-llvm +// min-llvm-version: 14.0.0 // revisions: all inline merge1 merge2 // compile-flags: --crate-type=lib -Cdebuginfo=1 -Copt-level=2 // @@ -14,7 +14,7 @@ // [merge1] compile-flags: -Cremark=all -Cremark=giraffe // [merge2] compile-flags: -Cremark=inline -Cremark=giraffe // -// error-pattern: inline: f not inlined into g +// error-pattern: inline: 'f' not inlined into 'g' // dont-check-compiler-stderr #[no_mangle] From a380581ff87bc095aa0d69993104d3a363dfb327 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 2 Feb 2022 10:01:02 +0100 Subject: [PATCH 3/8] Update data layout for 32-bit msvc targets https://reviews.llvm.org/D115942 changed the alignment of f80. --- compiler/rustc_codegen_llvm/src/context.rs | 12 +++++++++++- .../rustc_target/src/spec/i686_pc_windows_msvc.rs | 2 +- .../rustc_target/src/spec/i686_uwp_windows_msvc.rs | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs index 8672459b5da3a..eaa76d4ffb6e4 100644 --- a/compiler/rustc_codegen_llvm/src/context.rs +++ b/compiler/rustc_codegen_llvm/src/context.rs @@ -134,7 +134,8 @@ pub unsafe fn create_module<'ll>( let llmod = llvm::LLVMModuleCreateWithNameInContext(mod_name.as_ptr(), llcx); let mut target_data_layout = sess.target.data_layout.clone(); - if llvm_util::get_version() < (13, 0, 0) { + let llvm_version = llvm_util::get_version(); + if llvm_version < (13, 0, 0) { if sess.target.arch == "powerpc64" { target_data_layout = target_data_layout.replace("-S128", ""); } @@ -145,6 +146,15 @@ pub unsafe fn create_module<'ll>( target_data_layout = "e-m:e-p:64:64-i64:64-n32:64-S128".to_string(); } } + if llvm_version < (14, 0, 0) { + if sess.target.llvm_target == "i686-pc-windows-msvc" + || sess.target.llvm_target == "i586-pc-windows-msvc" + { + target_data_layout = + "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:32-n8:16:32-a:0:32-S32" + .to_string(); + } + } // Ensure the data-layout values hardcoded remain the defaults. if sess.target.is_builtin { diff --git a/compiler/rustc_target/src/spec/i686_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/i686_pc_windows_msvc.rs index 74074cfb5dda1..174294895bf7a 100644 --- a/compiler/rustc_target/src/spec/i686_pc_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/i686_pc_windows_msvc.rs @@ -24,7 +24,7 @@ pub fn target() -> Target { llvm_target: "i686-pc-windows-msvc".to_string(), pointer_width: 32, data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ - i64:64-f80:32-n8:16:32-a:0:32-S32" + i64:64-f80:128-n8:16:32-a:0:32-S32" .to_string(), arch: "x86".to_string(), options: base, diff --git a/compiler/rustc_target/src/spec/i686_uwp_windows_msvc.rs b/compiler/rustc_target/src/spec/i686_uwp_windows_msvc.rs index 05f204c560446..e2f65e7a7c938 100644 --- a/compiler/rustc_target/src/spec/i686_uwp_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/i686_uwp_windows_msvc.rs @@ -9,7 +9,7 @@ pub fn target() -> Target { llvm_target: "i686-pc-windows-msvc".to_string(), pointer_width: 32, data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ - i64:64-f80:32-n8:16:32-a:0:32-S32" + i64:64-f80:128-n8:16:32-a:0:32-S32" .to_string(), arch: "x86".to_string(), options: base, From 70ddd2ff1cbd2bdb887a1052877cfb666a6d92b8 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 2 Feb 2022 10:16:48 +0100 Subject: [PATCH 4/8] Update data layout for wasm32 targets New address spaces were added in https://reviews.llvm.org/D111154. --- compiler/rustc_codegen_llvm/src/context.rs | 3 +++ compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs | 3 ++- compiler/rustc_target/src/spec/wasm32_unknown_unknown.rs | 2 +- compiler/rustc_target/src/spec/wasm32_wasi.rs | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs index eaa76d4ffb6e4..f8e2d202e660a 100644 --- a/compiler/rustc_codegen_llvm/src/context.rs +++ b/compiler/rustc_codegen_llvm/src/context.rs @@ -154,6 +154,9 @@ pub unsafe fn create_module<'ll>( "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:32-n8:16:32-a:0:32-S32" .to_string(); } + if sess.target.arch == "wasm32" { + target_data_layout = target_data_layout.replace("-p10:8:8-p20:8:8", ""); + } } // Ensure the data-layout values hardcoded remain the defaults. diff --git a/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs b/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs index 69a404ec564e2..8fcdbc146af93 100644 --- a/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs +++ b/compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs @@ -43,7 +43,8 @@ pub fn target() -> Target { Target { llvm_target: "wasm32-unknown-emscripten".to_string(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-i64:64-f128:64-n32:64-S128-ni:1:10:20".to_string(), + data_layout: "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20" + .to_string(), arch: "wasm32".to_string(), options: opts, } diff --git a/compiler/rustc_target/src/spec/wasm32_unknown_unknown.rs b/compiler/rustc_target/src/spec/wasm32_unknown_unknown.rs index 134c6803b15d1..e50cf97409475 100644 --- a/compiler/rustc_target/src/spec/wasm32_unknown_unknown.rs +++ b/compiler/rustc_target/src/spec/wasm32_unknown_unknown.rs @@ -54,7 +54,7 @@ pub fn target() -> Target { Target { llvm_target: "wasm32-unknown-unknown".to_string(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-i64:64-n32:64-S128-ni:1:10:20".to_string(), + data_layout: "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20".to_string(), arch: "wasm32".to_string(), options, } diff --git a/compiler/rustc_target/src/spec/wasm32_wasi.rs b/compiler/rustc_target/src/spec/wasm32_wasi.rs index 2dab206dc7602..a4b81c9a2788f 100644 --- a/compiler/rustc_target/src/spec/wasm32_wasi.rs +++ b/compiler/rustc_target/src/spec/wasm32_wasi.rs @@ -109,7 +109,7 @@ pub fn target() -> Target { Target { llvm_target: "wasm32-wasi".to_string(), pointer_width: 32, - data_layout: "e-m:e-p:32:32-i64:64-n32:64-S128-ni:1:10:20".to_string(), + data_layout: "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20".to_string(), arch: "wasm32".to_string(), options, } From 827595078648abdf310a27bb271eb23ba66aea3e Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 2 Feb 2022 10:48:42 +0100 Subject: [PATCH 5/8] Update coverage IR test --- .../run-make-fulldeps/coverage-llvmir/filecheck.testprog.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/run-make-fulldeps/coverage-llvmir/filecheck.testprog.txt b/src/test/run-make-fulldeps/coverage-llvmir/filecheck.testprog.txt index 1e2ecc2fbb1cc..84e67e53ea4c6 100644 --- a/src/test/run-make-fulldeps/coverage-llvmir/filecheck.testprog.txt +++ b/src/test/run-make-fulldeps/coverage-llvmir/filecheck.testprog.txt @@ -15,14 +15,14 @@ CHECK: @__profc__R{{[a-zA-Z0-9_]+}}testprog14will_be_called = {{private|i CHECK-SAME: section "[[INSTR_PROF_CNTS]]"{{.*}}, align 8 CHECK: @__profd__R{{[a-zA-Z0-9_]+}}testprog14will_be_called = {{private|internal}} global -CHECK-SAME: @__profc__R{{[a-zA-Z0-9_]+}}testprog14will_be_called, +CHECK-SAME: @__profc__R{{[a-zA-Z0-9_]+}}testprog14will_be_called CHECK-SAME: section "[[INSTR_PROF_DATA]]"{{.*}}, align 8 CHECK: @__profc__R{{[a-zA-Z0-9_]+}}testprog4main = {{private|internal}} global CHECK-SAME: section "[[INSTR_PROF_CNTS]]"{{.*}}, align 8 CHECK: @__profd__R{{[a-zA-Z0-9_]+}}testprog4main = {{private|internal}} global -CHECK-SAME: @__profc__R{{[a-zA-Z0-9_]+}}testprog4main, +CHECK-SAME: @__profc__R{{[a-zA-Z0-9_]+}}testprog4main CHECK-SAME: section "[[INSTR_PROF_DATA]]"{{.*}}, align 8 CHECK: @__llvm_prf_nm = private constant From 200aa5c713c7dd4ada2d136fcb72b8d60f92dc9d Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 9 Feb 2022 17:44:56 +0100 Subject: [PATCH 6/8] Add cmake directory to llvm source distribution This directory is required for building LLVM now. --- src/bootstrap/dist.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 66b63cd1278c5..b1d53fdcef3c2 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -753,6 +753,8 @@ fn copy_src_dirs( "llvm-project\\llvm", "llvm-project/compiler-rt", "llvm-project\\compiler-rt", + "llvm-project/cmake", + "llvm-project\\cmake", ]; if spath.contains("llvm-project") && !spath.ends_with("llvm-project") From 0605a4122f519364d67d3ef5ff1726c5faae32cc Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 15 Feb 2022 15:22:13 +0100 Subject: [PATCH 7/8] Expose unstable llvm14-builtins-abi target feature for cfg use --- compiler/rustc_codegen_llvm/src/llvm_util.rs | 40 ++++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index 727d079d83d93..b1c14c7e44bd0 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -217,24 +217,32 @@ pub fn check_tied_features( pub fn target_features(sess: &Session) -> Vec { let target_machine = create_informational_target_machine(sess); - supported_target_features(sess) - .iter() - .filter_map( - |&(feature, gate)| { + let mut features: Vec = + supported_target_features(sess) + .iter() + .filter_map(|&(feature, gate)| { if sess.is_nightly_build() || gate.is_none() { Some(feature) } else { None } - }, - ) - .filter(|feature| { - for llvm_feature in to_llvm_feature(sess, feature) { - let cstr = CString::new(llvm_feature).unwrap(); - if unsafe { llvm::LLVMRustHasFeature(target_machine, cstr.as_ptr()) } { - return true; + }) + .filter(|feature| { + for llvm_feature in to_llvm_feature(sess, feature) { + let cstr = CString::new(llvm_feature).unwrap(); + if unsafe { llvm::LLVMRustHasFeature(target_machine, cstr.as_ptr()) } { + return true; + } } - } - false - }) - .map(|feature| Symbol::intern(feature)) - .collect() + false + }) + .map(|feature| Symbol::intern(feature)) + .collect(); + + // LLVM 14 changed the ABI for i128 arguments to __float/__fix builtins on Win64 + // (see https://reviews.llvm.org/D110413). This unstable target feature is intended for use + // by compiler-builtins, to export the builtins with the expected, LLVM-version-dependent ABI. + // The target feature can be dropped once we no longer support older LLVM versions. + if sess.is_nightly_build() && get_version() >= (14, 0, 0) { + features.push(Symbol::intern("llvm14-builtins-abi")); + } + features } pub fn print_version() { From 75636bb6cf09c03742e62ba680abf9376ab0d321 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 16 Feb 2022 09:22:44 +0100 Subject: [PATCH 8/8] Update compiler-builtins to 0.1.70 This pulls in https://github.com/rust-lang/compiler-builtins/pull/455, which exports __float/__fix builtins with the expected Win64 ABI on LLVM 14. --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dc480d82f2fd8..6c78924df2c00 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -741,9 +741,9 @@ dependencies = [ [[package]] name = "compiler_builtins" -version = "0.1.69" +version = "0.1.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac0d1d6b2307c15fd27af2bb41234b4ebddeae69f33714bfbdb44b3b5a6e3efe" +checksum = "80873f979f0a344a4ade87c2f70d9ccf5720b83b10c97ec7cd745895d021e85a" dependencies = [ "cc", "rustc-std-workspace-core",