Update the minimum external LLVM to 18
This commit is contained in:
parent
f79a912d9e
commit
6fd8a50680
57 changed files with 89 additions and 401 deletions
|
@ -196,14 +196,10 @@ extern "C" LLVMRustResult LLVMRustWriteArchive(
|
|||
}
|
||||
}
|
||||
|
||||
#if LLVM_VERSION_LT(18, 0)
|
||||
auto Result = writeArchive(Dst, Members, WriteSymbtab, Kind, true, false);
|
||||
#else
|
||||
auto SymtabMode = WriteSymbtab ? SymtabWritingMode::NormalSymtab
|
||||
: SymtabWritingMode::NoSymtab;
|
||||
auto Result =
|
||||
writeArchive(Dst, Members, SymtabMode, Kind, true, false, nullptr, isEC);
|
||||
#endif
|
||||
if (!Result)
|
||||
return LLVMRustResult::Success;
|
||||
LLVMRustSetLastError(toString(std::move(Result)).c_str());
|
||||
|
|
|
@ -58,17 +58,10 @@ fromRust(LLVMRustCounterMappingRegionKind Kind) {
|
|||
return coverage::CounterMappingRegion::GapRegion;
|
||||
case LLVMRustCounterMappingRegionKind::BranchRegion:
|
||||
return coverage::CounterMappingRegion::BranchRegion;
|
||||
#if LLVM_VERSION_GE(18, 0)
|
||||
case LLVMRustCounterMappingRegionKind::MCDCDecisionRegion:
|
||||
return coverage::CounterMappingRegion::MCDCDecisionRegion;
|
||||
case LLVMRustCounterMappingRegionKind::MCDCBranchRegion:
|
||||
return coverage::CounterMappingRegion::MCDCBranchRegion;
|
||||
#else
|
||||
case LLVMRustCounterMappingRegionKind::MCDCDecisionRegion:
|
||||
break;
|
||||
case LLVMRustCounterMappingRegionKind::MCDCBranchRegion:
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
report_fatal_error("Bad LLVMRustCounterMappingRegionKind!");
|
||||
}
|
||||
|
@ -100,7 +93,7 @@ struct LLVMRustMCDCParameters {
|
|||
// https://github.com/rust-lang/llvm-project/blob/66a2881a/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h#L253-L263
|
||||
// and representations in 19
|
||||
// https://github.com/llvm/llvm-project/blob/843cc474faefad1d639f4c44c1cf3ad7dbda76c8/llvm/include/llvm/ProfileData/Coverage/MCDCTypes.h
|
||||
#if LLVM_VERSION_GE(18, 0) && LLVM_VERSION_LT(19, 0)
|
||||
#if LLVM_VERSION_LT(19, 0)
|
||||
static coverage::CounterMappingRegion::MCDCParameters
|
||||
fromRust(LLVMRustMCDCParameters Params) {
|
||||
auto parameter = coverage::CounterMappingRegion::MCDCParameters{};
|
||||
|
@ -126,7 +119,7 @@ fromRust(LLVMRustMCDCParameters Params) {
|
|||
}
|
||||
report_fatal_error("Bad LLVMRustMCDCParametersTag!");
|
||||
}
|
||||
#elif LLVM_VERSION_GE(19, 0)
|
||||
#else
|
||||
static coverage::mcdc::Parameters fromRust(LLVMRustMCDCParameters Params) {
|
||||
switch (Params.Tag) {
|
||||
case LLVMRustMCDCParametersTag::None:
|
||||
|
@ -221,7 +214,7 @@ extern "C" void LLVMRustCoverageWriteMappingToBuffer(
|
|||
RustMappingRegions, NumMappingRegions)) {
|
||||
MappingRegions.emplace_back(
|
||||
fromRust(Region.Count), fromRust(Region.FalseCount),
|
||||
#if LLVM_VERSION_GE(18, 0) && LLVM_VERSION_LT(19, 0)
|
||||
#if LLVM_VERSION_LT(19, 0)
|
||||
// LLVM 19 may move this argument to last.
|
||||
fromRust(Region.MCDCParameters),
|
||||
#endif
|
||||
|
|
|
@ -26,21 +26,19 @@
|
|||
#include "llvm/Passes/StandardInstrumentations.h"
|
||||
#include "llvm/Support/CBindingWrapping.h"
|
||||
#include "llvm/Support/FileSystem.h"
|
||||
#include "llvm/Support/TimeProfiler.h"
|
||||
#include "llvm/Support/VirtualFileSystem.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/TargetParser/Host.h"
|
||||
#include "llvm/Transforms/IPO/AlwaysInliner.h"
|
||||
#include "llvm/Transforms/IPO/FunctionImport.h"
|
||||
#include "llvm/Transforms/IPO/Internalize.h"
|
||||
#include "llvm/Transforms/IPO/LowerTypeTests.h"
|
||||
#include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
|
||||
#include "llvm/Transforms/Utils/AddDiscriminators.h"
|
||||
#include "llvm/Transforms/Utils/FunctionImportUtils.h"
|
||||
#if LLVM_VERSION_GE(18, 0)
|
||||
#include "llvm/TargetParser/Host.h"
|
||||
#endif
|
||||
#include "llvm/Support/TimeProfiler.h"
|
||||
#include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
|
||||
#include "llvm/Transforms/Instrumentation/DataFlowSanitizer.h"
|
||||
#include "llvm/Transforms/Utils/AddDiscriminators.h"
|
||||
#include "llvm/Transforms/Utils/FunctionImportUtils.h"
|
||||
#if LLVM_VERSION_GE(19, 0)
|
||||
#include "llvm/Support/PGOOptions.h"
|
||||
#endif
|
||||
|
@ -240,11 +238,7 @@ enum class LLVMRustCodeGenOptLevel {
|
|||
Aggressive,
|
||||
};
|
||||
|
||||
#if LLVM_VERSION_GE(18, 0)
|
||||
using CodeGenOptLevelEnum = llvm::CodeGenOptLevel;
|
||||
#else
|
||||
using CodeGenOptLevelEnum = llvm::CodeGenOpt::Level;
|
||||
#endif
|
||||
|
||||
static CodeGenOptLevelEnum fromRust(LLVMRustCodeGenOptLevel Level) {
|
||||
switch (Level) {
|
||||
|
@ -370,21 +364,16 @@ extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM,
|
|||
}
|
||||
|
||||
extern "C" size_t LLVMRustGetTargetFeaturesCount(LLVMTargetMachineRef TM) {
|
||||
#if LLVM_VERSION_GE(18, 0)
|
||||
const TargetMachine *Target = unwrap(TM);
|
||||
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
|
||||
const ArrayRef<SubtargetFeatureKV> FeatTable =
|
||||
MCInfo->getAllProcessorFeatures();
|
||||
return FeatTable.size();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
extern "C" void LLVMRustGetTargetFeature(LLVMTargetMachineRef TM, size_t Index,
|
||||
const char **Feature,
|
||||
const char **Desc) {
|
||||
#if LLVM_VERSION_GE(18, 0)
|
||||
const TargetMachine *Target = unwrap(TM);
|
||||
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
|
||||
const ArrayRef<SubtargetFeatureKV> FeatTable =
|
||||
|
@ -392,7 +381,6 @@ extern "C" void LLVMRustGetTargetFeature(LLVMTargetMachineRef TM, size_t Index,
|
|||
const SubtargetFeatureKV Feat = FeatTable[Index];
|
||||
*Feature = Feat.Key;
|
||||
*Desc = Feat.Desc;
|
||||
#endif
|
||||
}
|
||||
|
||||
extern "C" const char *LLVMRustGetHostCPUName(size_t *len) {
|
||||
|
@ -569,17 +557,9 @@ enum class LLVMRustFileType {
|
|||
static CodeGenFileType fromRust(LLVMRustFileType Type) {
|
||||
switch (Type) {
|
||||
case LLVMRustFileType::AssemblyFile:
|
||||
#if LLVM_VERSION_GE(18, 0)
|
||||
return CodeGenFileType::AssemblyFile;
|
||||
#else
|
||||
return CGFT_AssemblyFile;
|
||||
#endif
|
||||
case LLVMRustFileType::ObjectFile:
|
||||
#if LLVM_VERSION_GE(18, 0)
|
||||
return CodeGenFileType::ObjectFile;
|
||||
#else
|
||||
return CGFT_ObjectFile;
|
||||
#endif
|
||||
default:
|
||||
report_fatal_error("Bad FileType.");
|
||||
}
|
||||
|
@ -865,11 +845,7 @@ extern "C" LLVMRustResult LLVMRustOptimize(
|
|||
// cargo run tests in multhreading mode by default
|
||||
// so use atomics for coverage counters
|
||||
Options.Atomic = true;
|
||||
#if LLVM_VERSION_GE(18, 0)
|
||||
MPM.addPass(InstrProfilingLoweringPass(Options, false));
|
||||
#else
|
||||
MPM.addPass(InstrProfiling(Options, false));
|
||||
#endif
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1210,7 +1186,6 @@ struct LLVMRustThinLTOData {
|
|||
|
||||
// Not 100% sure what these are, but they impact what's internalized and
|
||||
// what's inlined across modules, I believe.
|
||||
#if LLVM_VERSION_GE(18, 0)
|
||||
#if LLVM_VERSION_GE(20, 0)
|
||||
FunctionImporter::ImportListsTy ImportLists;
|
||||
#else
|
||||
|
@ -1218,11 +1193,6 @@ struct LLVMRustThinLTOData {
|
|||
#endif
|
||||
DenseMap<StringRef, FunctionImporter::ExportSetTy> ExportLists;
|
||||
DenseMap<StringRef, GVSummaryMapTy> ModuleToDefinedGVSummaries;
|
||||
#else
|
||||
StringMap<FunctionImporter::ImportMapTy> ImportLists;
|
||||
StringMap<FunctionImporter::ExportSetTy> ExportLists;
|
||||
StringMap<GVSummaryMapTy> ModuleToDefinedGVSummaries;
|
||||
#endif
|
||||
StringMap<std::map<GlobalValue::GUID, GlobalValue::LinkageTypes>> ResolvedODR;
|
||||
|
||||
LLVMRustThinLTOData() : Index(/* HaveGVs = */ false) {}
|
||||
|
@ -1274,11 +1244,7 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules, int num_modules,
|
|||
|
||||
Ret->ModuleMap[module->identifier] = mem_buffer;
|
||||
|
||||
#if LLVM_VERSION_GE(18, 0)
|
||||
if (Error Err = readModuleSummaryIndex(mem_buffer, Ret->Index)) {
|
||||
#else
|
||||
if (Error Err = readModuleSummaryIndex(mem_buffer, Ret->Index, i)) {
|
||||
#endif
|
||||
LLVMRustSetLastError(toString(std::move(Err)).c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -310,16 +310,10 @@ static Attribute::AttrKind fromRust(LLVMRustAttribute Kind) {
|
|||
return Attribute::SafeStack;
|
||||
case FnRetThunkExtern:
|
||||
return Attribute::FnRetThunkExtern;
|
||||
#if LLVM_VERSION_GE(18, 0)
|
||||
case Writable:
|
||||
return Attribute::Writable;
|
||||
case DeadOnUnwind:
|
||||
return Attribute::DeadOnUnwind;
|
||||
#else
|
||||
case Writable:
|
||||
case DeadOnUnwind:
|
||||
report_fatal_error("Not supported on this LLVM version");
|
||||
#endif
|
||||
}
|
||||
report_fatal_error("bad AttributeKind");
|
||||
}
|
||||
|
@ -1061,11 +1055,7 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateStaticMemberType(
|
|||
return wrap(Builder->createStaticMemberType(
|
||||
unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen),
|
||||
unwrapDI<DIFile>(File), LineNo, unwrapDI<DIType>(Ty), fromRust(Flags),
|
||||
unwrap<llvm::ConstantInt>(val),
|
||||
#if LLVM_VERSION_GE(18, 0)
|
||||
llvm::dwarf::DW_TAG_member,
|
||||
#endif
|
||||
AlignInBits));
|
||||
unwrap<llvm::ConstantInt>(val), llvm::dwarf::DW_TAG_member, AlignInBits));
|
||||
}
|
||||
|
||||
extern "C" LLVMMetadataRef
|
||||
|
@ -1182,10 +1172,7 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateEnumerationType(
|
|||
unwrapDI<DIDescriptor>(Scope), StringRef(Name, NameLen),
|
||||
unwrapDI<DIFile>(File), LineNumber, SizeInBits, AlignInBits,
|
||||
DINodeArray(unwrapDI<MDTuple>(Elements)), unwrapDI<DIType>(ClassTy),
|
||||
#if LLVM_VERSION_GE(18, 0)
|
||||
/* RunTimeLang */ 0,
|
||||
#endif
|
||||
"", IsScoped));
|
||||
/* RunTimeLang */ 0, "", IsScoped));
|
||||
}
|
||||
|
||||
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateUnionType(
|
||||
|
@ -1552,27 +1539,19 @@ LLVMRustGetInstrProfIncrementIntrinsic(LLVMModuleRef M) {
|
|||
|
||||
extern "C" LLVMValueRef
|
||||
LLVMRustGetInstrProfMCDCParametersIntrinsic(LLVMModuleRef M) {
|
||||
#if LLVM_VERSION_GE(18, 0)
|
||||
return wrap(llvm::Intrinsic::getDeclaration(
|
||||
unwrap(M), llvm::Intrinsic::instrprof_mcdc_parameters));
|
||||
#else
|
||||
report_fatal_error("LLVM 18.0 is required for mcdc intrinsic functions");
|
||||
#endif
|
||||
}
|
||||
|
||||
extern "C" LLVMValueRef
|
||||
LLVMRustGetInstrProfMCDCTVBitmapUpdateIntrinsic(LLVMModuleRef M) {
|
||||
#if LLVM_VERSION_GE(18, 0)
|
||||
return wrap(llvm::Intrinsic::getDeclaration(
|
||||
unwrap(M), llvm::Intrinsic::instrprof_mcdc_tvbitmap_update));
|
||||
#else
|
||||
report_fatal_error("LLVM 18.0 is required for mcdc intrinsic functions");
|
||||
#endif
|
||||
}
|
||||
|
||||
extern "C" LLVMValueRef
|
||||
LLVMRustGetInstrProfMCDCCondBitmapIntrinsic(LLVMModuleRef M) {
|
||||
#if LLVM_VERSION_GE(18, 0) && LLVM_VERSION_LT(19, 0)
|
||||
#if LLVM_VERSION_LT(19, 0)
|
||||
return wrap(llvm::Intrinsic::getDeclaration(
|
||||
unwrap(M), llvm::Intrinsic::instrprof_mcdc_condbitmap_update));
|
||||
#else
|
||||
|
|
|
@ -150,11 +150,9 @@ extern "C" bool LLVMRustIsECObject(char *BufPtr, size_t BufLen) {
|
|||
return cast<llvm::object::COFFObjectFile>(&*Obj)->getMachine() !=
|
||||
COFF::IMAGE_FILE_MACHINE_ARM64;
|
||||
|
||||
#if LLVM_VERSION_GE(18, 0)
|
||||
if (Obj->isCOFFImportFile())
|
||||
return cast<llvm::object::COFFImportFile>(&*Obj)->getMachine() !=
|
||||
COFF::IMAGE_FILE_MACHINE_ARM64;
|
||||
#endif
|
||||
|
||||
if (Obj->isIR()) {
|
||||
Expected<std::string> TripleStr =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue