Skip to content

Commit 1cc635f

Browse files
authored
Drop support for LLVM < 3.9.1 (#22401)
As of the merge of #21888, we no longer support building on LLVM <= 3.9.1. This is essentially the mechanical cleanup to rip out all code that we had to support building on older LLVM versions. There may still be some residual support left in places and of course some things can now be cleaned up further, but this should get us started.
1 parent e2ef50f commit 1cc635f

12 files changed

+54
-1836
lines changed

src/ccall.cpp

Lines changed: 6 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -166,17 +166,9 @@ static Value *runtime_sym_lookup(PointerType *funcptype, const char *f_lib,
166166
else {
167167
libname = literal_static_pointer_val(f_lib, T_pint8);
168168
}
169-
#if JL_LLVM_VERSION >= 30700
170169
Value *llvmf = builder.CreateCall(prepare_call(builder, jldlsym_func), { libname, stringConstPtr(builder, f_name), libptrgv });
171-
#else
172-
Value *llvmf = builder.CreateCall3(prepare_call(builder, jldlsym_func), libname, stringConstPtr(builder, f_name), libptrgv);
173-
#endif
174170
auto store = builder.CreateAlignedStore(llvmf, llvmgv, sizeof(void*));
175-
# if JL_LLVM_VERSION >= 30900
176171
store->setAtomic(AtomicOrdering::Release);
177-
# else
178-
store->setAtomic(Release);
179-
# endif
180172
builder.CreateBr(ccall_bb);
181173

182174
f->getBasicBlockList().push_back(ccall_bb);
@@ -254,11 +246,7 @@ static GlobalVariable *emit_plt_thunk(Module *M, FunctionType *functype,
254246
Value *ptr = runtime_sym_lookup(funcptype, f_lib, f_name, plt, libptrgv,
255247
llvmgv, runtime_lib);
256248
auto store = builder.CreateAlignedStore(builder.CreateBitCast(ptr, T_pvoidfunc), got, sizeof(void*));
257-
#if JL_LLVM_VERSION >= 30900
258249
store->setAtomic(AtomicOrdering::Release);
259-
#else
260-
store->setAtomic(Release);
261-
#endif
262250
SmallVector<Value*, 16> args;
263251
for (Function::arg_iterator arg = plt->arg_begin(), arg_e = plt->arg_end(); arg != arg_e; ++arg)
264252
args.push_back(&*arg);
@@ -280,7 +268,7 @@ static GlobalVariable *emit_plt_thunk(Module *M, FunctionType *functype,
280268
else {
281269
// musttail support is very bad on ARM, PPC, PPC64 (as of LLVM 3.9)
282270
// Known failures includes vararg (not needed here) and sret.
283-
#if JL_LLVM_VERSION >= 30700 && (defined(_CPU_X86_) || defined(_CPU_X86_64_) || \
271+
#if (defined(_CPU_X86_) || defined(_CPU_X86_64_) || \
284272
defined(_CPU_AARCH64_))
285273
ret->setTailCallKind(CallInst::TCK_MustTail);
286274
#endif
@@ -461,10 +449,8 @@ static Value *llvm_type_rewrite(
461449
Value *to;
462450
#if JL_LLVM_VERSION >= 40000
463451
const DataLayout &DL = jl_data_layout;
464-
#elif JL_LLVM_VERSION >= 30600
465-
const DataLayout &DL = jl_ExecutionEngine->getDataLayout();
466452
#else
467-
const DataLayout &DL = *jl_ExecutionEngine->getDataLayout();
453+
const DataLayout &DL = jl_ExecutionEngine->getDataLayout();
468454
#endif
469455
if (DL.getTypeAllocSize(target_type) >= DL.getTypeAllocSize(from_type)) {
470456
to = emit_static_alloca(target_type, ctx);
@@ -487,7 +473,7 @@ static Value *runtime_apply_type(jl_value_t *ty, jl_unionall_t *unionall, jl_cod
487473
args[0] = literal_pointer_val(ty);
488474
args[1] = literal_pointer_val((jl_value_t*)ctx->linfo->def.method->sig);
489475
args[2] = builder.CreateInBoundsGEP(
490-
LLVM37_param(T_prjlvalue)
476+
T_prjlvalue,
491477
emit_bitcast(decay_derived(ctx->spvals_ptr), T_pprjlvalue),
492478
ConstantInt::get(T_size, sizeof(jl_svec_t) / sizeof(jl_value_t*)));
493479
return builder.CreateCall(prepare_call(jlapplytype_func), makeArrayRef(args));
@@ -519,11 +505,7 @@ static void typeassert_input(const jl_cgval_t &jvinfo, jl_value_t *jlto, jl_unio
519505
Value *vx = boxed(jvinfo, ctx);
520506
Value *istype = builder.
521507
CreateICmpNE(
522-
#if JL_LLVM_VERSION >= 30700
523508
builder.CreateCall(prepare_call(jlisa_func), { vx, boxed(jlto_runtime, ctx) }),
524-
#else
525-
builder.CreateCall2(prepare_call(jlisa_func), vx, boxed(jlto_runtime, ctx)),
526-
#endif
527509
ConstantInt::get(T_int32, 0));
528510
BasicBlock *failBB = BasicBlock::Create(jl_LLVMContext, "fail", ctx->f);
529511
BasicBlock *passBB = BasicBlock::Create(jl_LLVMContext, "pass", ctx->f);
@@ -834,7 +816,6 @@ static jl_cgval_t emit_cglobal(jl_value_t **args, size_t nargs, jl_codectx_t *ct
834816
return mark_julia_type(res, false, rt, ctx);
835817
}
836818

837-
#ifdef USE_MCJIT
838819
class FunctionMover final : public ValueMaterializer
839820
{
840821
public:
@@ -871,11 +852,6 @@ class FunctionMover final : public ValueMaterializer
871852
VMap[&*I] = &*(DestI++); // Add mapping to VMap
872853
}
873854

874-
#if JL_LLVM_VERSION >= 30600
875-
// Clone debug info - Not yet public API
876-
// llvm::CloneDebugInfoMetadata(NewF,F,VMap);
877-
#endif
878-
879855
SmallVector<ReturnInst*, 8> Returns;
880856
llvm::CloneFunctionInto(NewF,F,VMap,true,Returns,"",NULL,NULL,this);
881857
NewF->setComdat(nullptr);
@@ -910,13 +886,7 @@ class FunctionMover final : public ValueMaterializer
910886
return NewF;
911887
}
912888

913-
#if JL_LLVM_VERSION >= 30900
914889
Value *materialize(Value *V) override
915-
#elif JL_LLVM_VERSION >= 30800
916-
Value *materializeDeclFor(Value *V) override
917-
#else
918-
Value *materializeValueFor (Value *V) override
919-
#endif
920890
{
921891
Function *F = dyn_cast<Function>(V);
922892
if (F) {
@@ -984,7 +954,6 @@ class FunctionMover final : public ValueMaterializer
984954
return NULL;
985955
};
986956
};
987-
#endif
988957

989958
// llvmcall(ir, (rettypes...), (argtypes...), args...)
990959
static jl_cgval_t emit_llvmcall(jl_value_t **args, size_t nargs, jl_codectx_t *ctx)
@@ -1109,14 +1078,10 @@ static jl_cgval_t emit_llvmcall(jl_value_t **args, size_t nargs, jl_codectx_t *c
11091078
<< jl_string_data(ir) << "\n}";
11101079
SMDiagnostic Err = SMDiagnostic();
11111080
std::string ir_string = ir_stream.str();
1112-
#if JL_LLVM_VERSION >= 30600
11131081
Module *m = NULL;
11141082
bool failed = parseAssemblyInto(llvm::MemoryBufferRef(ir_string,"llvmcall"),*jl_Module,Err);
11151083
if (!failed)
11161084
m = jl_Module;
1117-
#else
1118-
Module *m = ParseAssemblyString(ir_string.c_str(),jl_Module,Err,jl_LLVMContext);
1119-
#endif
11201085
if (m == NULL) {
11211086
std::string message = "Failed to parse LLVM Assembly: \n";
11221087
llvm::raw_string_ostream stream(message);
@@ -1136,20 +1101,14 @@ static jl_cgval_t emit_llvmcall(jl_value_t **args, size_t nargs, jl_codectx_t *c
11361101
it != argtypes.end(); ++it, ++i)
11371102
assert(*it == f->getFunctionType()->getParamType(i));
11381103

1139-
#ifdef USE_MCJIT
11401104
if (f->getParent() != jl_Module) {
11411105
FunctionMover mover(jl_Module, f->getParent());
11421106
f = mover.CloneFunction(f);
11431107
}
1144-
#endif
11451108

11461109
//f->dump();
1147-
#if JL_LLVM_VERSION < 30500
1148-
if (verifyFunction(*f,PrintMessageAction)) {
1149-
#else
11501110
llvm::raw_fd_ostream out(1,false);
11511111
if (verifyFunction(*f,&out)) {
1152-
#endif
11531112
#if JL_LLVM_VERSION >= 50000
11541113
f->print(llvm::dbgs(), nullptr, false, true);
11551114
#else
@@ -1212,10 +1171,8 @@ static jl_cgval_t mark_or_box_ccall_result(Value *result, bool isboxed, jl_value
12121171
emit_leafcheck(runtime_dt, "ccall: return type must be a leaf DataType", ctx);
12131172
#if JL_LLVM_VERSION >= 40000
12141173
const DataLayout &DL = jl_data_layout;
1215-
#elif JL_LLVM_VERSION >= 30600
1216-
const DataLayout &DL = jl_ExecutionEngine->getDataLayout();
12171174
#else
1218-
const DataLayout &DL = *jl_ExecutionEngine->getDataLayout();
1175+
const DataLayout &DL = jl_ExecutionEngine->getDataLayout();
12191176
#endif
12201177
unsigned nb = DL.getTypeStoreSize(result->getType());
12211178
MDNode *tbaa = jl_is_mutable(rt) ? tbaa_mutab : tbaa_immut;
@@ -1301,7 +1258,7 @@ std::string generate_func_sig()
13011258
}
13021259
else if (abi->use_sret((jl_datatype_t*)rt)) {
13031260
AttrBuilder retattrs = AttrBuilder();
1304-
#if !defined(_OS_WINDOWS_) || JL_LLVM_VERSION >= 30500 // llvm used to use the old mingw ABI, skipping this marking works around that difference
1261+
#if !defined(_OS_WINDOWS_) // llvm used to use the old mingw ABI, skipping this marking works around that difference
13051262
retattrs.addAttribute(Attribute::StructRet);
13061263
#endif
13071264
retattrs.addAttribute(Attribute::NoAlias);
@@ -1679,13 +1636,11 @@ static jl_cgval_t emit_ccall(jl_value_t **args, size_t nargs, jl_codectx_t *ctx)
16791636
#ifdef __MIC__
16801637
// TODO
16811638
#elif defined(_CPU_X86_64_) || defined(_CPU_X86_) /* !__MIC__ */
1682-
#if JL_LLVM_VERSION >= 30700
16831639
static auto pauseinst = InlineAsm::get(FunctionType::get(T_void, false), "pause",
16841640
"~{memory}", true);
16851641
builder.CreateCall(pauseinst);
16861642
JL_GC_POP();
16871643
return ghostValue(jl_void_type);
1688-
#endif
16891644
#elif defined(_CPU_AARCH64_) || (defined(_CPU_ARM_) && __ARM_ARCH >= 7)
16901645
static auto wfeinst = InlineAsm::get(FunctionType::get(T_void, false), "wfe",
16911646
"~{memory}", true);
@@ -2051,11 +2006,7 @@ jl_cgval_t function_sig_t::emit_a_ccall(
20512006
stacksave = CallInst::Create(Intrinsic::getDeclaration(jl_Module,
20522007
Intrinsic::stacksave));
20532008
if (savespot) {
2054-
#if JL_LLVM_VERSION >= 30800
20552009
instList.insertAfter(savespot->getIterator(), stacksave);
2056-
#else
2057-
instList.insertAfter(savespot, stacksave);
2058-
#endif
20592010
}
20602011
else {
20612012
instList.push_front(stacksave);
@@ -2197,10 +2148,8 @@ jl_cgval_t function_sig_t::emit_a_ccall(
21972148
#ifndef JL_NDEBUG
21982149
#if JL_LLVM_VERSION >= 40000
21992150
const DataLayout &DL = jl_data_layout;
2200-
#elif JL_LLVM_VERSION >= 30600
2201-
const DataLayout &DL = jl_ExecutionEngine->getDataLayout();
22022151
#else
2203-
const DataLayout &DL = *jl_ExecutionEngine->getDataLayout();
2152+
const DataLayout &DL = jl_ExecutionEngine->getDataLayout();
22042153
#endif
22052154
// ARM and AArch64 can use a LLVM type larger than the julia
22062155
// type. However, the LLVM type size should be no larger than

src/cgmemmgr.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,11 @@
44
#include "platform.h"
55
#include "options.h"
66

7-
#ifdef USE_MCJIT
87
#include <llvm/ExecutionEngine/SectionMemoryManager.h>
98
#include "fix_llvm_assert.h"
109
#include "julia.h"
1110
#include "julia_internal.h"
1211

13-
#if JL_LLVM_VERSION >= 30700
14-
#if JL_LLVM_VERSION < 30800
15-
# include <llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h>
16-
# include "fix_llvm_assert.h"
17-
#endif
1812
#ifdef _OS_LINUX_
1913
# include <sys/syscall.h>
2014
# include <sys/utsname.h>
@@ -755,11 +749,9 @@ class RTDyldMemoryManagerJL : public SectionMemoryManager {
755749
uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,
756750
unsigned SectionID, StringRef SectionName,
757751
bool isReadOnly) override;
758-
#if JL_LLVM_VERSION >= 30800
759752
using SectionMemoryManager::notifyObjectLoaded;
760753
void notifyObjectLoaded(RuntimeDyld &Dyld,
761754
const object::ObjectFile &Obj) override;
762-
#endif
763755
bool finalizeMemory(std::string *ErrMsg = nullptr) override;
764756
template <typename DL, typename Alloc>
765757
void mapAddresses(DL &Dyld, Alloc &&allocator)
@@ -831,7 +823,6 @@ uint8_t *RTDyldMemoryManagerJL::allocateDataSection(uintptr_t Size,
831823
SectionName, isReadOnly);
832824
}
833825

834-
#if JL_LLVM_VERSION >= 30800
835826
void RTDyldMemoryManagerJL::notifyObjectLoaded(RuntimeDyld &Dyld,
836827
const object::ObjectFile &Obj)
837828
{
@@ -843,7 +834,6 @@ void RTDyldMemoryManagerJL::notifyObjectLoaded(RuntimeDyld &Dyld,
843834
assert(exe_alloc);
844835
mapAddresses(Dyld);
845836
}
846-
#endif
847837

848838
bool RTDyldMemoryManagerJL::finalizeMemory(std::string *ErrMsg)
849839
{
@@ -886,27 +876,14 @@ void RTDyldMemoryManagerJL::deregisterEHFrames(uint8_t *Addr,
886876

887877
}
888878

889-
#if JL_LLVM_VERSION < 30800
890-
void notifyObjectLoaded(RTDyldMemoryManager *memmgr,
891-
llvm::orc::ObjectLinkingLayerBase::ObjSetHandleT H)
892-
{
893-
((RTDyldMemoryManagerJL*)memmgr)->mapAddresses(**H);
894-
}
895-
#endif
896-
897879
#ifdef _OS_WINDOWS_
898880
void *lookupWriteAddressFor(RTDyldMemoryManager *memmgr, void *rt_addr)
899881
{
900882
return ((RTDyldMemoryManagerJL*)memmgr)->lookupWriteAddressFor(rt_addr);
901883
}
902884
#endif
903885

904-
#else // JL_LLVM_VERSION >= 30700
905-
typedef SectionMemoryManager RTDyldMemoryManagerJL;
906-
#endif // JL_LLVM_VERSION >= 30700
907-
908886
RTDyldMemoryManager* createRTDyldMemoryManager()
909887
{
910888
return new RTDyldMemoryManagerJL();
911889
}
912-
#endif // USE_MCJIT

src/cgutils.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,7 +1156,7 @@ static void emit_leafcheck(Value *typ, const std::string &msg, jl_codectx_t *ctx
11561156
assert(typ->getType() == T_pjlvalue);
11571157
emit_typecheck(mark_julia_type(typ, true, jl_any_type, ctx, false), (jl_value_t*)jl_datatype_type, msg, ctx);
11581158
Value *isleaf;
1159-
isleaf = builder.CreateConstInBoundsGEP1_32(LLVM37_param(T_int8) emit_bitcast(decay_derived(typ), T_pint8), offsetof(jl_datatype_t, isleaftype));
1159+
isleaf = builder.CreateConstInBoundsGEP1_32(T_int8, emit_bitcast(decay_derived(typ), T_pint8), offsetof(jl_datatype_t, isleaftype));
11601160
isleaf = builder.CreateLoad(isleaf, tbaa_const);
11611161
isleaf = builder.CreateTrunc(isleaf, T_int1);
11621162
error_unless(isleaf, msg, ctx);
@@ -1526,14 +1526,14 @@ static jl_cgval_t emit_getfield_knownidx(const jl_cgval_t &strct, unsigned idx,
15261526
lt = vlt->getElementType();
15271527
Value *ptr = data_pointer(strct, ctx, lt->getPointerTo());
15281528
Value *llvm_idx = ConstantInt::get(T_size, idx);
1529-
addr = builder.CreateGEP(LLVM37_param(lt) ptr, llvm_idx);
1529+
addr = builder.CreateGEP(lt, ptr, llvm_idx);
15301530
}
15311531
else if (lt->isSingleValueType()) {
15321532
addr = data_pointer(strct, ctx, lt->getPointerTo());
15331533
}
15341534
else {
15351535
Value *ptr = data_pointer(strct, ctx, lt->getPointerTo());
1536-
addr = builder.CreateStructGEP(LLVM37_param(lt) ptr, idx);
1536+
addr = builder.CreateStructGEP(lt, ptr, idx);
15371537
}
15381538
}
15391539
if (jl_field_isptr(jt, idx)) {
@@ -2394,7 +2394,7 @@ static jl_cgval_t emit_new_struct(jl_value_t *ty, size_t nargs, jl_value_t **arg
23942394
if (!init_as_value) {
23952395
// avoid unboxing the argument explicitely
23962396
// and use memcpy instead
2397-
dest = builder.CreateConstInBoundsGEP2_32(LLVM37_param(lt) strct, 0, i);
2397+
dest = builder.CreateConstInBoundsGEP2_32(lt, strct, 0, i);
23982398
}
23992399
fval = emit_unbox(fty, fval_info, jtype, dest);
24002400

0 commit comments

Comments
 (0)