Skip to content

Commit

Permalink
[LLVM] Drop support for LLVM 11 (#43371)
Browse files Browse the repository at this point in the history
  • Loading branch information
vchuravy authored Dec 21, 2021
1 parent 4b0d6c9 commit 602b46c
Show file tree
Hide file tree
Showing 11 changed files with 3 additions and 120 deletions.
4 changes: 0 additions & 4 deletions src/abi_ppc64le.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,7 @@ bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx, Type *T
jl_datatype_t *ty0 = NULL;
bool hva = false;
if (jl_datatype_size(dt) > 64 && isHFA(dt, &ty0, &hva) > 8) {
#if JL_LLVM_VERSION < 120000
ab.addAttribute(Attribute::ByVal);
#else
ab.addByValAttr(Ty);
#endif
return true;
}
return false;
Expand Down
4 changes: 0 additions & 4 deletions src/abi_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx, Type *T
{
// Use pass by reference for all structs
if (dt->layout->nfields > 0) {
#if JL_LLVM_VERSION < 120000
ab.addAttribute(Attribute::ByVal);
#else
ab.addByValAttr(Ty);
#endif
return true;
}
return false;
Expand Down
4 changes: 0 additions & 4 deletions src/abi_win64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx, Type *T
if (win64_reg_size(size))
return false;
if (nargs <= 4) {
#if JL_LLVM_VERSION < 120000
ab.addAttribute(Attribute::ByVal);
#else
ab.addByValAttr(Ty);
#endif
}
return true;
}
Expand Down
4 changes: 0 additions & 4 deletions src/abi_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,7 @@ bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx, Type *T
size_t size = jl_datatype_size(dt);
if (is_complex64(dt) || is_complex128(dt) || (jl_is_primitivetype(dt) && size <= 8))
return false;
#if JL_LLVM_VERSION < 120000
ab.addAttribute(Attribute::ByVal);
#else
ab.addByValAttr(Ty);
#endif
return true;
}

Expand Down
8 changes: 0 additions & 8 deletions src/abi_x86_64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,7 @@ bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx, Type *T
{
Classification cl = classify(dt);
if (cl.isMemory) {
#if JL_LLVM_VERSION < 120000
ab.addAttribute(Attribute::ByVal);
#else
ab.addByValAttr(Ty);
#endif
return true;
}

Expand All @@ -206,12 +202,8 @@ bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx, Type *T
else if (jl_is_structtype(dt)) {
// spill to memory even though we would ordinarily pass
// it in registers
#if JL_LLVM_VERSION < 120000
ab.addAttribute(Attribute::ByVal);
#else
Type* Ty = preferred_llvm_type(dt, false, ctx);
ab.addByValAttr(Ty);
#endif
return true;
}
return false;
Expand Down
4 changes: 0 additions & 4 deletions src/ccall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1031,11 +1031,7 @@ std::string generate_func_sig(const char *fname)
else if (abi->use_sret((jl_datatype_t*)rt, jl_LLVMContext)) {
AttrBuilder retattrs = AttrBuilder();
#if !defined(_OS_WINDOWS_) // llvm used to use the old mingw ABI, skipping this marking works around that difference
#if JL_LLVM_VERSION < 120000
retattrs.addAttribute(Attribute::StructRet);
#else
retattrs.addStructRetAttr(lrt);
#endif
#endif
retattrs.addAttribute(Attribute::NoAlias);
paramattrs.push_back(std::move(retattrs));
Expand Down
6 changes: 0 additions & 6 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@
// for configuration options
#include <llvm/Support/PrettyStackTrace.h>
#include <llvm/Support/CommandLine.h>
#if JL_LLVM_VERSION >= 120000
#include <llvm/Support/Process.h>
#endif

#include <llvm/IR/InlineAsm.h>
#if defined(_CPU_ARM_) || defined(_CPU_AARCH64_)
Expand Down Expand Up @@ -8088,11 +8086,7 @@ extern "C" void jl_init_llvm(void)
// This is the only way I can find to print the help message once.
// It'll be nice if we can iterate through the features and print our own help
// message...
#if JL_LLVM_VERSION >= 120000
MSTI->setDefaultFeatures("help", "", "");
#else
MSTI->setDefaultFeatures("help", "");
#endif
}
}
// Package up features to be passed to target/subtarget
Expand Down
46 changes: 0 additions & 46 deletions src/jitlayers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,22 +481,12 @@ JL_DLLEXPORT void ORCNotifyObjectEmitted(JITEventListener *Listener,
const RuntimeDyld::LoadedObjectInfo &L,
RTDyldMemoryManager *memmgr);

#if JL_LLVM_VERSION >= 120000
template <typename ObjT, typename LoadResult>
void JuliaOJIT::registerObject(const ObjT &Obj, const LoadResult &LO)
{
const ObjT* Object = &Obj;
ORCNotifyObjectEmitted(JuliaListener.get(), *Object, *LO, MemMgr.get());
}
#else
template <typename ObjT, typename LoadResult>
void JuliaOJIT::registerObject(RTDyldObjHandleT H, const ObjT &Obj, const LoadResult &LO)
{
const ObjT* Object = &Obj;
NotifyFinalizer(H, *Object, *LO);
ORCNotifyObjectEmitted(JuliaListener.get(), *Object, *LO, MemMgr.get());
}
#endif

CodeGenOpt::Level CodeGenOptLevelFor(int optlevel)
{
Expand Down Expand Up @@ -636,21 +626,12 @@ JuliaOJIT::JuliaOJIT(TargetMachine &TM, LLVMContext *LLVMCtx)
),
CompileLayer(ES, ObjectLayer, std::make_unique<CompilerT>(this))
{
#if JL_LLVM_VERSION >= 120000
ObjectLayer.setNotifyLoaded(
[this](orc::MaterializationResponsibility &MR,
const object::ObjectFile &Object,
const RuntimeDyld::LoadedObjectInfo &LOS) {
registerObject(Object, &LOS);
});
#else
ObjectLayer.setNotifyLoaded(
[this](RTDyldObjHandleT H,
const object::ObjectFile &Object,
const RuntimeDyld::LoadedObjectInfo &LOS) {
registerObject(H, Object, &LOS);
});
#endif
for (int i = 0; i < 4; i++) {
TMs[i] = TM.getTarget().createTargetMachine(TM.getTargetTriple().getTriple(), TM.getTargetCPU(),
TM.getTargetFeatureString(), TM.Options, Reloc::Static, TM.getCodeModel(),
Expand Down Expand Up @@ -734,28 +715,15 @@ void JuliaOJIT::addModule(std::unique_ptr<Module> M)
}
}
#endif
#if JL_LLVM_VERSION >= 120000
// TODO: what is the performance characteristics of this?
cantFail(CompileLayer.add(JD, orc::ThreadSafeModule(std::move(M), TSCtx)));
#else
auto key = ES.allocateVModule();
// TODO: what is the performance characteristics of this?
cantFail(CompileLayer.add(JD, orc::ThreadSafeModule(std::move(M), TSCtx), key));
#endif
// force eager compilation (for now), due to memory management specifics
// (can't handle compilation recursion)
for (auto Name : NewExports)
cantFail(ES.lookup({&JD}, Name));

}

#if JL_LLVM_VERSION < 120000
void JuliaOJIT::removeModule(ModuleHandleT H)
{
//(void)CompileLayer.remove(H);
}
#endif

JL_JITSymbol JuliaOJIT::findSymbol(StringRef Name, bool ExportedSymbolsOnly)
{
orc::JITDylib* SearchOrders[2] = {&GlobalJD, &JD};
Expand Down Expand Up @@ -825,22 +793,8 @@ void JuliaOJIT::RegisterJITEventListener(JITEventListener *L)
{
if (!L)
return;
#if JL_LLVM_VERSION >= 120000
this->ObjectLayer.registerJITEventListener(*L);
#else
EventListeners.push_back(L);
#endif
}

#if JL_LLVM_VERSION < 120000
void JuliaOJIT::NotifyFinalizer(RTDyldObjHandleT Key,
const object::ObjectFile &Obj,
const RuntimeDyld::LoadedObjectInfo &LoadedObjectInfo)
{
for (auto &Listener : EventListeners)
Listener->notifyObjectLoaded(Key, Obj, LoadedObjectInfo);
}
#endif

const DataLayout& JuliaOJIT::getDataLayout() const
{
Expand Down
23 changes: 1 addition & 22 deletions src/jitlayers.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,6 @@ typedef JITSymbol JL_JITSymbol;
// is expected.
typedef JITSymbol JL_SymbolInfo;

#if JL_LLVM_VERSION < 120000
using RTDyldObjHandleT = orc::VModuleKey;
#endif

using CompilerResultT = Expected<std::unique_ptr<llvm::MemoryBuffer>>;

class JuliaOJIT {
Expand All @@ -158,38 +154,21 @@ class JuliaOJIT {
private:
JuliaOJIT &jit;
};
#if JL_LLVM_VERSION >= 120000
// Custom object emission notification handler for the JuliaOJIT
template <typename ObjT, typename LoadResult>
void registerObject(const ObjT &Obj, const LoadResult &LO);
#else
// Custom object emission notification handler for the JuliaOJIT
template <typename ObjT, typename LoadResult>
void registerObject(RTDyldObjHandleT H, const ObjT &Obj, const LoadResult &LO);
#endif

public:
typedef orc::RTDyldObjectLinkingLayer ObjLayerT;
typedef orc::IRCompileLayer CompileLayerT;
#if JL_LLVM_VERSION < 120000
typedef RTDyldObjHandleT ModuleHandleT;
#endif
typedef object::OwningBinary<object::ObjectFile> OwningObj;

JuliaOJIT(TargetMachine &TM, LLVMContext *Ctx);

void RegisterJITEventListener(JITEventListener *L);
#if JL_LLVM_VERSION < 120000
std::vector<JITEventListener *> EventListeners;
void NotifyFinalizer(RTDyldObjHandleT Key,
const object::ObjectFile &Obj,
const RuntimeDyld::LoadedObjectInfo &LoadedObjectInfo);
#endif
void addGlobalMapping(StringRef Name, uint64_t Addr);
void addModule(std::unique_ptr<Module> M);
#if JL_LLVM_VERSION < 120000
void removeModule(ModuleHandleT H);
#endif

JL_JITSymbol findSymbol(StringRef Name, bool ExportedSymbolsOnly);
JL_JITSymbol findUnmangledSymbol(StringRef Name);
uint64_t getGlobalValueAddress(StringRef Name);
Expand Down
16 changes: 0 additions & 16 deletions src/llvm-late-gc-lowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,12 +397,8 @@ CountTrackedPointers::CountTrackedPointers(Type *T) {
if (isa<ArrayType>(T))
count *= cast<ArrayType>(T)->getNumElements();
else if (isa<VectorType>(T)) {
#if JL_LLVM_VERSION >= 120000
ElementCount EC = cast<VectorType>(T)->getElementCount();
count *= EC.getKnownMinValue();
#else
count *= cast<VectorType>(T)->getNumElements();
#endif
}
}
if (count == 0)
Expand All @@ -415,12 +411,8 @@ unsigned getCompositeNumElements(Type *T) {
else if (auto *AT = dyn_cast<ArrayType>(T))
return AT->getNumElements();
else {
#if JL_LLVM_VERSION >= 120000
ElementCount EC = cast<VectorType>(T)->getElementCount();
return EC.getKnownMinValue();
#else
return cast<VectorType>(T)->getNumElements();
#endif
}
}

Expand Down Expand Up @@ -649,12 +641,8 @@ void LateLowerGCFrame::LiftSelect(State &S, SelectInst *SI) {
std::vector<int> Numbers;
unsigned NumRoots = 1;
if (auto VTy = dyn_cast<VectorType>(SI->getType())) {
#if JL_LLVM_VERSION >= 120000
ElementCount EC = VTy->getElementCount();
Numbers.resize(EC.getKnownMinValue(), -1);
#else
Numbers.resize(VTy->getNumElements(), -1);
#endif
}
else
assert(isa<PointerType>(SI->getType()) && "unimplemented");
Expand Down Expand Up @@ -715,12 +703,8 @@ void LateLowerGCFrame::LiftSelect(State &S, SelectInst *SI) {
assert(NumRoots == 1);
int Number = Numbers[0];
Numbers.resize(0);
#if JL_LLVM_VERSION >= 120000
ElementCount EC = VTy->getElementCount();
Numbers.resize(EC.getKnownMinValue(), Number);
#else
Numbers.resize(VTy->getNumElements(), Number);
#endif
}
}
if (!isa<PointerType>(SI->getType()))
Expand Down
4 changes: 2 additions & 2 deletions src/llvm-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#define JL_LLVM_VERSION (LLVM_VERSION_MAJOR * 10000 + LLVM_VERSION_MINOR * 100 \
+ LLVM_VERSION_PATCH)

#if JL_LLVM_VERSION < 110000
#error Only LLVM versions >= 11.0.0 are supported by Julia
#if JL_LLVM_VERSION < 120000
#error Only LLVM versions >= 12.0.0 are supported by Julia
#endif

#ifdef __cplusplus
Expand Down

0 comments on commit 602b46c

Please sign in to comment.