Skip to content

Commit 4c96822

Browse files
committed
Auto merge of #114148 - cuviper:drop-llvm-14, r=nikic
Update the minimum external LLVM to 15 With this change, we'll have stable support for LLVM 15 through 17 (pending release). For reference, the previous increase to LLVM 14 was #107573.
2 parents f9f674f + da47736 commit 4c96822

File tree

96 files changed

+293
-472
lines changed

Some content is hidden

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

96 files changed

+293
-472
lines changed

.github/workflows/ci.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
- name: mingw-check-tidy
5656
os: ubuntu-20.04-16core-64gb
5757
env: {}
58-
- name: x86_64-gnu-llvm-14
58+
- name: x86_64-gnu-llvm-15
5959
os: ubuntu-20.04-16core-64gb
6060
env: {}
6161
- name: x86_64-gnu-tools
@@ -293,10 +293,6 @@ jobs:
293293
env:
294294
RUST_BACKTRACE: 1
295295
os: ubuntu-20.04-8core-32gb
296-
- name: x86_64-gnu-llvm-14
297-
env:
298-
RUST_BACKTRACE: 1
299-
os: ubuntu-20.04-8core-32gb
300296
- name: x86_64-gnu-nopt
301297
os: ubuntu-20.04-4core-16gb
302298
env: {}

compiler/rustc_codegen_llvm/src/attributes.rs

+28-34
Original file line numberDiff line numberDiff line change
@@ -363,50 +363,44 @@ pub fn from_fn_attrs<'ll, 'tcx>(
363363
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::ALLOCATOR)
364364
|| codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::ALLOCATOR_ZEROED)
365365
{
366-
if llvm_util::get_version() >= (15, 0, 0) {
367-
to_add.push(create_alloc_family_attr(cx.llcx));
368-
// apply to argument place instead of function
369-
let alloc_align = AttributeKind::AllocAlign.create_attr(cx.llcx);
370-
attributes::apply_to_llfn(llfn, AttributePlace::Argument(1), &[alloc_align]);
371-
to_add.push(llvm::CreateAllocSizeAttr(cx.llcx, 0));
372-
let mut flags = AllocKindFlags::Alloc | AllocKindFlags::Aligned;
373-
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::ALLOCATOR) {
374-
flags |= AllocKindFlags::Uninitialized;
375-
} else {
376-
flags |= AllocKindFlags::Zeroed;
377-
}
378-
to_add.push(llvm::CreateAllocKindAttr(cx.llcx, flags));
366+
to_add.push(create_alloc_family_attr(cx.llcx));
367+
// apply to argument place instead of function
368+
let alloc_align = AttributeKind::AllocAlign.create_attr(cx.llcx);
369+
attributes::apply_to_llfn(llfn, AttributePlace::Argument(1), &[alloc_align]);
370+
to_add.push(llvm::CreateAllocSizeAttr(cx.llcx, 0));
371+
let mut flags = AllocKindFlags::Alloc | AllocKindFlags::Aligned;
372+
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::ALLOCATOR) {
373+
flags |= AllocKindFlags::Uninitialized;
374+
} else {
375+
flags |= AllocKindFlags::Zeroed;
379376
}
377+
to_add.push(llvm::CreateAllocKindAttr(cx.llcx, flags));
380378
// apply to return place instead of function (unlike all other attributes applied in this function)
381379
let no_alias = AttributeKind::NoAlias.create_attr(cx.llcx);
382380
attributes::apply_to_llfn(llfn, AttributePlace::ReturnValue, &[no_alias]);
383381
}
384382
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::REALLOCATOR) {
385-
if llvm_util::get_version() >= (15, 0, 0) {
386-
to_add.push(create_alloc_family_attr(cx.llcx));
387-
to_add.push(llvm::CreateAllocKindAttr(
388-
cx.llcx,
389-
AllocKindFlags::Realloc | AllocKindFlags::Aligned,
390-
));
391-
// applies to argument place instead of function place
392-
let allocated_pointer = AttributeKind::AllocatedPointer.create_attr(cx.llcx);
393-
attributes::apply_to_llfn(llfn, AttributePlace::Argument(0), &[allocated_pointer]);
394-
// apply to argument place instead of function
395-
let alloc_align = AttributeKind::AllocAlign.create_attr(cx.llcx);
396-
attributes::apply_to_llfn(llfn, AttributePlace::Argument(2), &[alloc_align]);
397-
to_add.push(llvm::CreateAllocSizeAttr(cx.llcx, 3));
398-
}
383+
to_add.push(create_alloc_family_attr(cx.llcx));
384+
to_add.push(llvm::CreateAllocKindAttr(
385+
cx.llcx,
386+
AllocKindFlags::Realloc | AllocKindFlags::Aligned,
387+
));
388+
// applies to argument place instead of function place
389+
let allocated_pointer = AttributeKind::AllocatedPointer.create_attr(cx.llcx);
390+
attributes::apply_to_llfn(llfn, AttributePlace::Argument(0), &[allocated_pointer]);
391+
// apply to argument place instead of function
392+
let alloc_align = AttributeKind::AllocAlign.create_attr(cx.llcx);
393+
attributes::apply_to_llfn(llfn, AttributePlace::Argument(2), &[alloc_align]);
394+
to_add.push(llvm::CreateAllocSizeAttr(cx.llcx, 3));
399395
let no_alias = AttributeKind::NoAlias.create_attr(cx.llcx);
400396
attributes::apply_to_llfn(llfn, AttributePlace::ReturnValue, &[no_alias]);
401397
}
402398
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::DEALLOCATOR) {
403-
if llvm_util::get_version() >= (15, 0, 0) {
404-
to_add.push(create_alloc_family_attr(cx.llcx));
405-
to_add.push(llvm::CreateAllocKindAttr(cx.llcx, AllocKindFlags::Free));
406-
// applies to argument place instead of function place
407-
let allocated_pointer = AttributeKind::AllocatedPointer.create_attr(cx.llcx);
408-
attributes::apply_to_llfn(llfn, AttributePlace::Argument(0), &[allocated_pointer]);
409-
}
399+
to_add.push(create_alloc_family_attr(cx.llcx));
400+
to_add.push(llvm::CreateAllocKindAttr(cx.llcx, AllocKindFlags::Free));
401+
// applies to argument place instead of function place
402+
let allocated_pointer = AttributeKind::AllocatedPointer.create_attr(cx.llcx);
403+
attributes::apply_to_llfn(llfn, AttributePlace::Argument(0), &[allocated_pointer]);
410404
}
411405
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::CMSE_NONSECURE_ENTRY) {
412406
to_add.push(llvm::CreateAttrString(cx.llcx, "cmse_nonsecure_entry"));

compiler/rustc_codegen_llvm/src/llvm_util.rs

-2
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,6 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec<Str
507507
.features
508508
.split(',')
509509
.filter(|v| !v.is_empty() && backend_feature_name(v).is_some())
510-
// Drop +atomics-32 feature introduced in LLVM 15.
511-
.filter(|v| *v != "+atomics-32" || get_version() >= (15, 0, 0))
512510
.map(String::from),
513511
);
514512

compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h

-2
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,8 @@ enum LLVMRustAttribute {
9292
NoCfCheck = 35,
9393
ShadowCallStack = 36,
9494
AllocSize = 37,
95-
#if LLVM_VERSION_GE(15, 0)
9695
AllocatedPointer = 38,
9796
AllocAlign = 39,
98-
#endif
9997
SanitizeSafeStack = 40,
10098
};
10199

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -801,9 +801,6 @@ LLVMRustOptimize(
801801
OptimizerLastEPCallbacks.push_back(
802802
[SanitizerOptions](ModulePassManager &MPM, OptimizationLevel Level) {
803803
auto CompileKernel = SanitizerOptions->SanitizeKernelAddress;
804-
#if LLVM_VERSION_LT(15, 0)
805-
MPM.addPass(RequireAnalysisPass<ASanGlobalsMetadataAnalysis, Module>());
806-
#endif
807804
AddressSanitizerOptions opts = AddressSanitizerOptions{
808805
CompileKernel,
809806
SanitizerOptions->SanitizeAddressRecover

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

-41
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,10 @@ static Attribute::AttrKind fromRust(LLVMRustAttribute Kind) {
277277
return Attribute::ShadowCallStack;
278278
case AllocSize:
279279
return Attribute::AllocSize;
280-
#if LLVM_VERSION_GE(15, 0)
281280
case AllocatedPointer:
282281
return Attribute::AllocatedPointer;
283282
case AllocAlign:
284283
return Attribute::AllocAlign;
285-
#endif
286284
case SanitizeSafeStack:
287285
return Attribute::SafeStack;
288286
}
@@ -340,20 +338,12 @@ extern "C" LLVMAttributeRef LLVMRustCreateStructRetAttr(LLVMContextRef C, LLVMTy
340338
}
341339

342340
extern "C" LLVMAttributeRef LLVMRustCreateElementTypeAttr(LLVMContextRef C, LLVMTypeRef Ty) {
343-
#if LLVM_VERSION_GE(15, 0)
344341
return wrap(Attribute::get(*unwrap(C), Attribute::ElementType, unwrap(Ty)));
345-
#else
346-
report_fatal_error("Should not be needed on LLVM < 15");
347-
#endif
348342
}
349343

350344
extern "C" LLVMAttributeRef LLVMRustCreateUWTableAttr(LLVMContextRef C, bool Async) {
351-
#if LLVM_VERSION_LT(15, 0)
352-
return wrap(Attribute::get(*unwrap(C), Attribute::UWTable));
353-
#else
354345
return wrap(Attribute::getWithUWTableKind(
355346
*unwrap(C), Async ? UWTableKind::Async : UWTableKind::Sync));
356-
#endif
357347
}
358348

359349
extern "C" LLVMAttributeRef LLVMRustCreateAllocSizeAttr(LLVMContextRef C, uint32_t ElementSizeArg) {
@@ -366,8 +356,6 @@ extern "C" LLVMAttributeRef LLVMRustCreateAllocSizeAttr(LLVMContextRef C, uint32
366356
));
367357
}
368358

369-
#if LLVM_VERSION_GE(15, 0)
370-
371359
// These values **must** match ffi::AllocKindFlags.
372360
// It _happens_ to match the LLVM values of llvm::AllocFnKind,
373361
// but that's happenstance and we do explicit conversions before
@@ -411,16 +399,10 @@ static llvm::AllocFnKind allocKindFromRust(LLVMRustAllocKindFlags F) {
411399
}
412400
return AFK;
413401
}
414-
#endif
415402

416403
extern "C" LLVMAttributeRef LLVMRustCreateAllocKindAttr(LLVMContextRef C, uint64_t AllocKindArg) {
417-
#if LLVM_VERSION_GE(15, 0)
418404
return wrap(Attribute::get(*unwrap(C), Attribute::AllocKind,
419405
static_cast<uint64_t>(allocKindFromRust(static_cast<LLVMRustAllocKindFlags>(AllocKindArg)))));
420-
#else
421-
report_fatal_error(
422-
"allockind attributes are new in LLVM 15 and should not be used on older LLVMs");
423-
#endif
424406
}
425407

426408
// Simplified representation of `MemoryEffects` across the FFI boundary.
@@ -517,14 +499,9 @@ LLVMRustInlineAsm(LLVMTypeRef Ty, char *AsmString, size_t AsmStringLen,
517499

518500
extern "C" bool LLVMRustInlineAsmVerify(LLVMTypeRef Ty, char *Constraints,
519501
size_t ConstraintsLen) {
520-
#if LLVM_VERSION_LT(15, 0)
521-
return InlineAsm::Verify(unwrap<FunctionType>(Ty),
522-
StringRef(Constraints, ConstraintsLen));
523-
#else
524502
// llvm::Error converts to true if it is an error.
525503
return !llvm::errorToBool(InlineAsm::verify(
526504
unwrap<FunctionType>(Ty), StringRef(Constraints, ConstraintsLen)));
527-
#endif
528505
}
529506

530507
typedef DIBuilder *LLVMRustDIBuilderRef;
@@ -1649,19 +1626,11 @@ extern "C" bool LLVMRustConstInt128Get(LLVMValueRef CV, bool sext, uint64_t *hig
16491626
auto C = unwrap<llvm::ConstantInt>(CV);
16501627
if (C->getBitWidth() > 128) { return false; }
16511628
APInt AP;
1652-
#if LLVM_VERSION_GE(15, 0)
16531629
if (sext) {
16541630
AP = C->getValue().sext(128);
16551631
} else {
16561632
AP = C->getValue().zext(128);
16571633
}
1658-
#else
1659-
if (sext) {
1660-
AP = C->getValue().sextOrSelf(128);
1661-
} else {
1662-
AP = C->getValue().zextOrSelf(128);
1663-
}
1664-
#endif
16651634
*low = AP.getLoBits(64).getZExtValue();
16661635
*high = AP.getHiBits(64).getZExtValue();
16671636
return true;
@@ -2037,24 +2006,14 @@ extern "C" void LLVMRustGetMangledName(LLVMValueRef V, RustStringRef Str) {
20372006
Mangler().getNameWithPrefix(OS, GV, true);
20382007
}
20392008

2040-
// LLVMGetAggregateElement was added in LLVM 15. For earlier LLVM versions just
2041-
// use its implementation.
2042-
#if LLVM_VERSION_LT(15, 0)
2043-
extern "C" LLVMValueRef LLVMGetAggregateElement(LLVMValueRef C, unsigned Idx) {
2044-
return wrap(unwrap<Constant>(C)->getAggregateElement(Idx));
2045-
}
2046-
#endif
2047-
20482009
extern "C" int32_t LLVMRustGetElementTypeArgIndex(LLVMValueRef CallSite) {
2049-
#if LLVM_VERSION_GE(15, 0)
20502010
auto *CB = unwrap<CallBase>(CallSite);
20512011
switch (CB->getIntrinsicID()) {
20522012
case Intrinsic::arm_ldrex:
20532013
return 0;
20542014
case Intrinsic::arm_strex:
20552015
return 1;
20562016
}
2057-
#endif
20582017
return -1;
20592018
}
20602019

src/bootstrap/llvm.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -525,11 +525,11 @@ fn check_llvm_version(builder: &Builder<'_>, llvm_config: &Path) {
525525
let version = output(cmd.arg("--version"));
526526
let mut parts = version.split('.').take(2).filter_map(|s| s.parse::<u32>().ok());
527527
if let (Some(major), Some(_minor)) = (parts.next(), parts.next()) {
528-
if major >= 14 {
528+
if major >= 15 {
529529
return;
530530
}
531531
}
532-
panic!("\n\nbad LLVM version: {}, need >=14.0\n\n", version)
532+
panic!("\n\nbad LLVM version: {}, need >=15.0\n\n", version)
533533
}
534534

535535
fn configure_cmake(

src/ci/docker/host-x86_64/x86_64-gnu-llvm-14/Dockerfile

-54
This file was deleted.

src/ci/docker/host-x86_64/x86_64-gnu-llvm-15/Dockerfile

+5-19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:22.10
1+
FROM ubuntu:22.04
22

33
ARG DEBIAN_FRONTEND=noninteractive
44

@@ -10,7 +10,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1010
file \
1111
curl \
1212
ca-certificates \
13-
python3 \
13+
python3.11 \
1414
git \
1515
cmake \
1616
sudo \
@@ -49,20 +49,6 @@ ENV RUST_CONFIGURE_ARGS \
4949
--enable-llvm-link-shared \
5050
--set rust.thin-lto-import-instr-limit=10
5151

52-
# NOTE: intentionally uses all of `x.py`, `x`, and `x.ps1` to make sure they all work on Linux.
53-
ENV SCRIPT ../x.py --stage 2 test --exclude src/tools/tidy && \
54-
# Run the `mir-opt` tests again but this time for a 32-bit target.
55-
# This enforces that tests using `// EMIT_MIR_FOR_EACH_BIT_WIDTH` have
56-
# both 32-bit and 64-bit outputs updated by the PR author, before
57-
# the PR is approved and tested for merging.
58-
# It will also detect tests lacking `// EMIT_MIR_FOR_EACH_BIT_WIDTH`,
59-
# despite having different output on 32-bit vs 64-bit targets.
60-
../x --stage 2 test tests/mir-opt \
61-
--host='' --target=i686-unknown-linux-gnu && \
62-
# Run the UI test suite again, but in `--pass=check` mode
63-
#
64-
# This is intended to make sure that both `--pass=check` continues to
65-
# work.
66-
#
67-
../x.ps1 --stage 2 test tests/ui --pass=check \
68-
--host='' --target=i686-unknown-linux-gnu
52+
COPY host-x86_64/x86_64-gnu-llvm-15/script.sh /tmp/
53+
54+
ENV SCRIPT /tmp/script.sh

src/ci/docker/host-x86_64/x86_64-gnu-llvm-16/Dockerfile

+3-17
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,6 @@ ENV RUST_CONFIGURE_ARGS \
4545
--enable-llvm-link-shared \
4646
--set rust.thin-lto-import-instr-limit=10
4747

48-
# NOTE: intentionally uses all of `x.py`, `x`, and `x.ps1` to make sure they all work on Linux.
49-
ENV SCRIPT ../x.py --stage 2 test --exclude src/tools/tidy && \
50-
# Run the `mir-opt` tests again but this time for a 32-bit target.
51-
# This enforces that tests using `// EMIT_MIR_FOR_EACH_BIT_WIDTH` have
52-
# both 32-bit and 64-bit outputs updated by the PR author, before
53-
# the PR is approved and tested for merging.
54-
# It will also detect tests lacking `// EMIT_MIR_FOR_EACH_BIT_WIDTH`,
55-
# despite having different output on 32-bit vs 64-bit targets.
56-
../x --stage 2 test tests/mir-opt \
57-
--host='' --target=i686-unknown-linux-gnu && \
58-
# Run the UI test suite again, but in `--pass=check` mode
59-
#
60-
# This is intended to make sure that both `--pass=check` continues to
61-
# work.
62-
#
63-
../x.ps1 --stage 2 test tests/ui --pass=check \
64-
--host='' --target=i686-unknown-linux-gnu
48+
COPY host-x86_64/x86_64-gnu-llvm-15/script.sh /tmp/
49+
50+
ENV SCRIPT /tmp/script.sh

0 commit comments

Comments
 (0)