Auto merge of #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 #114148 [Relevant zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/riscv.20forced-atomics)
This commit is contained in:
commit
49b3924bd4
65 changed files with 42 additions and 251 deletions
|
@ -42,11 +42,7 @@
|
|||
#include "llvm/IR/IRPrintingPasses.h"
|
||||
#include "llvm/Linker/Linker.h"
|
||||
|
||||
#if LLVM_VERSION_GE(16, 0)
|
||||
#include "llvm/TargetParser/Triple.h"
|
||||
#else
|
||||
#include "llvm/ADT/Triple.h"
|
||||
#endif
|
||||
|
||||
extern "C" void LLVMRustSetLastError(const char *);
|
||||
|
||||
|
|
|
@ -204,11 +204,7 @@ enum class LLVMRustCodeModel {
|
|||
None,
|
||||
};
|
||||
|
||||
#if LLVM_VERSION_LT(16, 0)
|
||||
static Optional<CodeModel::Model>
|
||||
#else
|
||||
static std::optional<CodeModel::Model>
|
||||
#endif
|
||||
fromRust(LLVMRustCodeModel Model) {
|
||||
switch (Model) {
|
||||
case LLVMRustCodeModel::Tiny:
|
||||
|
@ -222,11 +218,7 @@ fromRust(LLVMRustCodeModel Model) {
|
|||
case LLVMRustCodeModel::Large:
|
||||
return CodeModel::Large;
|
||||
case LLVMRustCodeModel::None:
|
||||
#if LLVM_VERSION_LT(16, 0)
|
||||
return None;
|
||||
#else
|
||||
return std::nullopt;
|
||||
#endif
|
||||
default:
|
||||
report_fatal_error("Bad CodeModel.");
|
||||
}
|
||||
|
@ -452,7 +444,6 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
|
|||
if (OutputObjFile) {
|
||||
Options.ObjectFilenameForDebug = OutputObjFile;
|
||||
}
|
||||
#if LLVM_VERSION_GE(16, 0)
|
||||
if (!strcmp("zlib", DebugInfoCompression) && llvm::compression::zlib::isAvailable()) {
|
||||
Options.CompressDebugSections = DebugCompressionType::Zlib;
|
||||
} else if (!strcmp("zstd", DebugInfoCompression) && llvm::compression::zstd::isAvailable()) {
|
||||
|
@ -460,7 +451,6 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
|
|||
} else if (!strcmp("none", DebugInfoCompression)) {
|
||||
Options.CompressDebugSections = DebugCompressionType::None;
|
||||
}
|
||||
#endif
|
||||
|
||||
Options.RelaxELFRelocations = RelaxELFRelocations;
|
||||
Options.UseInitArray = UseInitArray;
|
||||
|
@ -734,22 +724,14 @@ LLVMRustOptimize(
|
|||
bool DebugPassManager = false;
|
||||
|
||||
PassInstrumentationCallbacks PIC;
|
||||
#if LLVM_VERSION_LT(16, 0)
|
||||
StandardInstrumentations SI(DebugPassManager);
|
||||
#else
|
||||
StandardInstrumentations SI(TheModule->getContext(), DebugPassManager);
|
||||
#endif
|
||||
SI.registerCallbacks(PIC);
|
||||
|
||||
if (LlvmSelfProfiler){
|
||||
LLVMSelfProfileInitializeCallbacks(PIC,LlvmSelfProfiler,BeforePassCallback,AfterPassCallback);
|
||||
}
|
||||
|
||||
#if LLVM_VERSION_LT(16, 0)
|
||||
Optional<PGOOptions> PGOOpt;
|
||||
#else
|
||||
std::optional<PGOOptions> PGOOpt;
|
||||
#endif
|
||||
#if LLVM_VERSION_GE(17, 0)
|
||||
auto FS = vfs::getRealFileSystem();
|
||||
#endif
|
||||
|
@ -882,12 +864,7 @@ LLVMRustOptimize(
|
|||
/*EagerChecks=*/true);
|
||||
OptimizerLastEPCallbacks.push_back(
|
||||
[Options](ModulePassManager &MPM, OptimizationLevel Level) {
|
||||
#if LLVM_VERSION_LT(16, 0)
|
||||
MPM.addPass(ModuleMemorySanitizerPass(Options));
|
||||
MPM.addPass(createModuleToFunctionPassAdaptor(MemorySanitizerPass(Options)));
|
||||
#else
|
||||
MPM.addPass(MemorySanitizerPass(Options));
|
||||
#endif
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -912,11 +889,7 @@ LLVMRustOptimize(
|
|||
/*UseAfterScope=*/true,
|
||||
AsanDetectStackUseAfterReturnMode::Runtime,
|
||||
};
|
||||
#if LLVM_VERSION_LT(16, 0)
|
||||
MPM.addPass(ModuleAddressSanitizerPass(opts));
|
||||
#else
|
||||
MPM.addPass(AddressSanitizerPass(opts));
|
||||
#endif
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -14,18 +14,13 @@
|
|||
#include "llvm/Remarks/RemarkSerializer.h"
|
||||
#include "llvm/Remarks/RemarkFormat.h"
|
||||
#include "llvm/Support/ToolOutputFile.h"
|
||||
#if LLVM_VERSION_GE(16, 0)
|
||||
#include "llvm/Support/ModRef.h"
|
||||
#endif
|
||||
#include "llvm/Object/Archive.h"
|
||||
#include "llvm/Object/COFFImportFile.h"
|
||||
#include "llvm/Object/ObjectFile.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/Bitcode/BitcodeWriter.h"
|
||||
#include "llvm/Support/Signals.h"
|
||||
#if LLVM_VERSION_LT(16, 0)
|
||||
#include "llvm/ADT/Optional.h"
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
@ -347,13 +342,7 @@ extern "C" LLVMAttributeRef LLVMRustCreateUWTableAttr(LLVMContextRef C, bool Asy
|
|||
}
|
||||
|
||||
extern "C" LLVMAttributeRef LLVMRustCreateAllocSizeAttr(LLVMContextRef C, uint32_t ElementSizeArg) {
|
||||
return wrap(Attribute::getWithAllocSizeArgs(*unwrap(C), ElementSizeArg,
|
||||
#if LLVM_VERSION_LT(16, 0)
|
||||
None
|
||||
#else
|
||||
std::nullopt
|
||||
#endif
|
||||
));
|
||||
return wrap(Attribute::getWithAllocSizeArgs(*unwrap(C), ElementSizeArg, std::nullopt));
|
||||
}
|
||||
|
||||
// These values **must** match ffi::AllocKindFlags.
|
||||
|
@ -416,7 +405,6 @@ enum class LLVMRustMemoryEffects {
|
|||
|
||||
extern "C" LLVMAttributeRef LLVMRustCreateMemoryEffectsAttr(LLVMContextRef C,
|
||||
LLVMRustMemoryEffects Effects) {
|
||||
#if LLVM_VERSION_GE(16, 0)
|
||||
switch (Effects) {
|
||||
case LLVMRustMemoryEffects::None:
|
||||
return wrap(Attribute::getWithMemoryEffects(*unwrap(C), MemoryEffects::none()));
|
||||
|
@ -428,18 +416,6 @@ extern "C" LLVMAttributeRef LLVMRustCreateMemoryEffectsAttr(LLVMContextRef C,
|
|||
default:
|
||||
report_fatal_error("bad MemoryEffects.");
|
||||
}
|
||||
#else
|
||||
switch (Effects) {
|
||||
case LLVMRustMemoryEffects::None:
|
||||
return wrap(Attribute::get(*unwrap(C), Attribute::ReadNone));
|
||||
case LLVMRustMemoryEffects::ReadOnly:
|
||||
return wrap(Attribute::get(*unwrap(C), Attribute::ReadOnly));
|
||||
case LLVMRustMemoryEffects::InaccessibleMemOnly:
|
||||
return wrap(Attribute::get(*unwrap(C), Attribute::InaccessibleMemOnly));
|
||||
default:
|
||||
report_fatal_error("bad MemoryEffects.");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Enable a fast-math flag
|
||||
|
@ -726,18 +702,10 @@ enum class LLVMRustChecksumKind {
|
|||
SHA256,
|
||||
};
|
||||
|
||||
#if LLVM_VERSION_LT(16, 0)
|
||||
static Optional<DIFile::ChecksumKind> fromRust(LLVMRustChecksumKind Kind) {
|
||||
#else
|
||||
static std::optional<DIFile::ChecksumKind> fromRust(LLVMRustChecksumKind Kind) {
|
||||
#endif
|
||||
switch (Kind) {
|
||||
case LLVMRustChecksumKind::None:
|
||||
#if LLVM_VERSION_LT(16, 0)
|
||||
return None;
|
||||
#else
|
||||
return std::nullopt;
|
||||
#endif
|
||||
case LLVMRustChecksumKind::MD5:
|
||||
return DIFile::ChecksumKind::CSK_MD5;
|
||||
case LLVMRustChecksumKind::SHA1:
|
||||
|
@ -810,17 +778,8 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateFile(
|
|||
const char *Directory, size_t DirectoryLen, LLVMRustChecksumKind CSKind,
|
||||
const char *Checksum, size_t ChecksumLen) {
|
||||
|
||||
#if LLVM_VERSION_LT(16, 0)
|
||||
Optional<DIFile::ChecksumKind> llvmCSKind = fromRust(CSKind);
|
||||
#else
|
||||
std::optional<DIFile::ChecksumKind> llvmCSKind = fromRust(CSKind);
|
||||
#endif
|
||||
|
||||
#if LLVM_VERSION_LT(16, 0)
|
||||
Optional<DIFile::ChecksumInfo<StringRef>> CSInfo{};
|
||||
#else
|
||||
std::optional<DIFile::ChecksumInfo<StringRef>> CSInfo{};
|
||||
#endif
|
||||
if (llvmCSKind)
|
||||
CSInfo.emplace(*llvmCSKind, StringRef{Checksum, ChecksumLen});
|
||||
return wrap(Builder->createFile(StringRef(Filename, FilenameLen),
|
||||
|
@ -2053,17 +2012,9 @@ extern "C" bool LLVMRustIsNonGVFunctionPointerTy(LLVMValueRef V) {
|
|||
}
|
||||
|
||||
extern "C" bool LLVMRustLLVMHasZlibCompressionForDebugSymbols() {
|
||||
#if LLVM_VERSION_GE(16, 0)
|
||||
return llvm::compression::zlib::isAvailable();
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
extern "C" bool LLVMRustLLVMHasZstdCompressionForDebugSymbols() {
|
||||
#if LLVM_VERSION_GE(16, 0)
|
||||
return llvm::compression::zstd::isAvailable();
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue