Skip to content

Commit

Permalink
Rollup merge of rust-lang#90062 - cuviper:min-llvm-11, r=nikic
Browse files Browse the repository at this point in the history
Update the minimum external LLVM to 11

With this change, we'll have stable support for LLVM 11..=13.
For reference, the previous increase to LLVM 10 was rust-lang#83387.

r? `@nagisa` `@nikic`
  • Loading branch information
matthiaskrgr authored Oct 23, 2021
2 parents 809e5c8 + 5a87d1a commit 684402e
Show file tree
Hide file tree
Showing 47 changed files with 49 additions and 188 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: mingw-check
os: ubuntu-latest-xl
env: {}
- name: x86_64-gnu-llvm-10
- name: x86_64-gnu-llvm-11
os: ubuntu-latest-xl
env: {}
- name: x86_64-gnu-tools
Expand Down Expand Up @@ -274,7 +274,7 @@ jobs:
- name: x86_64-gnu-distcheck
os: ubuntu-latest-xl
env: {}
- name: x86_64-gnu-llvm-10
- name: x86_64-gnu-llvm-11
env:
RUST_BACKTRACE: 1
os: ubuntu-latest-xl
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ unsafe fn configure_llvm(sess: &Session) {
// Ref:
// - https://github.com/rust-lang/rust/issues/85351
// - https://reviews.llvm.org/D103167
let llvm_version = llvm_util::get_version();
if llvm_version >= (11, 0, 0) && llvm_version < (13, 0, 0) {
if llvm_util::get_version() < (13, 0, 0) {
add("-enable-machine-outliner=never", false);
}

Expand Down
7 changes: 0 additions & 7 deletions compiler/rustc_llvm/llvm-wrapper/CoverageMappingWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,7 @@ extern "C" void LLVMRustCoverageWriteMapSectionNameToString(LLVMModuleRef M,

extern "C" void LLVMRustCoverageWriteFuncSectionNameToString(LLVMModuleRef M,
RustStringRef Str) {
#if LLVM_VERSION_GE(11, 0)
WriteSectionNameToString(M, IPSK_covfun, Str);
// else do nothing; the `Version` check will abort codegen on the Rust side
#endif
}

extern "C" void LLVMRustCoverageWriteMappingVarNameToString(RustStringRef Str) {
Expand All @@ -111,9 +108,5 @@ extern "C" void LLVMRustCoverageWriteMappingVarNameToString(RustStringRef Str) {
}

extern "C" uint32_t LLVMRustCoverageMappingVersion() {
#if LLVM_VERSION_GE(11, 0)
return coverage::CovMapVersion::Version4;
#else
return coverage::CovMapVersion::Version3;
#endif
}
93 changes: 0 additions & 93 deletions compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ typedef struct LLVMOpaqueTargetMachine *LLVMTargetMachineRef;

DEFINE_STDCXX_CONVERSION_FUNCTIONS(Pass, LLVMPassRef)
DEFINE_STDCXX_CONVERSION_FUNCTIONS(TargetMachine, LLVMTargetMachineRef)
#if LLVM_VERSION_LT(11, 0)
DEFINE_STDCXX_CONVERSION_FUNCTIONS(PassManagerBuilder,
LLVMPassManagerBuilderRef)
#endif

extern "C" void LLVMInitializePasses() {
PassRegistry &Registry = *PassRegistry::getPassRegistry();
Expand Down Expand Up @@ -857,13 +853,8 @@ LLVMRustOptimizeWithNewPassManager(
// PassBuilder does not create a pipeline.
std::vector<std::function<void(ModulePassManager &, OptimizationLevel)>>
PipelineStartEPCallbacks;
#if LLVM_VERSION_GE(11, 0)
std::vector<std::function<void(ModulePassManager &, OptimizationLevel)>>
OptimizerLastEPCallbacks;
#else
std::vector<std::function<void(FunctionPassManager &, OptimizationLevel)>>
OptimizerLastEPCallbacks;
#endif

if (VerifyIR) {
PipelineStartEPCallbacks.push_back(
Expand Down Expand Up @@ -896,7 +887,6 @@ LLVMRustOptimizeWithNewPassManager(
SanitizerOptions->SanitizeMemoryTrackOrigins,
SanitizerOptions->SanitizeMemoryRecover,
/*CompileKernel=*/false);
#if LLVM_VERSION_GE(11, 0)
OptimizerLastEPCallbacks.push_back(
[Options](ModulePassManager &MPM, OptimizationLevel Level) {
#if LLVM_VERSION_GE(14, 0)
Expand All @@ -907,22 +897,9 @@ LLVMRustOptimizeWithNewPassManager(
MPM.addPass(createModuleToFunctionPassAdaptor(MemorySanitizerPass(Options)));
}
);
#else
PipelineStartEPCallbacks.push_back(
[Options](ModulePassManager &MPM, OptimizationLevel Level) {
MPM.addPass(MemorySanitizerPass(Options));
}
);
OptimizerLastEPCallbacks.push_back(
[Options](FunctionPassManager &FPM, OptimizationLevel Level) {
FPM.addPass(MemorySanitizerPass(Options));
}
);
#endif
}

if (SanitizerOptions->SanitizeThread) {
#if LLVM_VERSION_GE(11, 0)
OptimizerLastEPCallbacks.push_back(
[](ModulePassManager &MPM, OptimizationLevel Level) {
#if LLVM_VERSION_GE(14, 0)
Expand All @@ -933,22 +910,9 @@ LLVMRustOptimizeWithNewPassManager(
MPM.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass()));
}
);
#else
PipelineStartEPCallbacks.push_back(
[](ModulePassManager &MPM, OptimizationLevel Level) {
MPM.addPass(ThreadSanitizerPass());
}
);
OptimizerLastEPCallbacks.push_back(
[](FunctionPassManager &FPM, OptimizationLevel Level) {
FPM.addPass(ThreadSanitizerPass());
}
);
#endif
}

if (SanitizerOptions->SanitizeAddress) {
#if LLVM_VERSION_GE(11, 0)
OptimizerLastEPCallbacks.push_back(
[SanitizerOptions](ModulePassManager &MPM, OptimizationLevel Level) {
MPM.addPass(RequireAnalysisPass<ASanGlobalsMetadataAnalysis, Module>());
Expand All @@ -967,29 +931,8 @@ LLVMRustOptimizeWithNewPassManager(
#endif
}
);
#else
PipelineStartEPCallbacks.push_back(
[&](ModulePassManager &MPM, OptimizationLevel Level) {
MPM.addPass(RequireAnalysisPass<ASanGlobalsMetadataAnalysis, Module>());
}
);
OptimizerLastEPCallbacks.push_back(
[SanitizerOptions](FunctionPassManager &FPM, OptimizationLevel Level) {
FPM.addPass(AddressSanitizerPass(
/*CompileKernel=*/false, SanitizerOptions->SanitizeAddressRecover,
/*UseAfterScope=*/true));
}
);
PipelineStartEPCallbacks.push_back(
[SanitizerOptions](ModulePassManager &MPM, OptimizationLevel Level) {
MPM.addPass(ModuleAddressSanitizerPass(
/*CompileKernel=*/false, SanitizerOptions->SanitizeAddressRecover));
}
);
#endif
}
if (SanitizerOptions->SanitizeHWAddress) {
#if LLVM_VERSION_GE(11, 0)
OptimizerLastEPCallbacks.push_back(
[SanitizerOptions](ModulePassManager &MPM, OptimizationLevel Level) {
#if LLVM_VERSION_GE(14, 0)
Expand All @@ -1003,14 +946,6 @@ LLVMRustOptimizeWithNewPassManager(
#endif
}
);
#else
PipelineStartEPCallbacks.push_back(
[SanitizerOptions](ModulePassManager &MPM, OptimizationLevel Level) {
MPM.addPass(HWAddressSanitizerPass(
/*CompileKernel=*/false, SanitizerOptions->SanitizeHWAddressRecover));
}
);
#endif
}
}

Expand All @@ -1037,17 +972,8 @@ LLVMRustOptimizeWithNewPassManager(
for (const auto &C : PipelineStartEPCallbacks)
C(MPM, OptLevel);

# if LLVM_VERSION_GE(11, 0)
for (const auto &C : OptimizerLastEPCallbacks)
C(MPM, OptLevel);
# else
if (!OptimizerLastEPCallbacks.empty()) {
FunctionPassManager FPM(DebugPassManager);
for (const auto &C : OptimizerLastEPCallbacks)
C(FPM, OptLevel);
MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
}
# endif

MPM.addPass(AlwaysInlinerPass(EmitLifetimeMarkers));

Expand Down Expand Up @@ -1088,17 +1014,8 @@ LLVMRustOptimizeWithNewPassManager(
#else
MPM = PB.buildThinLTOPreLinkDefaultPipeline(OptLevel, DebugPassManager);
#endif
#if LLVM_VERSION_GE(11, 0)
for (const auto &C : OptimizerLastEPCallbacks)
C(MPM, OptLevel);
#else
if (!OptimizerLastEPCallbacks.empty()) {
FunctionPassManager FPM(DebugPassManager);
for (const auto &C : OptimizerLastEPCallbacks)
C(FPM, OptLevel);
MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
}
#endif
break;
case LLVMRustOptStage::PreLinkFatLTO:
#if LLVM_VERSION_GE(12, 0)
Expand Down Expand Up @@ -1552,7 +1469,6 @@ LLVMRustFreeThinLTOData(LLVMRustThinLTOData *Data) {
// `ProcessThinLTOModule` function. Here they're split up into separate steps
// so rustc can save off the intermediate bytecode between each step.

#if LLVM_VERSION_GE(11, 0)
static bool
clearDSOLocalOnDeclarations(Module &Mod, TargetMachine &TM) {
// When linking an ELF shared object, dso_local should be dropped. We
Expand All @@ -1563,20 +1479,15 @@ clearDSOLocalOnDeclarations(Module &Mod, TargetMachine &TM) {
Mod.getPIELevel() == PIELevel::Default;
return ClearDSOLocalOnDeclarations;
}
#endif

extern "C" bool
LLVMRustPrepareThinLTORename(const LLVMRustThinLTOData *Data, LLVMModuleRef M,
LLVMTargetMachineRef TM) {
Module &Mod = *unwrap(M);
TargetMachine &Target = *unwrap(TM);

#if LLVM_VERSION_GE(11, 0)
bool ClearDSOLocal = clearDSOLocalOnDeclarations(Mod, Target);
bool error = renameModuleForThinLTO(Mod, Data->Index, ClearDSOLocal);
#else
bool error = renameModuleForThinLTO(Mod, Data->Index);
#endif

if (error) {
LLVMRustSetLastError("renameModuleForThinLTO failed");
Expand Down Expand Up @@ -1645,12 +1556,8 @@ LLVMRustPrepareThinLTOImport(const LLVMRustThinLTOData *Data, LLVMModuleRef M,

return MOrErr;
};
#if LLVM_VERSION_GE(11, 0)
bool ClearDSOLocal = clearDSOLocalOnDeclarations(Mod, Target);
FunctionImporter Importer(Data->Index, Loader, ClearDSOLocal);
#else
FunctionImporter Importer(Data->Index, Loader);
#endif
Expected<bool> Result = Importer.importFunctions(Mod, ImportList);
if (!Result) {
LLVMRustSetLastError(toString(Result.takeError()).c_str());
Expand Down
14 changes: 0 additions & 14 deletions compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,10 +681,8 @@ static Optional<DIFile::ChecksumKind> fromRust(LLVMRustChecksumKind Kind) {
return DIFile::ChecksumKind::CSK_MD5;
case LLVMRustChecksumKind::SHA1:
return DIFile::ChecksumKind::CSK_SHA1;
#if (LLVM_VERSION_MAJOR >= 11)
case LLVMRustChecksumKind::SHA256:
return DIFile::ChecksumKind::CSK_SHA256;
#endif
default:
report_fatal_error("bad ChecksumKind.");
}
Expand Down Expand Up @@ -999,14 +997,9 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateUnionType(
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateTemplateTypeParameter(
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope,
const char *Name, size_t NameLen, LLVMMetadataRef Ty) {
#if LLVM_VERSION_GE(11, 0)
bool IsDefault = false; // FIXME: should we ever set this true?
return wrap(Builder->createTemplateTypeParameter(
unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen), unwrapDI<DIType>(Ty), IsDefault));
#else
return wrap(Builder->createTemplateTypeParameter(
unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen), unwrapDI<DIType>(Ty)));
#endif
}

extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateNameSpace(
Expand Down Expand Up @@ -1246,23 +1239,16 @@ extern "C" LLVMTypeKind LLVMRustGetTypeKind(LLVMTypeRef Ty) {
return LLVMArrayTypeKind;
case Type::PointerTyID:
return LLVMPointerTypeKind;
#if LLVM_VERSION_GE(11, 0)
case Type::FixedVectorTyID:
return LLVMVectorTypeKind;
#else
case Type::VectorTyID:
return LLVMVectorTypeKind;
#endif
case Type::X86_MMXTyID:
return LLVMX86_MMXTypeKind;
case Type::TokenTyID:
return LLVMTokenTypeKind;
#if LLVM_VERSION_GE(11, 0)
case Type::ScalableVectorTyID:
return LLVMScalableVectorTypeKind;
case Type::BFloatTyID:
return LLVMBFloatTypeKind;
#endif
#if LLVM_VERSION_GE(12, 0)
case Type::X86_AMXTyID:
return LLVMX86_AMXTypeKind;
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,11 @@ fn check_llvm_version(builder: &Builder<'_>, llvm_config: &Path) {
let version = output(cmd.arg("--version"));
let mut parts = version.split('.').take(2).filter_map(|s| s.parse::<u32>().ok());
if let (Some(major), Some(_minor)) = (parts.next(), parts.next()) {
if major >= 10 {
if major >= 11 {
return;
}
}
panic!("\n\nbad LLVM version: {}, need >=10.0\n\n", version)
panic!("\n\nbad LLVM version: {}, need >=11.0\n\n", version)
}

fn configure_cmake(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM ubuntu:18.04
FROM ubuntu:20.04

ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
g++ \
gcc-multilib \
Expand All @@ -13,8 +14,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
cmake \
sudo \
gdb \
llvm-10-tools \
llvm-10-dev \
llvm-11-tools \
llvm-11-dev \
libedit-dev \
libssl-dev \
pkg-config \
Expand All @@ -28,7 +29,7 @@ RUN sh /scripts/sccache.sh
# using llvm-link-shared due to libffi issues -- see #34486
ENV RUST_CONFIGURE_ARGS \
--build=x86_64-unknown-linux-gnu \
--llvm-root=/usr/lib/llvm-10 \
--llvm-root=/usr/lib/llvm-11 \
--enable-llvm-link-shared \
--set rust.thin-lto-import-instr-limit=10

Expand Down
4 changes: 2 additions & 2 deletions src/ci/github-actions/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ jobs:
- name: mingw-check
<<: *job-linux-xl

- name: x86_64-gnu-llvm-10
- name: x86_64-gnu-llvm-11
<<: *job-linux-xl

- name: x86_64-gnu-tools
Expand Down Expand Up @@ -431,7 +431,7 @@ jobs:
- name: x86_64-gnu-distcheck
<<: *job-linux-xl

- name: x86_64-gnu-llvm-10
- name: x86_64-gnu-llvm-11
env:
RUST_BACKTRACE: 1
<<: *job-linux-xl
Expand Down
1 change: 0 additions & 1 deletion src/test/assembly/asm/aarch64-modifiers.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// min-llvm-version: 10.0.1
// assembly-output: emit-asm
// compile-flags: -O
// compile-flags: --target aarch64-unknown-linux-gnu
Expand Down
1 change: 0 additions & 1 deletion src/test/assembly/asm/aarch64-types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// min-llvm-version: 10.0.1
// assembly-output: emit-asm
// compile-flags: --target aarch64-unknown-linux-gnu
// needs-llvm-components: aarch64
Expand Down
1 change: 0 additions & 1 deletion src/test/assembly/asm/arm-modifiers.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// min-llvm-version: 10.0.1
// assembly-output: emit-asm
// compile-flags: -O
// compile-flags: --target armv7-unknown-linux-gnueabihf
Expand Down
1 change: 0 additions & 1 deletion src/test/assembly/asm/arm-types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// min-llvm-version: 10.0.1
// assembly-output: emit-asm
// compile-flags: --target armv7-unknown-linux-gnueabihf
// compile-flags: -C target-feature=+neon
Expand Down
1 change: 0 additions & 1 deletion src/test/assembly/asm/global_asm.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// min-llvm-version: 10.0.1
// only-x86_64
// assembly-output: emit-asm
// compile-flags: -C llvm-args=--x86-asm-syntax=intel
Expand Down
1 change: 0 additions & 1 deletion src/test/assembly/asm/hexagon-types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// min-llvm-version: 10.0.1
// assembly-output: emit-asm
// compile-flags: --target hexagon-unknown-linux-musl
// needs-llvm-components: hexagon
Expand Down
1 change: 0 additions & 1 deletion src/test/assembly/asm/mips-types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// min-llvm-version: 10.0.1
// revisions: mips32 mips64
// assembly-output: emit-asm
//[mips32] compile-flags: --target mips-unknown-linux-gnu
Expand Down
Loading

0 comments on commit 684402e

Please sign in to comment.