@@ -605,6 +605,24 @@ AttributeSet Attributes(LLVMContext &C, std::initializer_list<Attribute::AttrKin
605605 return AttributeSet::get (C, ArrayRef<Attribute>(attrs));
606606}
607607
608+ static inline Attribute NoCaptureAttr (LLVMContext &C)
609+ {
610+ #if JL_LLVM_VERSION < 210000
611+ return Attribute::get (C, Attribute::NoCapture);
612+ #else
613+ return Attribute::getWithCaptureInfo (C, CaptureInfo (CaptureComponents::None));
614+ #endif
615+ }
616+
617+ static inline void addNoCaptureAttr (AttrBuilder ¶m)
618+ {
619+ #if JL_LLVM_VERSION < 210000
620+ param.addAttribute (Attribute::NoCapture);
621+ #else
622+ param.addCapturesAttr (CaptureInfo (CaptureComponents::None));
623+ #endif
624+ }
625+
608626static Type *get_pjlvalue (LLVMContext &C) { return JuliaType::get_pjlvalue_ty (C); }
609627
610628static FunctionType *get_func_sig (LLVMContext &C) { return JuliaType::get_jlfunc_ty (C); }
@@ -617,7 +635,7 @@ static AttributeList get_func_attrs(LLVMContext &C)
617635 AttributeSet (),
618636 Attributes (C, {Attribute::NonNull}),
619637 {AttributeSet (),
620- Attributes (C, {Attribute::NoAlias, Attribute::ReadOnly, Attribute::NoCapture, Attribute::NoUndef })});
638+ Attributes (C, {Attribute::NoAlias, Attribute::ReadOnly, Attribute::NoUndef}, { NoCaptureAttr (C) })});
621639}
622640
623641static AttributeList get_attrs_noreturn (LLVMContext &C)
@@ -998,7 +1016,7 @@ static const auto jllockvalue_func = new JuliaFunction<>{
9981016 [](LLVMContext &C) { return AttributeList::get (C,
9991017 AttributeSet (),
10001018 AttributeSet (),
1001- {Attributes (C, {Attribute::NoCapture })}); },
1019+ {Attributes (C, {}, { NoCaptureAttr (C) })}); },
10021020};
10031021static const auto jlunlockvalue_func = new JuliaFunction<>{
10041022 XSTR (jl_unlock_value),
@@ -1007,7 +1025,7 @@ static const auto jlunlockvalue_func = new JuliaFunction<>{
10071025 [](LLVMContext &C) { return AttributeList::get (C,
10081026 AttributeSet (),
10091027 AttributeSet (),
1010- {Attributes (C, {Attribute::NoCapture })}); },
1028+ {Attributes (C, {}, { NoCaptureAttr (C) })}); },
10111029};
10121030static const auto jllockfield_func = new JuliaFunction<>{
10131031 XSTR (jl_lock_field),
@@ -1016,7 +1034,7 @@ static const auto jllockfield_func = new JuliaFunction<>{
10161034 [](LLVMContext &C) { return AttributeList::get (C,
10171035 AttributeSet (),
10181036 AttributeSet (),
1019- {Attributes (C, {Attribute::NoCapture })}); },
1037+ {Attributes (C, {}, { NoCaptureAttr (C) })}); },
10201038};
10211039static const auto jlunlockfield_func = new JuliaFunction<>{
10221040 XSTR (jl_unlock_field),
@@ -1025,7 +1043,7 @@ static const auto jlunlockfield_func = new JuliaFunction<>{
10251043 [](LLVMContext &C) { return AttributeList::get (C,
10261044 AttributeSet (),
10271045 AttributeSet (),
1028- {Attributes (C, {Attribute::NoCapture })}); },
1046+ {Attributes (C, {}, { NoCaptureAttr (C) })}); },
10291047};
10301048static const auto jlenter_func = new JuliaFunction<>{
10311049 XSTR (jl_enter_handler),
@@ -1493,7 +1511,7 @@ static const auto gc_loaded_func = new JuliaFunction<>{
14931511 RetAttrs.addAttribute (Attribute::NonNull);
14941512 RetAttrs.addAttribute (Attribute::NoUndef);
14951513 return AttributeList::get (C, AttributeSet::get (C,FnAttrs), AttributeSet::get (C,RetAttrs),
1496- { Attributes (C, {Attribute::NonNull, Attribute::NoUndef, Attribute::ReadNone, Attribute::NoCapture }),
1514+ { Attributes (C, {Attribute::NonNull, Attribute::NoUndef, Attribute::ReadNone}, { NoCaptureAttr (C) }),
14971515 Attributes (C, {Attribute::NonNull, Attribute::NoUndef, Attribute::ReadNone}) });
14981516 },
14991517};
@@ -1688,6 +1706,15 @@ struct jl_aliasinfo_t {
16881706 // memory region non-aliasing. It should be deleted once the TBAA metadata
16891707 // is improved to encode only memory layout and *not* memory regions.
16901708 static jl_aliasinfo_t fromTBAA (jl_codectx_t &ctx, MDNode *tbaa);
1709+
1710+ AAMDNodes toAAMDNodes () const
1711+ {
1712+ #if JL_LLVM_VERSION < 220000
1713+ return AAMDNodes (tbaa, tbaa_struct, scope, noalias);
1714+ #else
1715+ return AAMDNodes (tbaa, tbaa_struct, scope, noalias, nullptr );
1716+ #endif
1717+ }
16911718};
16921719
16931720// metadata tracking for a llvm Value* during codegen
@@ -2685,7 +2712,11 @@ std::unique_ptr<Module> jl_create_llvm_module(StringRef name, LLVMContext &conte
26852712 m->addModuleFlag (llvm::Module::Warning, " Debug Info Version" ,
26862713 llvm::DEBUG_METADATA_VERSION);
26872714 m->setDataLayout (DL);
2715+ #if JL_LLVM_VERSION < 210000
26882716 m->setTargetTriple (triple.str ());
2717+ #else
2718+ m->setTargetTriple (triple);
2719+ #endif
26892720
26902721 if (triple.isOSWindows () && triple.getArch () == Triple::x86) {
26912722 // tell Win32 to assume the stack is always 16-byte aligned,
@@ -7944,15 +7975,15 @@ static jl_returninfo_t get_specsig_function(jl_codegen_params_t ¶ms, Module
79447975 AttrBuilder param (M->getContext ());
79457976 param.addStructRetAttr (srt);
79467977 param.addAttribute (Attribute::NoAlias);
7947- param. addAttribute (Attribute::NoCapture );
7978+ addNoCaptureAttr (param );
79487979 param.addAttribute (Attribute::NoUndef);
79497980 attrs.push_back (AttributeSet::get (M->getContext (), param));
79507981 assert (fsig.size () == 1 );
79517982 }
79527983 if (props.cc == jl_returninfo_t ::Union) {
79537984 AttrBuilder param (M->getContext ());
79547985 param.addAttribute (Attribute::NoAlias);
7955- param. addAttribute (Attribute::NoCapture );
7986+ addNoCaptureAttr (param );
79567987 param.addAttribute (Attribute::NoUndef);
79577988 attrs.push_back (AttributeSet::get (M->getContext (), param));
79587989 assert (fsig.size () == 1 );
@@ -7961,7 +7992,7 @@ static jl_returninfo_t get_specsig_function(jl_codegen_params_t ¶ms, Module
79617992 if (props.return_roots ) {
79627993 AttrBuilder param (M->getContext ());
79637994 param.addAttribute (Attribute::NoAlias);
7964- param. addAttribute (Attribute::NoCapture );
7995+ addNoCaptureAttr (param );
79657996 param.addAttribute (Attribute::NoUndef);
79667997 attrs.push_back (AttributeSet::get (M->getContext (), param));
79677998 fsig.push_back (getPointerTy (M->getContext ()));
@@ -7995,7 +8026,7 @@ static jl_returninfo_t get_specsig_function(jl_codegen_params_t ¶ms, Module
79958026 AttrBuilder param (M->getContext ());
79968027 Type *ty = et;
79978028 if (et == nullptr || et->isAggregateType ()) { // aggregate types are passed by pointer
7998- param. addAttribute (Attribute::NoCapture );
8029+ addNoCaptureAttr (param );
79998030 param.addAttribute (Attribute::ReadOnly);
80008031 ty = PointerType::get (M->getContext (), AddressSpace::Derived);
80018032 }
@@ -9888,7 +9919,9 @@ void linkFunctionBody(Function &Dst, Function &Src)
98889919 Dst.setPersonalityFn (Src.getPersonalityFn ());
98899920 if (Src.hasPersonalityFn ())
98909921 Dst.setPersonalityFn (Src.getPersonalityFn ());
9922+ #if JL_LLVM_VERSION < 210000
98919923 assert (Src.IsNewDbgInfoFormat == Dst.IsNewDbgInfoFormat );
9924+ #endif
98929925
98939926 // Copy over the metadata attachments without remapping.
98949927 Dst.copyMetadata (&Src, 0 );
0 commit comments