Skip to content

Commit a06aaa4

Browse files
committed
Update the minimum external LLVM to 14
1 parent 2773383 commit a06aaa4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+54
-205
lines changed

.github/workflows/ci.yml

+2-6
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
tidy: true
5555
os: ubuntu-20.04-xl
5656
env: {}
57-
- name: x86_64-gnu-llvm-13
57+
- name: x86_64-gnu-llvm-14
5858
tidy: false
5959
os: ubuntu-20.04-xl
6060
env: {}
@@ -300,11 +300,7 @@ jobs:
300300
env:
301301
RUST_BACKTRACE: 1
302302
os: ubuntu-20.04-xl
303-
- name: x86_64-gnu-llvm-13
304-
env:
305-
RUST_BACKTRACE: 1
306-
os: ubuntu-20.04-xl
307-
- name: x86_64-gnu-llvm-13-stage1
303+
- name: x86_64-gnu-llvm-14-stage1
308304
env:
309305
RUST_BACKTRACE: 1
310306
os: ubuntu-20.04-xl

compiler/rustc_codegen_llvm/src/consts.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use crate::common::{self, CodegenCx};
33
use crate::debuginfo;
44
use crate::errors::{InvalidMinimumAlignment, SymbolAlreadyDefined};
55
use crate::llvm::{self, True};
6-
use crate::llvm_util;
76
use crate::type_::Type;
87
use crate::type_of::LayoutLlvmExt;
98
use crate::value::Value;
@@ -56,13 +55,7 @@ pub fn const_alloc_to_llvm<'ll>(cx: &CodegenCx<'ll, '_>, alloc: ConstAllocation<
5655
// to avoid the cost of generating large complex const expressions.
5756
// For example, `[(u32, u8); 1024 * 1024]` contains uninit padding in each element,
5857
// and would result in `{ [5 x i8] zeroinitializer, [3 x i8] undef, ...repeat 1M times... }`.
59-
let max = if llvm_util::get_version() < (14, 0, 0) {
60-
// Generating partially-uninit consts inhibits optimizations in LLVM < 14.
61-
// See https://github.com/rust-lang/rust/issues/84565.
62-
1
63-
} else {
64-
cx.sess().opts.unstable_opts.uninit_const_chunk_threshold
65-
};
58+
let max = cx.sess().opts.unstable_opts.uninit_const_chunk_threshold;
6659
let allow_uninit_chunks = chunks.clone().take(max.saturating_add(1)).count() <= max;
6760

6861
if allow_uninit_chunks {

compiler/rustc_codegen_llvm/src/context.rs

-11
Original file line numberDiff line numberDiff line change
@@ -143,17 +143,6 @@ pub unsafe fn create_module<'ll>(
143143

144144
let mut target_data_layout = sess.target.data_layout.to_string();
145145
let llvm_version = llvm_util::get_version();
146-
if llvm_version < (14, 0, 0) {
147-
if sess.target.llvm_target == "i686-pc-windows-msvc"
148-
|| sess.target.llvm_target == "i586-pc-windows-msvc"
149-
{
150-
target_data_layout =
151-
"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"
152-
.to_string();
153-
} else if sess.target.arch == "wasm32" {
154-
target_data_layout = target_data_layout.replace("-p10:8:8-p20:8:8", "");
155-
}
156-
}
157146
if llvm_version < (16, 0, 0) {
158147
if sess.target.arch == "s390x" {
159148
target_data_layout = target_data_layout.replace("-v128:64", "");

compiler/rustc_codegen_llvm/src/llvm_util.rs

+2-13
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,7 @@ pub fn time_trace_profiler_finish(file_name: &Path) {
152152
pub fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> SmallVec<[&'a str; 2]> {
153153
let arch = if sess.target.arch == "x86_64" { "x86" } else { &*sess.target.arch };
154154
match (arch, s) {
155-
("x86", "sse4.2") => {
156-
if get_version() >= (14, 0, 0) {
157-
smallvec!["sse4.2", "crc32"]
158-
} else {
159-
smallvec!["sse4.2"]
160-
}
161-
}
155+
("x86", "sse4.2") => smallvec!["sse4.2", "crc32"],
162156
("x86", "pclmulqdq") => smallvec!["pclmul"],
163157
("x86", "rdrand") => smallvec!["rdrnd"],
164158
("x86", "bmi1") => smallvec!["bmi"],
@@ -243,7 +237,7 @@ pub fn target_features(sess: &Session, allow_unstable: bool) -> Vec<Symbol> {
243237
// (see https://reviews.llvm.org/D110413). This unstable target feature is intended for use
244238
// by compiler-builtins, to export the builtins with the expected, LLVM-version-dependent ABI.
245239
// The target feature can be dropped once we no longer support older LLVM versions.
246-
if sess.is_nightly_build() && get_version() >= (14, 0, 0) {
240+
if sess.is_nightly_build() {
247241
features.push(Symbol::intern("llvm14-builtins-abi"));
248242
}
249243
features
@@ -494,11 +488,6 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec<Str
494488
.flatten();
495489
features.extend(feats);
496490

497-
// FIXME: Move v8a to target definition list when earliest supported LLVM is 14.
498-
if get_version() >= (14, 0, 0) && sess.target.arch == "aarch64" {
499-
features.push("+v8a".into());
500-
}
501-
502491
if diagnostics && let Some(f) = check_tied_features(sess, &featsmap) {
503492
sess.emit_err(TargetFeatureDisableOrEnable {
504493
features: f,

compiler/rustc_codegen_llvm/src/type_of.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::common::*;
22
use crate::context::TypeLowering;
3-
use crate::llvm_util::get_version;
43
use crate::type_::Type;
54
use rustc_codegen_ssa::traits::*;
65
use rustc_middle::bug;
@@ -43,10 +42,8 @@ fn uncached_llvm_type<'a, 'tcx>(
4342
// in problematically distinct types due to HRTB and subtyping (see #47638).
4443
// ty::Dynamic(..) |
4544
ty::Adt(..) | ty::Closure(..) | ty::Foreign(..) | ty::Generator(..) | ty::Str
46-
// For performance reasons we use names only when emitting LLVM IR. Unless we are on
47-
// LLVM < 14, where the use of unnamed types resulted in various issues, e.g., #76213,
48-
// #79564, and #79246.
49-
if get_version() < (14, 0, 0) || !cx.sess().fewer_names() =>
45+
// For performance reasons we use names only when emitting LLVM IR.
46+
if !cx.sess().fewer_names() =>
5047
{
5148
let mut name = with_no_visible_paths!(with_no_trimmed_paths!(layout.ty.to_string()));
5249
if let (&ty::Adt(def, _), &Variants::Single { index }) =

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

+3-41
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "llvm/IR/AssemblyAnnotationWriter.h"
1515
#include "llvm/IR/IntrinsicInst.h"
1616
#include "llvm/IR/Verifier.h"
17+
#include "llvm/MC/TargetRegistry.h"
1718
#include "llvm/Object/ObjectFile.h"
1819
#include "llvm/Object/IRObjectFile.h"
1920
#include "llvm/Passes/PassBuilder.h"
@@ -25,11 +26,6 @@
2526
#include "llvm/Support/VirtualFileSystem.h"
2627
#endif
2728
#include "llvm/Support/Host.h"
28-
#if LLVM_VERSION_LT(14, 0)
29-
#include "llvm/Support/TargetRegistry.h"
30-
#else
31-
#include "llvm/MC/TargetRegistry.h"
32-
#endif
3329
#include "llvm/Target/TargetMachine.h"
3430
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
3531
#include "llvm/Transforms/IPO/AlwaysInliner.h"
@@ -267,10 +263,6 @@ enum class LLVMRustPassBuilderOptLevel {
267263
Oz,
268264
};
269265

270-
#if LLVM_VERSION_LT(14,0)
271-
using OptimizationLevel = PassBuilder::OptimizationLevel;
272-
#endif
273-
274266
static OptimizationLevel fromRust(LLVMRustPassBuilderOptLevel Level) {
275267
switch (Level) {
276268
case LLVMRustPassBuilderOptLevel::O0:
@@ -747,27 +739,18 @@ LLVMRustOptimize(
747739

748740
if (SanitizerOptions) {
749741
if (SanitizerOptions->SanitizeMemory) {
750-
#if LLVM_VERSION_GE(14, 0)
751742
MemorySanitizerOptions Options(
752743
SanitizerOptions->SanitizeMemoryTrackOrigins,
753744
SanitizerOptions->SanitizeMemoryRecover,
754745
/*CompileKernel=*/false,
755746
/*EagerChecks=*/true);
756-
#else
757-
MemorySanitizerOptions Options(
758-
SanitizerOptions->SanitizeMemoryTrackOrigins,
759-
SanitizerOptions->SanitizeMemoryRecover,
760-
/*CompileKernel=*/false);
761-
#endif
762747
OptimizerLastEPCallbacks.push_back(
763748
[Options](ModulePassManager &MPM, OptimizationLevel Level) {
764-
#if LLVM_VERSION_GE(14, 0) && LLVM_VERSION_LT(16, 0)
749+
#if LLVM_VERSION_LT(16, 0)
765750
MPM.addPass(ModuleMemorySanitizerPass(Options));
751+
MPM.addPass(createModuleToFunctionPassAdaptor(MemorySanitizerPass(Options)));
766752
#else
767753
MPM.addPass(MemorySanitizerPass(Options));
768-
#endif
769-
#if LLVM_VERSION_LT(16, 0)
770-
MPM.addPass(createModuleToFunctionPassAdaptor(MemorySanitizerPass(Options)));
771754
#endif
772755
}
773756
);
@@ -776,11 +759,7 @@ LLVMRustOptimize(
776759
if (SanitizerOptions->SanitizeThread) {
777760
OptimizerLastEPCallbacks.push_back(
778761
[](ModulePassManager &MPM, OptimizationLevel Level) {
779-
#if LLVM_VERSION_GE(14, 0)
780762
MPM.addPass(ModuleThreadSanitizerPass());
781-
#else
782-
MPM.addPass(ThreadSanitizerPass());
783-
#endif
784763
MPM.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass()));
785764
}
786765
);
@@ -792,7 +771,6 @@ LLVMRustOptimize(
792771
#if LLVM_VERSION_LT(15, 0)
793772
MPM.addPass(RequireAnalysisPass<ASanGlobalsMetadataAnalysis, Module>());
794773
#endif
795-
#if LLVM_VERSION_GE(14, 0)
796774
AddressSanitizerOptions opts = AddressSanitizerOptions{
797775
/*CompileKernel=*/false,
798776
SanitizerOptions->SanitizeAddressRecover,
@@ -803,29 +781,17 @@ LLVMRustOptimize(
803781
MPM.addPass(ModuleAddressSanitizerPass(opts));
804782
#else
805783
MPM.addPass(AddressSanitizerPass(opts));
806-
#endif
807-
#else
808-
MPM.addPass(ModuleAddressSanitizerPass(
809-
/*CompileKernel=*/false, SanitizerOptions->SanitizeAddressRecover));
810-
MPM.addPass(createModuleToFunctionPassAdaptor(AddressSanitizerPass(
811-
/*CompileKernel=*/false, SanitizerOptions->SanitizeAddressRecover,
812-
/*UseAfterScope=*/true)));
813784
#endif
814785
}
815786
);
816787
}
817788
if (SanitizerOptions->SanitizeHWAddress) {
818789
OptimizerLastEPCallbacks.push_back(
819790
[SanitizerOptions](ModulePassManager &MPM, OptimizationLevel Level) {
820-
#if LLVM_VERSION_GE(14, 0)
821791
HWAddressSanitizerOptions opts(
822792
/*CompileKernel=*/false, SanitizerOptions->SanitizeHWAddressRecover,
823793
/*DisableOptimization=*/false);
824794
MPM.addPass(HWAddressSanitizerPass(opts));
825-
#else
826-
MPM.addPass(HWAddressSanitizerPass(
827-
/*CompileKernel=*/false, SanitizerOptions->SanitizeHWAddressRecover));
828-
#endif
829795
}
830796
);
831797
}
@@ -1328,11 +1294,7 @@ extern "C" bool
13281294
LLVMRustPrepareThinLTOResolveWeak(const LLVMRustThinLTOData *Data, LLVMModuleRef M) {
13291295
Module &Mod = *unwrap(M);
13301296
const auto &DefinedGlobals = Data->ModuleToDefinedGVSummaries.lookup(Mod.getModuleIdentifier());
1331-
#if LLVM_VERSION_GE(14, 0)
13321297
thinLTOFinalizeInModule(Mod, DefinedGlobals, /*PropagateAttrs=*/true);
1333-
#else
1334-
thinLTOResolvePrevailingInModule(Mod, DefinedGlobals);
1335-
#endif
13361298
return true;
13371299
}
13381300

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

+1-13
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,7 @@ static LLVM_THREAD_LOCAL char *LastError;
6363
//
6464
// Notably it exits the process with code 101, unlike LLVM's default of 1.
6565
static void FatalErrorHandler(void *UserData,
66-
#if LLVM_VERSION_LT(14, 0)
67-
const std::string& Reason,
68-
#else
6966
const char* Reason,
70-
#endif
7167
bool GenCrashDiag) {
7268
// Do the same thing that the default error handler does.
7369
std::cerr << "LLVM ERROR: " << Reason << std::endl;
@@ -249,18 +245,10 @@ static Attribute::AttrKind fromRust(LLVMRustAttribute Kind) {
249245
template<typename T> static inline void AddAttributes(T *t, unsigned Index,
250246
LLVMAttributeRef *Attrs, size_t AttrsLen) {
251247
AttributeList PAL = t->getAttributes();
252-
AttributeList PALNew;
253-
#if LLVM_VERSION_LT(14, 0)
254-
AttrBuilder B;
255-
for (LLVMAttributeRef Attr : makeArrayRef(Attrs, AttrsLen))
256-
B.addAttribute(unwrap(Attr));
257-
PALNew = PAL.addAttributes(t->getContext(), Index, B);
258-
#else
259248
AttrBuilder B(t->getContext());
260249
for (LLVMAttributeRef Attr : ArrayRef<LLVMAttributeRef>(Attrs, AttrsLen))
261250
B.addAttribute(unwrap(Attr));
262-
PALNew = PAL.addAttributesAtIndex(t->getContext(), Index, B);
263-
#endif
251+
AttributeList PALNew = PAL.addAttributesAtIndex(t->getContext(), Index, B);
264252
t->setAttributes(PALNew);
265253
}
266254

compiler/rustc_target/src/spec/aarch64_be_unknown_linux_gnu.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub fn target() -> Target {
88
data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
99
arch: "aarch64".into(),
1010
options: TargetOptions {
11-
features: "+outline-atomics".into(),
11+
features: "+v8a,+outline-atomics".into(),
1212
max_atomic_width: Some(128),
1313
mcount: "\u{1}_mcount".into(),
1414
endian: Endian::Big,

compiler/rustc_target/src/spec/aarch64_be_unknown_linux_gnu_ilp32.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub fn target() -> Target {
1212
arch: "aarch64".into(),
1313
options: TargetOptions {
1414
abi: "ilp32".into(),
15-
features: "+outline-atomics".into(),
15+
features: "+v8a,+outline-atomics".into(),
1616
mcount: "\u{1}_mcount".into(),
1717
endian: Endian::Big,
1818
..base

compiler/rustc_target/src/spec/aarch64_kmc_solid_asp3.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub fn target() -> Target {
99
arch: "aarch64".into(),
1010
options: TargetOptions {
1111
linker: Some("aarch64-kmc-elf-gcc".into()),
12-
features: "+neon,+fp-armv8".into(),
12+
features: "+v8a,+neon,+fp-armv8".into(),
1313
relocation_model: RelocModel::Static,
1414
disable_redzone: true,
1515
max_atomic_width: Some(128),

compiler/rustc_target/src/spec/aarch64_linux_android.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub fn target() -> Target {
1313
max_atomic_width: Some(128),
1414
// As documented in https://developer.android.com/ndk/guides/cpu-features.html
1515
// the neon (ASIMD) and FP must exist on all android aarch64 targets.
16-
features: "+neon,+fp-armv8".into(),
16+
features: "+v8a,+neon,+fp-armv8".into(),
1717
supported_sanitizers: SanitizerSet::CFI
1818
| SanitizerSet::HWADDRESS
1919
| SanitizerSet::MEMTAG

compiler/rustc_target/src/spec/aarch64_nintendo_switch_freestanding.rs

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub fn target() -> Target {
1010
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
1111
arch: "aarch64".into(),
1212
options: TargetOptions {
13+
features: "+v8a".into(),
1314
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
1415
linker: Some("rust-lld".into()),
1516
link_script: Some(LINKER_SCRIPT.into()),

compiler/rustc_target/src/spec/aarch64_pc_windows_gnullvm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::spec::Target;
33
pub fn target() -> Target {
44
let mut base = super::windows_gnullvm_base::opts();
55
base.max_atomic_width = Some(128);
6-
base.features = "+neon,+fp-armv8".into();
6+
base.features = "+v8a,+neon,+fp-armv8".into();
77
base.linker = Some("aarch64-w64-mingw32-clang".into());
88

99
Target {

compiler/rustc_target/src/spec/aarch64_pc_windows_msvc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::spec::Target;
33
pub fn target() -> Target {
44
let mut base = super::windows_msvc_base::opts();
55
base.max_atomic_width = Some(128);
6-
base.features = "+neon,+fp-armv8".into();
6+
base.features = "+v8a,+neon,+fp-armv8".into();
77

88
Target {
99
llvm_target: "aarch64-pc-windows-msvc".into(),

compiler/rustc_target/src/spec/aarch64_unknown_freebsd.rs

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pub fn target() -> Target {
77
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
88
arch: "aarch64".into(),
99
options: TargetOptions {
10+
features: "+v8a".into(),
1011
max_atomic_width: Some(128),
1112
supported_sanitizers: SanitizerSet::ADDRESS
1213
| SanitizerSet::CFI

compiler/rustc_target/src/spec/aarch64_unknown_fuchsia.rs

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pub fn target() -> Target {
77
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
88
arch: "aarch64".into(),
99
options: TargetOptions {
10+
features: "+v8a".into(),
1011
max_atomic_width: Some(128),
1112
supported_sanitizers: SanitizerSet::ADDRESS
1213
| SanitizerSet::CFI

compiler/rustc_target/src/spec/aarch64_unknown_hermit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::spec::Target;
33
pub fn target() -> Target {
44
let mut base = super::hermit_base::opts();
55
base.max_atomic_width = Some(128);
6-
base.features = "+strict-align,+neon,+fp-armv8".into();
6+
base.features = "+v8a,+strict-align,+neon,+fp-armv8".into();
77

88
Target {
99
llvm_target: "aarch64-unknown-hermit".into(),

compiler/rustc_target/src/spec/aarch64_unknown_linux_gnu.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub fn target() -> Target {
77
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
88
arch: "aarch64".into(),
99
options: TargetOptions {
10-
features: "+outline-atomics".into(),
10+
features: "+v8a,+outline-atomics".into(),
1111
mcount: "\u{1}_mcount".into(),
1212
max_atomic_width: Some(128),
1313
supported_sanitizers: SanitizerSet::ADDRESS

compiler/rustc_target/src/spec/aarch64_unknown_linux_gnu_ilp32.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub fn target() -> Target {
88
arch: "aarch64".into(),
99
options: TargetOptions {
1010
abi: "ilp32".into(),
11-
features: "+outline-atomics".into(),
11+
features: "+v8a,+outline-atomics".into(),
1212
max_atomic_width: Some(128),
1313
mcount: "\u{1}_mcount".into(),
1414
..super::linux_gnu_base::opts()

compiler/rustc_target/src/spec/aarch64_unknown_linux_musl.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pub fn target() -> Target {
44
let mut base = super::linux_musl_base::opts();
55
base.max_atomic_width = Some(128);
66
base.supports_xray = true;
7+
base.features = "+v8a".into();
78

89
Target {
910
llvm_target: "aarch64-unknown-linux-musl".into(),

compiler/rustc_target/src/spec/aarch64_unknown_netbsd.rs

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pub fn target() -> Target {
77
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(),
88
arch: "aarch64".into(),
99
options: TargetOptions {
10+
features: "+v8a".into(),
1011
mcount: "__mcount".into(),
1112
max_atomic_width: Some(128),
1213
..super::netbsd_base::opts()

0 commit comments

Comments
 (0)