Update the minimum external LLVM to 19
This commit is contained in:
parent
0c478fdfe1
commit
12167d7064
70 changed files with 222 additions and 1911 deletions
|
@ -47,7 +47,6 @@ struct LLVMRustMCDCBranchParameters {
|
|||
int16_t ConditionIDs[2];
|
||||
};
|
||||
|
||||
#if LLVM_VERSION_GE(19, 0)
|
||||
static coverage::mcdc::BranchParameters
|
||||
fromRust(LLVMRustMCDCBranchParameters Params) {
|
||||
return coverage::mcdc::BranchParameters(
|
||||
|
@ -59,7 +58,6 @@ fromRust(LLVMRustMCDCDecisionParameters Params) {
|
|||
return coverage::mcdc::DecisionParameters(Params.BitmapIdx,
|
||||
Params.NumConditions);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Must match the layout of
|
||||
// `rustc_codegen_llvm::coverageinfo::ffi::CoverageSpan`.
|
||||
|
@ -203,7 +201,6 @@ extern "C" void LLVMRustCoverageWriteFunctionMappingsToBuffer(
|
|||
Region.Span.LineEnd, Region.Span.ColumnEnd));
|
||||
}
|
||||
|
||||
#if LLVM_VERSION_GE(19, 0)
|
||||
// MC/DC branch regions:
|
||||
for (const auto &Region : ArrayRef(MCDCBranchRegions, NumMCDCBranchRegions)) {
|
||||
MappingRegions.push_back(coverage::CounterMappingRegion::makeBranchRegion(
|
||||
|
@ -221,7 +218,6 @@ extern "C" void LLVMRustCoverageWriteFunctionMappingsToBuffer(
|
|||
Region.Span.LineStart, Region.Span.ColumnStart, Region.Span.LineEnd,
|
||||
Region.Span.ColumnEnd));
|
||||
}
|
||||
#endif
|
||||
|
||||
// Write the converted expressions and mappings to a byte buffer.
|
||||
auto CoverageMappingWriter = coverage::CoverageMappingWriter(
|
||||
|
|
|
@ -47,10 +47,7 @@
|
|||
#include <vector>
|
||||
|
||||
// Conditional includes prevent clang-format from fully sorting the list,
|
||||
// so keep them separate.
|
||||
#if LLVM_VERSION_GE(19, 0)
|
||||
#include "llvm/Support/PGOOptions.h"
|
||||
#endif
|
||||
// so if any are needed, keep them separate down here.
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
|
@ -432,31 +429,15 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
|
|||
}
|
||||
if (!strcmp("zlib", DebugInfoCompression) &&
|
||||
llvm::compression::zlib::isAvailable()) {
|
||||
#if LLVM_VERSION_GE(19, 0)
|
||||
Options.MCOptions.CompressDebugSections = DebugCompressionType::Zlib;
|
||||
#else
|
||||
Options.CompressDebugSections = DebugCompressionType::Zlib;
|
||||
#endif
|
||||
} else if (!strcmp("zstd", DebugInfoCompression) &&
|
||||
llvm::compression::zstd::isAvailable()) {
|
||||
#if LLVM_VERSION_GE(19, 0)
|
||||
Options.MCOptions.CompressDebugSections = DebugCompressionType::Zstd;
|
||||
#else
|
||||
Options.CompressDebugSections = DebugCompressionType::Zstd;
|
||||
#endif
|
||||
} else if (!strcmp("none", DebugInfoCompression)) {
|
||||
#if LLVM_VERSION_GE(19, 0)
|
||||
Options.MCOptions.CompressDebugSections = DebugCompressionType::None;
|
||||
#else
|
||||
Options.CompressDebugSections = DebugCompressionType::None;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if LLVM_VERSION_GE(19, 0)
|
||||
Options.MCOptions.X86RelaxRelocations = RelaxELFRelocations;
|
||||
#else
|
||||
Options.RelaxELFRelocations = RelaxELFRelocations;
|
||||
#endif
|
||||
Options.UseInitArray = UseInitArray;
|
||||
Options.EmulatedTLS = UseEmulatedTls;
|
||||
|
||||
|
@ -753,34 +734,23 @@ extern "C" LLVMRustResult LLVMRustOptimize(
|
|||
auto FS = vfs::getRealFileSystem();
|
||||
if (PGOGenPath) {
|
||||
assert(!PGOUsePath && !PGOSampleUsePath);
|
||||
PGOOpt = PGOOptions(PGOGenPath, "", "", "", FS, PGOOptions::IRInstr,
|
||||
PGOOptions::NoCSAction,
|
||||
#if LLVM_VERSION_GE(19, 0)
|
||||
PGOOptions::ColdFuncOpt::Default,
|
||||
#endif
|
||||
DebugInfoForProfiling);
|
||||
PGOOpt = PGOOptions(
|
||||
PGOGenPath, "", "", "", FS, PGOOptions::IRInstr, PGOOptions::NoCSAction,
|
||||
PGOOptions::ColdFuncOpt::Default, DebugInfoForProfiling);
|
||||
} else if (PGOUsePath) {
|
||||
assert(!PGOSampleUsePath);
|
||||
PGOOpt = PGOOptions(PGOUsePath, "", "", "", FS, PGOOptions::IRUse,
|
||||
PGOOptions::NoCSAction,
|
||||
#if LLVM_VERSION_GE(19, 0)
|
||||
PGOOptions::ColdFuncOpt::Default,
|
||||
#endif
|
||||
DebugInfoForProfiling);
|
||||
PGOOpt = PGOOptions(
|
||||
PGOUsePath, "", "", "", FS, PGOOptions::IRUse, PGOOptions::NoCSAction,
|
||||
PGOOptions::ColdFuncOpt::Default, DebugInfoForProfiling);
|
||||
} else if (PGOSampleUsePath) {
|
||||
PGOOpt = PGOOptions(PGOSampleUsePath, "", "", "", FS, PGOOptions::SampleUse,
|
||||
PGOOptions::NoCSAction,
|
||||
#if LLVM_VERSION_GE(19, 0)
|
||||
PGOOptions::ColdFuncOpt::Default,
|
||||
#endif
|
||||
DebugInfoForProfiling);
|
||||
PGOOpt =
|
||||
PGOOptions(PGOSampleUsePath, "", "", "", FS, PGOOptions::SampleUse,
|
||||
PGOOptions::NoCSAction, PGOOptions::ColdFuncOpt::Default,
|
||||
DebugInfoForProfiling);
|
||||
} else if (DebugInfoForProfiling) {
|
||||
PGOOpt = PGOOptions("", "", "", "", FS, PGOOptions::NoAction,
|
||||
PGOOptions::NoCSAction,
|
||||
#if LLVM_VERSION_GE(19, 0)
|
||||
PGOOptions::ColdFuncOpt::Default,
|
||||
#endif
|
||||
DebugInfoForProfiling);
|
||||
PGOOpt = PGOOptions(
|
||||
"", "", "", "", FS, PGOOptions::NoAction, PGOOptions::NoCSAction,
|
||||
PGOOptions::ColdFuncOpt::Default, DebugInfoForProfiling);
|
||||
}
|
||||
|
||||
auto PB = PassBuilder(TM, PTO, PGOOpt, &PIC);
|
||||
|
|
|
@ -473,12 +473,8 @@ extern "C" LLVMAttributeRef
|
|||
LLVMRustCreateRangeAttribute(LLVMContextRef C, unsigned NumBits,
|
||||
const uint64_t LowerWords[],
|
||||
const uint64_t UpperWords[]) {
|
||||
#if LLVM_VERSION_GE(19, 0)
|
||||
return LLVMCreateConstantRangeAttribute(C, Attribute::Range, NumBits,
|
||||
LowerWords, UpperWords);
|
||||
#else
|
||||
report_fatal_error("LLVM 19.0 is required for Range Attribute");
|
||||
#endif
|
||||
}
|
||||
|
||||
// These values **must** match ffi::AllocKindFlags.
|
||||
|
@ -1601,43 +1597,6 @@ extern "C" LLVMValueRef LLVMRustBuildMemSet(LLVMBuilderRef B, LLVMValueRef Dst,
|
|||
MaybeAlign(DstAlign), IsVolatile));
|
||||
}
|
||||
|
||||
// Polyfill for `LLVMBuildCallBr`, which was added in LLVM 19.
|
||||
// <https://github.com/llvm/llvm-project/commit/584253c4e2f788f870488fc32193b52d67ddaccc>
|
||||
// FIXME: Remove when Rust's minimum supported LLVM version reaches 19.
|
||||
#if LLVM_VERSION_LT(19, 0)
|
||||
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(OperandBundleDef, LLVMOperandBundleRef)
|
||||
|
||||
extern "C" LLVMValueRef
|
||||
LLVMBuildCallBr(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn,
|
||||
LLVMBasicBlockRef DefaultDest, LLVMBasicBlockRef *IndirectDests,
|
||||
unsigned NumIndirectDests, LLVMValueRef *Args, unsigned NumArgs,
|
||||
LLVMOperandBundleRef *Bundles, unsigned NumBundles,
|
||||
const char *Name) {
|
||||
Value *Callee = unwrap(Fn);
|
||||
FunctionType *FTy = unwrap<FunctionType>(Ty);
|
||||
|
||||
// FIXME: Is there a way around this?
|
||||
std::vector<BasicBlock *> IndirectDestsUnwrapped;
|
||||
IndirectDestsUnwrapped.reserve(NumIndirectDests);
|
||||
for (unsigned i = 0; i < NumIndirectDests; ++i) {
|
||||
IndirectDestsUnwrapped.push_back(unwrap(IndirectDests[i]));
|
||||
}
|
||||
|
||||
// FIXME: Is there a way around this?
|
||||
SmallVector<OperandBundleDef> OpBundles;
|
||||
OpBundles.reserve(NumBundles);
|
||||
for (unsigned i = 0; i < NumBundles; ++i) {
|
||||
OpBundles.push_back(*unwrap(Bundles[i]));
|
||||
}
|
||||
|
||||
return wrap(
|
||||
unwrap(B)->CreateCallBr(FTy, Callee, unwrap(DefaultDest),
|
||||
ArrayRef<BasicBlock *>(IndirectDestsUnwrapped),
|
||||
ArrayRef<Value *>(unwrap(Args), NumArgs),
|
||||
ArrayRef<OperandBundleDef>(OpBundles), Name));
|
||||
}
|
||||
#endif
|
||||
|
||||
extern "C" void LLVMRustPositionBuilderAtStart(LLVMBuilderRef B,
|
||||
LLVMBasicBlockRef BB) {
|
||||
auto Point = unwrap(BB)->getFirstInsertionPt();
|
||||
|
@ -1781,24 +1740,6 @@ extern "C" LLVMValueRef LLVMRustBuildMaxNum(LLVMBuilderRef B, LLVMValueRef LHS,
|
|||
return wrap(unwrap(B)->CreateMaxNum(unwrap(LHS), unwrap(RHS)));
|
||||
}
|
||||
|
||||
#if LLVM_VERSION_LT(19, 0)
|
||||
enum {
|
||||
LLVMGEPFlagInBounds = (1 << 0),
|
||||
LLVMGEPFlagNUSW = (1 << 1),
|
||||
LLVMGEPFlagNUW = (1 << 2),
|
||||
};
|
||||
extern "C" LLVMValueRef
|
||||
LLVMBuildGEPWithNoWrapFlags(LLVMBuilderRef B, LLVMTypeRef Ty,
|
||||
LLVMValueRef Pointer, LLVMValueRef *Indices,
|
||||
unsigned NumIndices, const char *Name,
|
||||
unsigned NoWrapFlags) {
|
||||
if (NoWrapFlags & LLVMGEPFlagInBounds)
|
||||
return LLVMBuildInBoundsGEP2(B, Ty, Pointer, Indices, NumIndices, Name);
|
||||
else
|
||||
return LLVMBuildGEP2(B, Ty, Pointer, Indices, NumIndices, Name);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Transfers ownership of DiagnosticHandler unique_ptr to the caller.
|
||||
extern "C" DiagnosticHandler *
|
||||
LLVMRustContextGetDiagnosticHandler(LLVMContextRef C) {
|
||||
|
@ -1866,11 +1807,7 @@ extern "C" void LLVMRustContextConfigureDiagnosticHandler(
|
|||
}
|
||||
}
|
||||
if (DiagnosticHandlerCallback) {
|
||||
#if LLVM_VERSION_GE(19, 0)
|
||||
DiagnosticHandlerCallback(&DI, DiagnosticHandlerContext);
|
||||
#else
|
||||
DiagnosticHandlerCallback(DI, DiagnosticHandlerContext);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -2018,21 +1955,3 @@ extern "C" void LLVMRustSetNoSanitizeHWAddress(LLVMValueRef Global) {
|
|||
MD.NoHWAddress = true;
|
||||
GV.setSanitizerMetadata(MD);
|
||||
}
|
||||
|
||||
// Operations on composite constants.
|
||||
// These are clones of LLVM api functions that will become available in future
|
||||
// releases. They can be removed once Rust's minimum supported LLVM version
|
||||
// supports them. See https://github.com/rust-lang/rust/issues/121868 See
|
||||
// https://llvm.org/doxygen/group__LLVMCCoreValueConstantComposite.html
|
||||
|
||||
// FIXME: Remove when Rust's minimum supported LLVM version reaches 19.
|
||||
// https://github.com/llvm/llvm-project/commit/e1405e4f71c899420ebf8262d5e9745598419df8
|
||||
#if LLVM_VERSION_LT(19, 0)
|
||||
extern "C" LLVMValueRef LLVMConstStringInContext2(LLVMContextRef C,
|
||||
const char *Str,
|
||||
size_t Length,
|
||||
bool DontNullTerminate) {
|
||||
return wrap(ConstantDataArray::getString(*unwrap(C), StringRef(Str, Length),
|
||||
!DontNullTerminate));
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue