Remove checks for LLVM < 4.0
While we still have to support LLVM 4.0 for Emscripten, we can drop checks for LLVM >= 4.0 and < 4.0.
This commit is contained in:
parent
f6e9a6e41c
commit
d794597698
8 changed files with 6 additions and 215 deletions
|
@ -32,7 +32,6 @@
|
|||
#include "llvm/Target/TargetSubtargetInfo.h"
|
||||
#endif
|
||||
|
||||
#if LLVM_VERSION_GE(4, 0)
|
||||
#include "llvm/Transforms/IPO/AlwaysInliner.h"
|
||||
#include "llvm/Transforms/IPO/FunctionImport.h"
|
||||
#include "llvm/Transforms/Utils/FunctionImportUtils.h"
|
||||
|
@ -40,14 +39,9 @@
|
|||
#if LLVM_VERSION_LE(4, 0)
|
||||
#include "llvm/Object/ModuleSummaryIndexObjectFile.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "llvm-c/Transforms/PassManagerBuilder.h"
|
||||
|
||||
#if LLVM_VERSION_GE(4, 0)
|
||||
#define PGO_AVAILABLE
|
||||
#endif
|
||||
|
||||
using namespace llvm;
|
||||
using namespace llvm::legacy;
|
||||
|
||||
|
@ -121,12 +115,8 @@ bool LLVMRustPassManagerBuilderPopulateThinLTOPassManager(
|
|||
LLVMPassManagerBuilderRef PMBR,
|
||||
LLVMPassManagerRef PMR
|
||||
) {
|
||||
#if LLVM_VERSION_GE(4, 0)
|
||||
unwrap(PMBR)->populateThinLTOPassManager(*unwrap(PMR));
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef LLVM_COMPONENT_X86
|
||||
|
@ -288,17 +278,12 @@ static Optional<Reloc::Model> fromRust(LLVMRustRelocMode RustReloc) {
|
|||
return Reloc::PIC_;
|
||||
case LLVMRustRelocMode::DynamicNoPic:
|
||||
return Reloc::DynamicNoPIC;
|
||||
#if LLVM_VERSION_GE(4, 0)
|
||||
case LLVMRustRelocMode::ROPI:
|
||||
return Reloc::ROPI;
|
||||
case LLVMRustRelocMode::RWPI:
|
||||
return Reloc::RWPI;
|
||||
case LLVMRustRelocMode::ROPIRWPI:
|
||||
return Reloc::ROPI_RWPI;
|
||||
#else
|
||||
default:
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
report_fatal_error("Bad RelocModel.");
|
||||
}
|
||||
|
@ -450,11 +435,8 @@ extern "C" void LLVMRustConfigurePassManagerBuilder(
|
|||
unwrap(PMBR)->SLPVectorize = SLPVectorize;
|
||||
unwrap(PMBR)->OptLevel = fromRust(OptLevel);
|
||||
unwrap(PMBR)->LoopVectorize = LoopVectorize;
|
||||
#if LLVM_VERSION_GE(4, 0)
|
||||
unwrap(PMBR)->PrepareForThinLTO = PrepareForThinLTO;
|
||||
#endif
|
||||
|
||||
#ifdef PGO_AVAILABLE
|
||||
if (PGOGenPath) {
|
||||
assert(!PGOUsePath);
|
||||
unwrap(PMBR)->EnablePGOInstrGen = true;
|
||||
|
@ -464,9 +446,6 @@ extern "C" void LLVMRustConfigurePassManagerBuilder(
|
|||
assert(!PGOGenPath);
|
||||
unwrap(PMBR)->PGOInstrUse = PGOUsePath;
|
||||
}
|
||||
#else
|
||||
assert(!PGOGenPath && !PGOUsePath && "Should've caught earlier");
|
||||
#endif
|
||||
}
|
||||
|
||||
// Unfortunately, the LLVM C API doesn't provide a way to set the `LibraryInfo`
|
||||
|
@ -716,7 +695,6 @@ extern "C" void LLVMRustPrintPasses() {
|
|||
LLVMInitializePasses();
|
||||
struct MyListener : PassRegistrationListener {
|
||||
void passEnumerate(const PassInfo *Info) {
|
||||
#if LLVM_VERSION_GE(4, 0)
|
||||
StringRef PassArg = Info->getPassArgument();
|
||||
StringRef PassName = Info->getPassName();
|
||||
if (!PassArg.empty()) {
|
||||
|
@ -726,11 +704,6 @@ extern "C" void LLVMRustPrintPasses() {
|
|||
printf("%15.*s - %.*s\n", (int)PassArg.size(), PassArg.data(),
|
||||
(int)PassName.size(), PassName.data());
|
||||
}
|
||||
#else
|
||||
if (Info->getPassArgument() && *Info->getPassArgument()) {
|
||||
printf("%15s - %s\n", Info->getPassArgument(), Info->getPassName());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
} Listener;
|
||||
|
||||
|
@ -740,11 +713,7 @@ extern "C" void LLVMRustPrintPasses() {
|
|||
|
||||
extern "C" void LLVMRustAddAlwaysInlinePass(LLVMPassManagerBuilderRef PMBR,
|
||||
bool AddLifetimes) {
|
||||
#if LLVM_VERSION_GE(4, 0)
|
||||
unwrap(PMBR)->Inliner = llvm::createAlwaysInlinerLegacyPass(AddLifetimes);
|
||||
#else
|
||||
unwrap(PMBR)->Inliner = createAlwaysInlinerPass(AddLifetimes);
|
||||
#endif
|
||||
}
|
||||
|
||||
extern "C" void LLVMRustRunRestrictionPass(LLVMModuleRef M, char **Symbols,
|
||||
|
@ -795,26 +764,6 @@ extern "C" void LLVMRustSetModulePIELevel(LLVMModuleRef M) {
|
|||
unwrap(M)->setPIELevel(PIELevel::Level::Large);
|
||||
}
|
||||
|
||||
extern "C" bool
|
||||
LLVMRustThinLTOAvailable() {
|
||||
#if LLVM_VERSION_GE(4, 0)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
extern "C" bool
|
||||
LLVMRustPGOAvailable() {
|
||||
#ifdef PGO_AVAILABLE
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if LLVM_VERSION_GE(4, 0)
|
||||
|
||||
// Here you'll find an implementation of ThinLTO as used by the Rust compiler
|
||||
// right now. This ThinLTO support is only enabled on "recent ish" versions of
|
||||
// LLVM, and otherwise it's just blanket rejected from other compilers.
|
||||
|
@ -1276,94 +1225,3 @@ LLVMRustThinLTOPatchDICompileUnit(LLVMModuleRef Mod, DICompileUnit *Unit) {
|
|||
MD->clearOperands();
|
||||
MD->addOperand(Unit);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
struct LLVMRustThinLTOData {
|
||||
};
|
||||
|
||||
struct LLVMRustThinLTOModule {
|
||||
};
|
||||
|
||||
extern "C" LLVMRustThinLTOData*
|
||||
LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
|
||||
int num_modules,
|
||||
const char **preserved_symbols,
|
||||
int num_symbols) {
|
||||
report_fatal_error("ThinLTO not available");
|
||||
}
|
||||
|
||||
extern "C" bool
|
||||
LLVMRustPrepareThinLTORename(const LLVMRustThinLTOData *Data, LLVMModuleRef M) {
|
||||
report_fatal_error("ThinLTO not available");
|
||||
}
|
||||
|
||||
extern "C" bool
|
||||
LLVMRustPrepareThinLTOResolveWeak(const LLVMRustThinLTOData *Data, LLVMModuleRef M) {
|
||||
report_fatal_error("ThinLTO not available");
|
||||
}
|
||||
|
||||
extern "C" bool
|
||||
LLVMRustPrepareThinLTOInternalize(const LLVMRustThinLTOData *Data, LLVMModuleRef M) {
|
||||
report_fatal_error("ThinLTO not available");
|
||||
}
|
||||
|
||||
extern "C" bool
|
||||
LLVMRustPrepareThinLTOImport(const LLVMRustThinLTOData *Data, LLVMModuleRef M) {
|
||||
report_fatal_error("ThinLTO not available");
|
||||
}
|
||||
|
||||
extern "C" LLVMRustThinLTOModuleImports
|
||||
LLVMRustGetLLVMRustThinLTOModuleImports(const LLVMRustThinLTOData *Data) {
|
||||
report_fatal_error("ThinLTO not available");
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
LLVMRustFreeThinLTOData(LLVMRustThinLTOData *Data) {
|
||||
report_fatal_error("ThinLTO not available");
|
||||
}
|
||||
|
||||
struct LLVMRustThinLTOBuffer {
|
||||
};
|
||||
|
||||
extern "C" LLVMRustThinLTOBuffer*
|
||||
LLVMRustThinLTOBufferCreate(LLVMModuleRef M) {
|
||||
report_fatal_error("ThinLTO not available");
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
LLVMRustThinLTOBufferFree(LLVMRustThinLTOBuffer *Buffer) {
|
||||
report_fatal_error("ThinLTO not available");
|
||||
}
|
||||
|
||||
extern "C" const void*
|
||||
LLVMRustThinLTOBufferPtr(const LLVMRustThinLTOBuffer *Buffer) {
|
||||
report_fatal_error("ThinLTO not available");
|
||||
}
|
||||
|
||||
extern "C" size_t
|
||||
LLVMRustThinLTOBufferLen(const LLVMRustThinLTOBuffer *Buffer) {
|
||||
report_fatal_error("ThinLTO not available");
|
||||
}
|
||||
|
||||
extern "C" LLVMModuleRef
|
||||
LLVMRustParseBitcodeForThinLTO(LLVMContextRef Context,
|
||||
const char *data,
|
||||
size_t len,
|
||||
const char *identifier) {
|
||||
report_fatal_error("ThinLTO not available");
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
LLVMRustThinLTOGetDICompileUnit(LLVMModuleRef Mod,
|
||||
DICompileUnit **A,
|
||||
DICompileUnit **B) {
|
||||
report_fatal_error("ThinLTO not available");
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
LLVMRustThinLTOPatchDICompileUnit(LLVMModuleRef Mod) {
|
||||
report_fatal_error("ThinLTO not available");
|
||||
}
|
||||
|
||||
#endif // LLVM_VERSION_GE(4, 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue