Skip to content

Commit 7757e46

Browse files
authored
Excise support for LLVM 13 (#49722)
1 parent 21d4c2f commit 7757e46

File tree

11 files changed

+8
-225
lines changed

11 files changed

+8
-225
lines changed

src/aotcompile.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@
99
#include <llvm/Analysis/TargetLibraryInfo.h>
1010
#include <llvm/Analysis/TargetTransformInfo.h>
1111
#include <llvm/IR/DataLayout.h>
12-
#if JL_LLVM_VERSION >= 140000
1312
#include <llvm/MC/TargetRegistry.h>
14-
#else
15-
#include <llvm/Support/TargetRegistry.h>
16-
#endif
1713
#include <llvm/Target/TargetMachine.h>
1814

1915
// analysis passes

src/ccall.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -958,10 +958,8 @@ static jl_cgval_t emit_llvmcall(jl_codectx_t &ctx, jl_value_t **args, size_t nar
958958
// copy module properties that should always match
959959
Mod->setTargetTriple(jl_Module->getTargetTriple());
960960
Mod->setDataLayout(jl_Module->getDataLayout());
961-
#if JL_LLVM_VERSION >= 130000
962961
Mod->setStackProtectorGuard(jl_Module->getStackProtectorGuard());
963962
Mod->setOverrideStackAlignment(jl_Module->getOverrideStackAlignment());
964-
#endif
965963

966964
// verify the definition
967965
Function *def = Mod->getFunction(ir_name);
@@ -1097,11 +1095,7 @@ std::string generate_func_sig(const char *fname)
10971095
abi->use_sret(jl_voidpointer_type, LLVMCtx);
10981096
}
10991097
else if (abi->use_sret((jl_datatype_t*)rt, LLVMCtx)) {
1100-
#if JL_LLVM_VERSION >= 140000
11011098
AttrBuilder retattrs(LLVMCtx);
1102-
#else
1103-
AttrBuilder retattrs;
1104-
#endif
11051099
if (!ctx->TargetTriple.isOSWindows()) {
11061100
// llvm used to use the old mingw ABI, skipping this marking works around that difference
11071101
retattrs.addStructRetAttr(lrt);
@@ -1120,11 +1114,7 @@ std::string generate_func_sig(const char *fname)
11201114
}
11211115

11221116
for (size_t i = 0; i < nccallargs; ++i) {
1123-
#if JL_LLVM_VERSION >= 140000
11241117
AttrBuilder ab(LLVMCtx);
1125-
#else
1126-
AttrBuilder ab;
1127-
#endif
11281118
jl_value_t *tti = jl_svecref(at, i);
11291119
Type *t = NULL;
11301120
bool isboxed;

src/cgutils.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,12 +1768,8 @@ std::vector<unsigned> first_ptr(Type *T)
17681768
num_elements = AT->getNumElements();
17691769
else {
17701770
VectorType *VT = cast<VectorType>(T);
1771-
#if JL_LLVM_VERSION >= 120000
17721771
ElementCount EC = VT->getElementCount();
17731772
num_elements = EC.getKnownMinValue();
1774-
#else
1775-
num_elements = VT->getNumElements();
1776-
#endif
17771773
}
17781774
if (num_elements == 0)
17791775
return {};
@@ -2015,12 +2011,7 @@ static jl_cgval_t typed_store(jl_codectx_t &ctx,
20152011
assert(Order != AtomicOrdering::NotAtomic && r);
20162012
// we can't handle isboxed here as a workaround for really bad LLVM
20172013
// design issue: plain Xchg only works with integers
2018-
#if JL_LLVM_VERSION >= 130000
20192014
auto *store = ctx.builder.CreateAtomicRMW(AtomicRMWInst::Xchg, ptr, r, Align(alignment), Order);
2020-
#else
2021-
auto *store = ctx.builder.CreateAtomicRMW(AtomicRMWInst::Xchg, ptr, r, Order);
2022-
store->setAlignment(Align(alignment));
2023-
#endif
20242015
jl_aliasinfo_t ai = jl_aliasinfo_t::fromTBAA(ctx, tbaa);
20252016
ai.noalias = MDNode::concatenate(aliasscope, ai.noalias);
20262017
ai.decorateInst(store);
@@ -2170,12 +2161,7 @@ static jl_cgval_t typed_store(jl_codectx_t &ctx,
21702161
FailOrder = AtomicOrdering::Monotonic;
21712162
else if (FailOrder == AtomicOrdering::Unordered)
21722163
FailOrder = AtomicOrdering::Monotonic;
2173-
#if JL_LLVM_VERSION >= 130000
21742164
auto *store = ctx.builder.CreateAtomicCmpXchg(ptr, Compare, r, Align(alignment), Order, FailOrder);
2175-
#else
2176-
auto *store = ctx.builder.CreateAtomicCmpXchg(ptr, Compare, r, Order, FailOrder);
2177-
store->setAlignment(Align(alignment));
2178-
#endif
21792165
jl_aliasinfo_t ai = jl_aliasinfo_t::fromTBAA(ctx, tbaa);
21802166
ai.noalias = MDNode::concatenate(aliasscope, ai.noalias);
21812167
ai.decorateInst(store);
@@ -3052,12 +3038,8 @@ static jl_value_t *static_constant_instance(const llvm::DataLayout &DL, Constant
30523038
if (const auto *CC = dyn_cast<ConstantAggregate>(constant))
30533039
nargs = CC->getNumOperands();
30543040
else if (const auto *CAZ = dyn_cast<ConstantAggregateZero>(constant)) {
3055-
#if JL_LLVM_VERSION >= 130000
30563041
// SVE: Elsewhere we use `getMinKownValue`
30573042
nargs = CAZ->getElementCount().getFixedValue();
3058-
#else
3059-
nargs = CAZ->getNumElements();
3060-
#endif
30613043
}
30623044
else if (const auto *CDS = dyn_cast<ConstantDataSequential>(constant))
30633045
nargs = CDS->getNumElements();

src/codegen.cpp

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@
2020

2121
// target machine computation
2222
#include <llvm/CodeGen/TargetSubtargetInfo.h>
23-
#if JL_LLVM_VERSION >= 140000
2423
#include <llvm/MC/TargetRegistry.h>
25-
#else
26-
#include <llvm/Support/TargetRegistry.h>
27-
#endif
2824
#include <llvm/Target/TargetOptions.h>
2925
#include <llvm/Support/Host.h>
3026
#include <llvm/Support/TargetSelect.h>
@@ -2338,7 +2334,7 @@ std::unique_ptr<Module> jl_create_llvm_module(StringRef name, LLVMContext &conte
23382334
m->setOverrideStackAlignment(16);
23392335
}
23402336

2341-
#if defined(JL_DEBUG_BUILD) && JL_LLVM_VERSION >= 130000
2337+
#if defined(JL_DEBUG_BUILD)
23422338
m->setStackProtectorGuard("global");
23432339
#endif
23442340
return m;
@@ -2347,11 +2343,7 @@ std::unique_ptr<Module> jl_create_llvm_module(StringRef name, LLVMContext &conte
23472343
static void jl_init_function(Function *F, const Triple &TT)
23482344
{
23492345
// set any attributes that *must* be set on all functions
2350-
#if JL_LLVM_VERSION >= 140000
23512346
AttrBuilder attr(F->getContext());
2352-
#else
2353-
AttrBuilder attr;
2354-
#endif
23552347
if (TT.isOSWindows() && TT.getArch() == Triple::x86) {
23562348
// tell Win32 to assume the stack is always 16-byte aligned,
23572349
// and to ensure that it is 16-byte aligned for out-going calls,
@@ -2383,11 +2375,7 @@ static void jl_init_function(Function *F, const Triple &TT)
23832375
#if defined(_COMPILER_MSAN_ENABLED_)
23842376
attr.addAttribute(Attribute::SanitizeMemory);
23852377
#endif
2386-
#if JL_LLVM_VERSION >= 140000
23872378
F->addFnAttrs(attr);
2388-
#else
2389-
F->addAttributes(AttributeList::FunctionIndex, attr);
2390-
#endif
23912379
}
23922380

23932381
static bool uses_specsig(jl_value_t *sig, bool needsparams, bool va, jl_value_t *rettype, bool prefer_specsig)
@@ -5978,13 +5966,8 @@ static Function* gen_cfun_wrapper(
59785966
// we are adding the extra nest parameter after sret arg.
59795967
std::vector<std::pair<unsigned, AttributeSet>> newAttributes;
59805968
newAttributes.reserve(attributes.getNumAttrSets() + 1);
5981-
#if JL_LLVM_VERSION >= 140000
59825969
auto it = *attributes.indexes().begin();
59835970
const auto it_end = *attributes.indexes().end();
5984-
#else
5985-
auto it = attributes.index_begin();
5986-
const auto it_end = attributes.index_end();
5987-
#endif
59885971

59895972
// Skip past FunctionIndex
59905973
if (it == AttributeList::AttrIndex::FunctionIndex) {
@@ -5999,11 +5982,7 @@ static Function* gen_cfun_wrapper(
59995982
}
60005983

60015984
// Add the new nest attribute
6002-
#if JL_LLVM_VERSION >= 140000
60035985
AttrBuilder attrBuilder(M->getContext());
6004-
#else
6005-
AttrBuilder attrBuilder;
6006-
#endif
60075986
attrBuilder.addAttribute(Attribute::Nest);
60085987
newAttributes.emplace_back(it, AttributeSet::get(M->getContext(), attrBuilder));
60095988

@@ -6868,11 +6847,7 @@ static jl_returninfo_t get_specsig_function(jl_codectx_t &ctx, Module *M, Value
68686847
SmallVector<AttributeSet, 8> attrs; // function declaration attributes
68696848
if (props.cc == jl_returninfo_t::SRet) {
68706849
assert(srt);
6871-
#if JL_LLVM_VERSION >= 140000
68726850
AttrBuilder param(ctx.builder.getContext());
6873-
#else
6874-
AttrBuilder param;
6875-
#endif
68766851
param.addStructRetAttr(srt);
68776852
param.addAttribute(Attribute::NoAlias);
68786853
param.addAttribute(Attribute::NoCapture);
@@ -6881,11 +6856,7 @@ static jl_returninfo_t get_specsig_function(jl_codectx_t &ctx, Module *M, Value
68816856
assert(fsig.size() == 1);
68826857
}
68836858
if (props.cc == jl_returninfo_t::Union) {
6884-
#if JL_LLVM_VERSION >= 140000
68856859
AttrBuilder param(ctx.builder.getContext());
6886-
#else
6887-
AttrBuilder param;
6888-
#endif
68896860
param.addAttribute(Attribute::NoAlias);
68906861
param.addAttribute(Attribute::NoCapture);
68916862
param.addAttribute(Attribute::NoUndef);
@@ -6894,11 +6865,7 @@ static jl_returninfo_t get_specsig_function(jl_codectx_t &ctx, Module *M, Value
68946865
}
68956866

68966867
if (props.return_roots) {
6897-
#if JL_LLVM_VERSION >= 140000
68986868
AttrBuilder param(ctx.builder.getContext());
6899-
#else
6900-
AttrBuilder param;
6901-
#endif
69026869
param.addAttribute(Attribute::NoAlias);
69036870
param.addAttribute(Attribute::NoCapture);
69046871
param.addAttribute(Attribute::NoUndef);
@@ -6922,11 +6889,7 @@ static jl_returninfo_t get_specsig_function(jl_codectx_t &ctx, Module *M, Value
69226889
}
69236890
if (type_is_ghost(ty))
69246891
continue;
6925-
#if JL_LLVM_VERSION >= 140000
69266892
AttrBuilder param(ctx.builder.getContext());
6927-
#else
6928-
AttrBuilder param;
6929-
#endif
69306893
if (ty->isAggregateType()) { // aggregate types are passed by pointer
69316894
param.addAttribute(Attribute::NoCapture);
69326895
param.addAttribute(Attribute::ReadOnly);
@@ -7245,16 +7208,8 @@ static jl_llvm_functions_t
72457208
declarations.functionObject = needsparams ? "jl_fptr_sparam" : "jl_fptr_args";
72467209
}
72477210

7248-
#if JL_LLVM_VERSION >= 140000
72497211
AttrBuilder FnAttrs(ctx.builder.getContext(), f->getAttributes().getFnAttrs());
7250-
#else
7251-
AttrBuilder FnAttrs(f->getAttributes().getFnAttributes());
7252-
#endif
7253-
#if JL_LLVM_VERSION >= 140000
72547212
AttrBuilder RetAttrs(ctx.builder.getContext(), f->getAttributes().getRetAttrs());
7255-
#else
7256-
AttrBuilder RetAttrs(f->getAttributes().getRetAttributes());
7257-
#endif
72587213

72597214
if (jlrettype == (jl_value_t*)jl_bottom_type)
72607215
FnAttrs.addAttribute(Attribute::NoReturn);
@@ -7547,11 +7502,7 @@ static jl_llvm_functions_t
75477502
}
75487503
Argument *Arg = &*AI;
75497504
++AI;
7550-
#if JL_LLVM_VERSION >= 140000
75517505
AttrBuilder param(ctx.builder.getContext(), f->getAttributes().getParamAttrs(Arg->getArgNo()));
7552-
#else
7553-
AttrBuilder param(f->getAttributes().getParamAttributes(Arg->getArgNo()));
7554-
#endif
75557506
jl_cgval_t theArg;
75567507
if (llvmArgType->isAggregateType()) {
75577508
maybe_mark_argument_dereferenceable(param, argType);
@@ -7571,11 +7522,7 @@ static jl_llvm_functions_t
75717522
if (has_sret) {
75727523
Argument *Arg = &*AI;
75737524
++AI;
7574-
#if JL_LLVM_VERSION >= 140000
75757525
AttrBuilder param(ctx.builder.getContext(), f->getAttributes().getParamAttrs(Arg->getArgNo()));
7576-
#else
7577-
AttrBuilder param(f->getAttributes().getParamAttributes(Arg->getArgNo()));
7578-
#endif
75797526
if (returninfo.cc == jl_returninfo_t::Union) {
75807527
param.addAttribute(Attribute::NonNull);
75817528
// The `dereferenceable` below does not imply `nonnull` for non addrspace(0) pointers.
@@ -7597,11 +7544,7 @@ static jl_llvm_functions_t
75977544
if (returninfo.return_roots) {
75987545
Argument *Arg = &*AI;
75997546
++AI;
7600-
#if JL_LLVM_VERSION >= 140000
76017547
AttrBuilder param(ctx.builder.getContext(), f->getAttributes().getParamAttrs(Arg->getArgNo()));
7602-
#else
7603-
AttrBuilder param(f->getAttributes().getParamAttributes(Arg->getArgNo()));
7604-
#endif
76057548
param.addAttribute(Attribute::NonNull);
76067549
// The `dereferenceable` below does not imply `nonnull` for non addrspace(0) pointers.
76077550
size_t size = returninfo.return_roots * sizeof(jl_value_t*);

src/disasm.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,7 @@
9292
#include <llvm/Support/MemoryBuffer.h>
9393
#include <llvm/Support/NativeFormatting.h>
9494
#include <llvm/Support/SourceMgr.h>
95-
#if JL_LLVM_VERSION >= 140000
9695
#include <llvm/MC/TargetRegistry.h>
97-
#else
98-
#include <llvm/Support/TargetRegistry.h>
99-
#endif
10096
#include <llvm/Support/TargetSelect.h>
10197
#include <llvm/Support/raw_ostream.h>
10298

@@ -883,16 +879,10 @@ static void jl_dump_asm_internal(
883879
TheTarget->createMCSubtargetInfo(TheTriple.str(), cpu, features));
884880
assert(STI && "Unable to create subtarget info!");
885881

886-
#if JL_LLVM_VERSION >= 130000
887882
MCContext Ctx(TheTriple, MAI.get(), MRI.get(), STI.get(), &SrcMgr);
888883
std::unique_ptr<MCObjectFileInfo> MOFI(
889884
TheTarget->createMCObjectFileInfo(Ctx, /*PIC=*/false, /*LargeCodeModel=*/ false));
890885
Ctx.setObjectFileInfo(MOFI.get());
891-
#else
892-
std::unique_ptr<MCObjectFileInfo> MOFI(new MCObjectFileInfo());
893-
MCContext Ctx(MAI.get(), MRI.get(), MOFI.get(), &SrcMgr);
894-
MOFI->InitMCObjectFileInfo(TheTriple, /* PIC */ false, Ctx);
895-
#endif
896886

897887
std::unique_ptr<MCDisassembler> DisAsm(TheTarget->createMCDisassembler(*STI, Ctx));
898888
if (!DisAsm) {

0 commit comments

Comments
 (0)