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
23472343static 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
23932381static 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 *);
0 commit comments