Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to LLVM 14 #93577

Merged
merged 8 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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",
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 @@ -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", "");
}
Expand All @@ -145,6 +146,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 @@ -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")
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