Update the minimum external LLVM to 14
This commit is contained in:
parent
2773383a31
commit
a06aaa4a9e
42 changed files with 54 additions and 205 deletions
|
@ -14,6 +14,7 @@
|
|||
#include "llvm/IR/AssemblyAnnotationWriter.h"
|
||||
#include "llvm/IR/IntrinsicInst.h"
|
||||
#include "llvm/IR/Verifier.h"
|
||||
#include "llvm/MC/TargetRegistry.h"
|
||||
#include "llvm/Object/ObjectFile.h"
|
||||
#include "llvm/Object/IRObjectFile.h"
|
||||
#include "llvm/Passes/PassBuilder.h"
|
||||
|
@ -25,11 +26,6 @@
|
|||
#include "llvm/Support/VirtualFileSystem.h"
|
||||
#endif
|
||||
#include "llvm/Support/Host.h"
|
||||
#if LLVM_VERSION_LT(14, 0)
|
||||
#include "llvm/Support/TargetRegistry.h"
|
||||
#else
|
||||
#include "llvm/MC/TargetRegistry.h"
|
||||
#endif
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
|
||||
#include "llvm/Transforms/IPO/AlwaysInliner.h"
|
||||
|
@ -267,10 +263,6 @@ enum class LLVMRustPassBuilderOptLevel {
|
|||
Oz,
|
||||
};
|
||||
|
||||
#if LLVM_VERSION_LT(14,0)
|
||||
using OptimizationLevel = PassBuilder::OptimizationLevel;
|
||||
#endif
|
||||
|
||||
static OptimizationLevel fromRust(LLVMRustPassBuilderOptLevel Level) {
|
||||
switch (Level) {
|
||||
case LLVMRustPassBuilderOptLevel::O0:
|
||||
|
@ -747,27 +739,18 @@ LLVMRustOptimize(
|
|||
|
||||
if (SanitizerOptions) {
|
||||
if (SanitizerOptions->SanitizeMemory) {
|
||||
#if LLVM_VERSION_GE(14, 0)
|
||||
MemorySanitizerOptions Options(
|
||||
SanitizerOptions->SanitizeMemoryTrackOrigins,
|
||||
SanitizerOptions->SanitizeMemoryRecover,
|
||||
/*CompileKernel=*/false,
|
||||
/*EagerChecks=*/true);
|
||||
#else
|
||||
MemorySanitizerOptions Options(
|
||||
SanitizerOptions->SanitizeMemoryTrackOrigins,
|
||||
SanitizerOptions->SanitizeMemoryRecover,
|
||||
/*CompileKernel=*/false);
|
||||
#endif
|
||||
OptimizerLastEPCallbacks.push_back(
|
||||
[Options](ModulePassManager &MPM, OptimizationLevel Level) {
|
||||
#if LLVM_VERSION_GE(14, 0) && LLVM_VERSION_LT(16, 0)
|
||||
#if LLVM_VERSION_LT(16, 0)
|
||||
MPM.addPass(ModuleMemorySanitizerPass(Options));
|
||||
MPM.addPass(createModuleToFunctionPassAdaptor(MemorySanitizerPass(Options)));
|
||||
#else
|
||||
MPM.addPass(MemorySanitizerPass(Options));
|
||||
#endif
|
||||
#if LLVM_VERSION_LT(16, 0)
|
||||
MPM.addPass(createModuleToFunctionPassAdaptor(MemorySanitizerPass(Options)));
|
||||
#endif
|
||||
}
|
||||
);
|
||||
|
@ -776,11 +759,7 @@ LLVMRustOptimize(
|
|||
if (SanitizerOptions->SanitizeThread) {
|
||||
OptimizerLastEPCallbacks.push_back(
|
||||
[](ModulePassManager &MPM, OptimizationLevel Level) {
|
||||
#if LLVM_VERSION_GE(14, 0)
|
||||
MPM.addPass(ModuleThreadSanitizerPass());
|
||||
#else
|
||||
MPM.addPass(ThreadSanitizerPass());
|
||||
#endif
|
||||
MPM.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass()));
|
||||
}
|
||||
);
|
||||
|
@ -792,7 +771,6 @@ LLVMRustOptimize(
|
|||
#if LLVM_VERSION_LT(15, 0)
|
||||
MPM.addPass(RequireAnalysisPass<ASanGlobalsMetadataAnalysis, Module>());
|
||||
#endif
|
||||
#if LLVM_VERSION_GE(14, 0)
|
||||
AddressSanitizerOptions opts = AddressSanitizerOptions{
|
||||
/*CompileKernel=*/false,
|
||||
SanitizerOptions->SanitizeAddressRecover,
|
||||
|
@ -803,13 +781,6 @@ LLVMRustOptimize(
|
|||
MPM.addPass(ModuleAddressSanitizerPass(opts));
|
||||
#else
|
||||
MPM.addPass(AddressSanitizerPass(opts));
|
||||
#endif
|
||||
#else
|
||||
MPM.addPass(ModuleAddressSanitizerPass(
|
||||
/*CompileKernel=*/false, SanitizerOptions->SanitizeAddressRecover));
|
||||
MPM.addPass(createModuleToFunctionPassAdaptor(AddressSanitizerPass(
|
||||
/*CompileKernel=*/false, SanitizerOptions->SanitizeAddressRecover,
|
||||
/*UseAfterScope=*/true)));
|
||||
#endif
|
||||
}
|
||||
);
|
||||
|
@ -817,15 +788,10 @@ LLVMRustOptimize(
|
|||
if (SanitizerOptions->SanitizeHWAddress) {
|
||||
OptimizerLastEPCallbacks.push_back(
|
||||
[SanitizerOptions](ModulePassManager &MPM, OptimizationLevel Level) {
|
||||
#if LLVM_VERSION_GE(14, 0)
|
||||
HWAddressSanitizerOptions opts(
|
||||
/*CompileKernel=*/false, SanitizerOptions->SanitizeHWAddressRecover,
|
||||
/*DisableOptimization=*/false);
|
||||
MPM.addPass(HWAddressSanitizerPass(opts));
|
||||
#else
|
||||
MPM.addPass(HWAddressSanitizerPass(
|
||||
/*CompileKernel=*/false, SanitizerOptions->SanitizeHWAddressRecover));
|
||||
#endif
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -1328,11 +1294,7 @@ extern "C" bool
|
|||
LLVMRustPrepareThinLTOResolveWeak(const LLVMRustThinLTOData *Data, LLVMModuleRef M) {
|
||||
Module &Mod = *unwrap(M);
|
||||
const auto &DefinedGlobals = Data->ModuleToDefinedGVSummaries.lookup(Mod.getModuleIdentifier());
|
||||
#if LLVM_VERSION_GE(14, 0)
|
||||
thinLTOFinalizeInModule(Mod, DefinedGlobals, /*PropagateAttrs=*/true);
|
||||
#else
|
||||
thinLTOResolvePrevailingInModule(Mod, DefinedGlobals);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,11 +63,7 @@ static LLVM_THREAD_LOCAL char *LastError;
|
|||
//
|
||||
// Notably it exits the process with code 101, unlike LLVM's default of 1.
|
||||
static void FatalErrorHandler(void *UserData,
|
||||
#if LLVM_VERSION_LT(14, 0)
|
||||
const std::string& Reason,
|
||||
#else
|
||||
const char* Reason,
|
||||
#endif
|
||||
bool GenCrashDiag) {
|
||||
// Do the same thing that the default error handler does.
|
||||
std::cerr << "LLVM ERROR: " << Reason << std::endl;
|
||||
|
@ -249,18 +245,10 @@ static Attribute::AttrKind fromRust(LLVMRustAttribute Kind) {
|
|||
template<typename T> static inline void AddAttributes(T *t, unsigned Index,
|
||||
LLVMAttributeRef *Attrs, size_t AttrsLen) {
|
||||
AttributeList PAL = t->getAttributes();
|
||||
AttributeList PALNew;
|
||||
#if LLVM_VERSION_LT(14, 0)
|
||||
AttrBuilder B;
|
||||
for (LLVMAttributeRef Attr : makeArrayRef(Attrs, AttrsLen))
|
||||
B.addAttribute(unwrap(Attr));
|
||||
PALNew = PAL.addAttributes(t->getContext(), Index, B);
|
||||
#else
|
||||
AttrBuilder B(t->getContext());
|
||||
for (LLVMAttributeRef Attr : ArrayRef<LLVMAttributeRef>(Attrs, AttrsLen))
|
||||
B.addAttribute(unwrap(Attr));
|
||||
PALNew = PAL.addAttributesAtIndex(t->getContext(), Index, B);
|
||||
#endif
|
||||
AttributeList PALNew = PAL.addAttributesAtIndex(t->getContext(), Index, B);
|
||||
t->setAttributes(PALNew);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue