Skip to content

Commit 49b3924

Browse files
committed
Auto merge of rust-lang#117947 - Dirbaio:drop-llvm-15, r=cuviper
Update the minimum external LLVM to 16. With this change, we'll have stable support for LLVM 16 and 17. For reference, the previous increase to LLVM 15 was rust-lang#114148 [Relevant zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/riscv.20forced-atomics)
2 parents 6eb9524 + 7de6d04 commit 49b3924

File tree

65 files changed

+42
-251
lines changed

Some content is hidden

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

65 files changed

+42
-251
lines changed

.github/workflows/ci.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
- name: mingw-check-tidy
5757
os: ubuntu-20.04-4core-16gb
5858
env: {}
59-
- name: x86_64-gnu-llvm-15
59+
- name: x86_64-gnu-llvm-16
6060
env:
6161
ENABLE_GCC_CODEGEN: "1"
6262
os: ubuntu-20.04-16core-64gb
@@ -302,10 +302,6 @@ jobs:
302302
env:
303303
RUST_BACKTRACE: 1
304304
os: ubuntu-20.04-8core-32gb
305-
- name: x86_64-gnu-llvm-15
306-
env:
307-
RUST_BACKTRACE: 1
308-
os: ubuntu-20.04-8core-32gb
309305
- name: x86_64-gnu-nopt
310306
os: ubuntu-20.04-4core-16gb
311307
env: {}

compiler/rustc_codegen_llvm/src/context.rs

-12
Original file line numberDiff line numberDiff line change
@@ -134,18 +134,6 @@ pub unsafe fn create_module<'ll>(
134134

135135
let mut target_data_layout = sess.target.data_layout.to_string();
136136
let llvm_version = llvm_util::get_version();
137-
if llvm_version < (16, 0, 0) {
138-
if sess.target.arch == "s390x" {
139-
// LLVM 16 data layout changed to always set 64-bit vector alignment,
140-
// which is conditional in earlier LLVM versions.
141-
// https://reviews.llvm.org/D131158 for the discussion.
142-
target_data_layout = target_data_layout.replace("-v128:64", "");
143-
} else if sess.target.arch == "riscv64" {
144-
// LLVM 16 introduced this change so as to produce more efficient code.
145-
// See https://reviews.llvm.org/D116735 for the discussion.
146-
target_data_layout = target_data_layout.replace("-n32:64-", "-n64-");
147-
}
148-
}
149137
if llvm_version < (17, 0, 0) {
150138
if sess.target.arch.starts_with("powerpc") {
151139
// LLVM 17 specifies function pointer alignment for ppc:

compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h

-4
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,7 @@
4242
#include "llvm/IR/IRPrintingPasses.h"
4343
#include "llvm/Linker/Linker.h"
4444

45-
#if LLVM_VERSION_GE(16, 0)
4645
#include "llvm/TargetParser/Triple.h"
47-
#else
48-
#include "llvm/ADT/Triple.h"
49-
#endif
5046

5147
extern "C" void LLVMRustSetLastError(const char *);
5248

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

-27
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,7 @@ enum class LLVMRustCodeModel {
204204
None,
205205
};
206206

207-
#if LLVM_VERSION_LT(16, 0)
208-
static Optional<CodeModel::Model>
209-
#else
210207
static std::optional<CodeModel::Model>
211-
#endif
212208
fromRust(LLVMRustCodeModel Model) {
213209
switch (Model) {
214210
case LLVMRustCodeModel::Tiny:
@@ -222,11 +218,7 @@ fromRust(LLVMRustCodeModel Model) {
222218
case LLVMRustCodeModel::Large:
223219
return CodeModel::Large;
224220
case LLVMRustCodeModel::None:
225-
#if LLVM_VERSION_LT(16, 0)
226-
return None;
227-
#else
228221
return std::nullopt;
229-
#endif
230222
default:
231223
report_fatal_error("Bad CodeModel.");
232224
}
@@ -452,15 +444,13 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
452444
if (OutputObjFile) {
453445
Options.ObjectFilenameForDebug = OutputObjFile;
454446
}
455-
#if LLVM_VERSION_GE(16, 0)
456447
if (!strcmp("zlib", DebugInfoCompression) && llvm::compression::zlib::isAvailable()) {
457448
Options.CompressDebugSections = DebugCompressionType::Zlib;
458449
} else if (!strcmp("zstd", DebugInfoCompression) && llvm::compression::zstd::isAvailable()) {
459450
Options.CompressDebugSections = DebugCompressionType::Zstd;
460451
} else if (!strcmp("none", DebugInfoCompression)) {
461452
Options.CompressDebugSections = DebugCompressionType::None;
462453
}
463-
#endif
464454

465455
Options.RelaxELFRelocations = RelaxELFRelocations;
466456
Options.UseInitArray = UseInitArray;
@@ -734,22 +724,14 @@ LLVMRustOptimize(
734724
bool DebugPassManager = false;
735725

736726
PassInstrumentationCallbacks PIC;
737-
#if LLVM_VERSION_LT(16, 0)
738-
StandardInstrumentations SI(DebugPassManager);
739-
#else
740727
StandardInstrumentations SI(TheModule->getContext(), DebugPassManager);
741-
#endif
742728
SI.registerCallbacks(PIC);
743729

744730
if (LlvmSelfProfiler){
745731
LLVMSelfProfileInitializeCallbacks(PIC,LlvmSelfProfiler,BeforePassCallback,AfterPassCallback);
746732
}
747733

748-
#if LLVM_VERSION_LT(16, 0)
749-
Optional<PGOOptions> PGOOpt;
750-
#else
751734
std::optional<PGOOptions> PGOOpt;
752-
#endif
753735
#if LLVM_VERSION_GE(17, 0)
754736
auto FS = vfs::getRealFileSystem();
755737
#endif
@@ -882,12 +864,7 @@ LLVMRustOptimize(
882864
/*EagerChecks=*/true);
883865
OptimizerLastEPCallbacks.push_back(
884866
[Options](ModulePassManager &MPM, OptimizationLevel Level) {
885-
#if LLVM_VERSION_LT(16, 0)
886-
MPM.addPass(ModuleMemorySanitizerPass(Options));
887-
MPM.addPass(createModuleToFunctionPassAdaptor(MemorySanitizerPass(Options)));
888-
#else
889867
MPM.addPass(MemorySanitizerPass(Options));
890-
#endif
891868
}
892869
);
893870
}
@@ -912,11 +889,7 @@ LLVMRustOptimize(
912889
/*UseAfterScope=*/true,
913890
AsanDetectStackUseAfterReturnMode::Runtime,
914891
};
915-
#if LLVM_VERSION_LT(16, 0)
916-
MPM.addPass(ModuleAddressSanitizerPass(opts));
917-
#else
918892
MPM.addPass(AddressSanitizerPass(opts));
919-
#endif
920893
}
921894
);
922895
}

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

+1-50
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,13 @@
1414
#include "llvm/Remarks/RemarkSerializer.h"
1515
#include "llvm/Remarks/RemarkFormat.h"
1616
#include "llvm/Support/ToolOutputFile.h"
17-
#if LLVM_VERSION_GE(16, 0)
1817
#include "llvm/Support/ModRef.h"
19-
#endif
2018
#include "llvm/Object/Archive.h"
2119
#include "llvm/Object/COFFImportFile.h"
2220
#include "llvm/Object/ObjectFile.h"
2321
#include "llvm/Pass.h"
2422
#include "llvm/Bitcode/BitcodeWriter.h"
2523
#include "llvm/Support/Signals.h"
26-
#if LLVM_VERSION_LT(16, 0)
27-
#include "llvm/ADT/Optional.h"
28-
#endif
2924

3025
#include <iostream>
3126

@@ -347,13 +342,7 @@ extern "C" LLVMAttributeRef LLVMRustCreateUWTableAttr(LLVMContextRef C, bool Asy
347342
}
348343

349344
extern "C" LLVMAttributeRef LLVMRustCreateAllocSizeAttr(LLVMContextRef C, uint32_t ElementSizeArg) {
350-
return wrap(Attribute::getWithAllocSizeArgs(*unwrap(C), ElementSizeArg,
351-
#if LLVM_VERSION_LT(16, 0)
352-
None
353-
#else
354-
std::nullopt
355-
#endif
356-
));
345+
return wrap(Attribute::getWithAllocSizeArgs(*unwrap(C), ElementSizeArg, std::nullopt));
357346
}
358347

359348
// These values **must** match ffi::AllocKindFlags.
@@ -416,7 +405,6 @@ enum class LLVMRustMemoryEffects {
416405

417406
extern "C" LLVMAttributeRef LLVMRustCreateMemoryEffectsAttr(LLVMContextRef C,
418407
LLVMRustMemoryEffects Effects) {
419-
#if LLVM_VERSION_GE(16, 0)
420408
switch (Effects) {
421409
case LLVMRustMemoryEffects::None:
422410
return wrap(Attribute::getWithMemoryEffects(*unwrap(C), MemoryEffects::none()));
@@ -428,18 +416,6 @@ extern "C" LLVMAttributeRef LLVMRustCreateMemoryEffectsAttr(LLVMContextRef C,
428416
default:
429417
report_fatal_error("bad MemoryEffects.");
430418
}
431-
#else
432-
switch (Effects) {
433-
case LLVMRustMemoryEffects::None:
434-
return wrap(Attribute::get(*unwrap(C), Attribute::ReadNone));
435-
case LLVMRustMemoryEffects::ReadOnly:
436-
return wrap(Attribute::get(*unwrap(C), Attribute::ReadOnly));
437-
case LLVMRustMemoryEffects::InaccessibleMemOnly:
438-
return wrap(Attribute::get(*unwrap(C), Attribute::InaccessibleMemOnly));
439-
default:
440-
report_fatal_error("bad MemoryEffects.");
441-
}
442-
#endif
443419
}
444420

445421
// Enable a fast-math flag
@@ -726,18 +702,10 @@ enum class LLVMRustChecksumKind {
726702
SHA256,
727703
};
728704

729-
#if LLVM_VERSION_LT(16, 0)
730-
static Optional<DIFile::ChecksumKind> fromRust(LLVMRustChecksumKind Kind) {
731-
#else
732705
static std::optional<DIFile::ChecksumKind> fromRust(LLVMRustChecksumKind Kind) {
733-
#endif
734706
switch (Kind) {
735707
case LLVMRustChecksumKind::None:
736-
#if LLVM_VERSION_LT(16, 0)
737-
return None;
738-
#else
739708
return std::nullopt;
740-
#endif
741709
case LLVMRustChecksumKind::MD5:
742710
return DIFile::ChecksumKind::CSK_MD5;
743711
case LLVMRustChecksumKind::SHA1:
@@ -810,17 +778,8 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateFile(
810778
const char *Directory, size_t DirectoryLen, LLVMRustChecksumKind CSKind,
811779
const char *Checksum, size_t ChecksumLen) {
812780

813-
#if LLVM_VERSION_LT(16, 0)
814-
Optional<DIFile::ChecksumKind> llvmCSKind = fromRust(CSKind);
815-
#else
816781
std::optional<DIFile::ChecksumKind> llvmCSKind = fromRust(CSKind);
817-
#endif
818-
819-
#if LLVM_VERSION_LT(16, 0)
820-
Optional<DIFile::ChecksumInfo<StringRef>> CSInfo{};
821-
#else
822782
std::optional<DIFile::ChecksumInfo<StringRef>> CSInfo{};
823-
#endif
824783
if (llvmCSKind)
825784
CSInfo.emplace(*llvmCSKind, StringRef{Checksum, ChecksumLen});
826785
return wrap(Builder->createFile(StringRef(Filename, FilenameLen),
@@ -2053,17 +2012,9 @@ extern "C" bool LLVMRustIsNonGVFunctionPointerTy(LLVMValueRef V) {
20532012
}
20542013

20552014
extern "C" bool LLVMRustLLVMHasZlibCompressionForDebugSymbols() {
2056-
#if LLVM_VERSION_GE(16, 0)
20572015
return llvm::compression::zlib::isAvailable();
2058-
#else
2059-
return false;
2060-
#endif
20612016
}
20622017

20632018
extern "C" bool LLVMRustLLVMHasZstdCompressionForDebugSymbols() {
2064-
#if LLVM_VERSION_GE(16, 0)
20652019
return llvm::compression::zstd::isAvailable();
2066-
#else
2067-
return false;
2068-
#endif
20692020
}

compiler/rustc_target/src/spec/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -1155,10 +1155,6 @@ pub enum StackProbeType {
11551155
}
11561156

11571157
impl StackProbeType {
1158-
// LLVM X86 targets (ix86 and x86_64) can use inline-asm stack probes starting with LLVM 16.
1159-
// Notable past issues were rust#83139 (fixed in 14) and rust#84667 (fixed in 16).
1160-
const X86: Self = Self::InlineOrCall { min_llvm_version_for_inline: (16, 0, 0) };
1161-
11621158
fn from_json(json: &Json) -> Result<Self, String> {
11631159
let object = json.as_object().ok_or_else(|| "expected a JSON object")?;
11641160
let kind = object

compiler/rustc_target/src/spec/targets/i386_apple_ios.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub fn target() -> Target {
1616
arch: arch.target_arch(),
1717
options: TargetOptions {
1818
max_atomic_width: Some(64),
19-
stack_probes: StackProbeType::X86,
19+
stack_probes: StackProbeType::Inline,
2020
..opts("ios", arch)
2121
},
2222
}

compiler/rustc_target/src/spec/targets/i586_pc_nto_qnx700.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub fn target() -> Target {
1616
&["-Vgcc_ntox86_cxx"],
1717
),
1818
env: "nto70".into(),
19-
stack_probes: StackProbeType::X86,
19+
stack_probes: StackProbeType::Inline,
2020
..base::nto_qnx::opts()
2121
},
2222
}

compiler/rustc_target/src/spec/targets/i686_apple_darwin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub fn target() -> Target {
77
let mut base = opts("macos", arch);
88
base.max_atomic_width = Some(64);
99
base.add_pre_link_args(LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-m32"]);
10-
base.stack_probes = StackProbeType::X86;
10+
base.stack_probes = StackProbeType::Inline;
1111
base.frame_pointer = FramePointer::Always;
1212

1313
Target {

compiler/rustc_target/src/spec/targets/i686_linux_android.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub fn target() -> Target {
1111
// https://developer.android.com/ndk/guides/abis.html#x86
1212
base.cpu = "pentiumpro".into();
1313
base.features = "+mmx,+sse,+sse2,+sse3,+ssse3".into();
14-
base.stack_probes = StackProbeType::X86;
14+
base.stack_probes = StackProbeType::Inline;
1515

1616
Target {
1717
llvm_target: "i686-linux-android".into(),

compiler/rustc_target/src/spec/targets/i686_unknown_freebsd.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub fn target() -> Target {
55
base.cpu = "pentium4".into();
66
base.max_atomic_width = Some(64);
77
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32", "-Wl,-znotext"]);
8-
base.stack_probes = StackProbeType::X86;
8+
base.stack_probes = StackProbeType::Inline;
99

1010
Target {
1111
llvm_target: "i686-unknown-freebsd".into(),

compiler/rustc_target/src/spec/targets/i686_unknown_haiku.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub fn target() -> Target {
55
base.cpu = "pentium4".into();
66
base.max_atomic_width = Some(64);
77
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]);
8-
base.stack_probes = StackProbeType::X86;
8+
base.stack_probes = StackProbeType::Inline;
99

1010
Target {
1111
llvm_target: "i686-unknown-haiku".into(),

compiler/rustc_target/src/spec/targets/i686_unknown_linux_gnu.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub fn target() -> Target {
66
base.max_atomic_width = Some(64);
77
base.supported_sanitizers = SanitizerSet::ADDRESS;
88
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]);
9-
base.stack_probes = StackProbeType::X86;
9+
base.stack_probes = StackProbeType::Inline;
1010

1111
Target {
1212
llvm_target: "i686-unknown-linux-gnu".into(),

compiler/rustc_target/src/spec/targets/i686_unknown_linux_musl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub fn target() -> Target {
55
base.cpu = "pentium4".into();
66
base.max_atomic_width = Some(64);
77
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32", "-Wl,-melf_i386"]);
8-
base.stack_probes = StackProbeType::X86;
8+
base.stack_probes = StackProbeType::Inline;
99

1010
// The unwinder used by i686-unknown-linux-musl, the LLVM libunwind
1111
// implementation, apparently relies on frame pointers existing... somehow.

compiler/rustc_target/src/spec/targets/i686_unknown_netbsd.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub fn target() -> Target {
55
base.cpu = "pentium4".into();
66
base.max_atomic_width = Some(64);
77
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]);
8-
base.stack_probes = StackProbeType::X86;
8+
base.stack_probes = StackProbeType::Inline;
99

1010
Target {
1111
llvm_target: "i686-unknown-netbsdelf".into(),

compiler/rustc_target/src/spec/targets/i686_unknown_openbsd.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub fn target() -> Target {
55
base.cpu = "pentium4".into();
66
base.max_atomic_width = Some(64);
77
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32", "-fuse-ld=lld"]);
8-
base.stack_probes = StackProbeType::X86;
8+
base.stack_probes = StackProbeType::Inline;
99

1010
Target {
1111
llvm_target: "i686-unknown-openbsd".into(),

compiler/rustc_target/src/spec/targets/i686_wrs_vxworks.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub fn target() -> Target {
55
base.cpu = "pentium4".into();
66
base.max_atomic_width = Some(64);
77
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]);
8-
base.stack_probes = StackProbeType::X86;
8+
base.stack_probes = StackProbeType::Inline;
99

1010
Target {
1111
llvm_target: "i686-unknown-linux-gnu".into(),

compiler/rustc_target/src/spec/targets/x86_64_apple_darwin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub fn target() -> Target {
88
base.max_atomic_width = Some(128); // penryn+ supports cmpxchg16b
99
base.frame_pointer = FramePointer::Always;
1010
base.add_pre_link_args(LinkerFlavor::Darwin(Cc::Yes, Lld::No), &["-m64"]);
11-
base.stack_probes = StackProbeType::X86;
11+
base.stack_probes = StackProbeType::Inline;
1212
base.supported_sanitizers =
1313
SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::LEAK | SanitizerSet::THREAD;
1414

compiler/rustc_target/src/spec/targets/x86_64_apple_ios.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub fn target() -> Target {
1414
arch: arch.target_arch(),
1515
options: TargetOptions {
1616
max_atomic_width: Some(128),
17-
stack_probes: StackProbeType::X86,
17+
stack_probes: StackProbeType::Inline,
1818
..base
1919
},
2020
}

compiler/rustc_target/src/spec/targets/x86_64_apple_ios_macabi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub fn target() -> Target {
1717
arch: arch.target_arch(),
1818
options: TargetOptions {
1919
max_atomic_width: Some(128),
20-
stack_probes: StackProbeType::X86,
20+
stack_probes: StackProbeType::Inline,
2121
..base
2222
},
2323
}

0 commit comments

Comments
 (0)