Skip to content

Commit

Permalink
Auto merge of #93577 - nikic:llvm-14, r=nagisa
Browse files Browse the repository at this point in the history
Upgrade to LLVM 14

LLVM patch state:
 * [x] llvm/llvm-project@a55727f Backported.
 * [x] rust-lang/llvm-project@c3c82dc Backported as llvm/llvm-project@917c47b.
 * [x] rust-lang/llvm-project@6e8f9ab No plan to upstream.
 * [x] llvm/llvm-project@319f4b2 Backported.
 * [x] rust-lang/llvm-project@8b2c25d No plan to upstream.
 * [x] rust-lang/llvm-project@75fef2e No plan to upstream.
 * [ ] rust-lang/llvm-project@adef757 Upstreamed as llvm/llvm-project@2d2ef38. Needs backport.
 * [x] rust-lang/llvm-project@4b7c1b4 No plan to upstream.
 * [x] rust-lang/llvm-project@3f5ab0c No plan to upstream.
 * [x] rust-lang/llvm-project@514d055 No plan to upstream.
 * [ ] rust-lang/llvm-project@54c5869 Under review at https://reviews.llvm.org/D119695 and https://reviews.llvm.org/D119856.

Release timeline:
 * LLVM 14.0.0 final planned for Mar 15.
 * Rust 1.60.0 planned for Apr 7.

Compile-time:
  * https://perf.rust-lang.org/compare.html?start=250384edc5d78533e993f38c60d64e42b21684b2&end=b87df8d2c7c5d9ac448c585de10927ab2ee1b864
  * A slight improvement on average, though no big changes either way.
  * There are some larger max-rss improvements.

r? `@ghost`
  • Loading branch information
bors committed Feb 17, 2022
2 parents 582b696 + 75636bb commit 30b3f35
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -740,9 +740,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",
Expand Down
15 changes: 14 additions & 1 deletion compiler/rustc_codegen_llvm/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,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", "");
}
Expand All @@ -146,6 +147,18 @@ 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();
}
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.
if sess.target.is_builtin {
Expand Down
40 changes: 24 additions & 16 deletions compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,24 +217,32 @@ pub fn check_tied_features(

pub fn target_features(sess: &Session) -> Vec<Symbol> {
let target_machine = create_informational_target_machine(sess);
supported_target_features(sess)
.iter()
.filter_map(
|&(feature, gate)| {
let mut features: Vec<Symbol> =
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() {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/i686_pc_windows_msvc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/i686_uwp_windows_msvc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_target/src/spec/wasm32_unknown_emscripten.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/wasm32_unknown_unknown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/wasm32_wasi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,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")
Expand Down
2 changes: 1 addition & 1 deletion src/llvm-project
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/optimization-remark.rs
Original file line number Diff line number Diff line change
@@ -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
//
Expand All @@ -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]
Expand Down

0 comments on commit 30b3f35

Please sign in to comment.