@@ -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)
@@ -996,7 +1014,7 @@ static const auto jllockvalue_func = new JuliaFunction<>{
9961014 [](LLVMContext &C) { return AttributeList::get (C,
9971015 AttributeSet (),
9981016 AttributeSet (),
999- {Attributes (C, {Attribute::NoCapture })}); },
1017+ {Attributes (C, {}, { NoCaptureAttr (C) })}); },
10001018};
10011019static const auto jlunlockvalue_func = new JuliaFunction<>{
10021020 XSTR (jl_unlock_value),
@@ -1005,7 +1023,7 @@ static const auto jlunlockvalue_func = new JuliaFunction<>{
10051023 [](LLVMContext &C) { return AttributeList::get (C,
10061024 AttributeSet (),
10071025 AttributeSet (),
1008- {Attributes (C, {Attribute::NoCapture })}); },
1026+ {Attributes (C, {}, { NoCaptureAttr (C) })}); },
10091027};
10101028static const auto jllockfield_func = new JuliaFunction<>{
10111029 XSTR (jl_lock_field),
@@ -1014,7 +1032,7 @@ static const auto jllockfield_func = new JuliaFunction<>{
10141032 [](LLVMContext &C) { return AttributeList::get (C,
10151033 AttributeSet (),
10161034 AttributeSet (),
1017- {Attributes (C, {Attribute::NoCapture })}); },
1035+ {Attributes (C, {}, { NoCaptureAttr (C) })}); },
10181036};
10191037static const auto jlunlockfield_func = new JuliaFunction<>{
10201038 XSTR (jl_unlock_field),
@@ -1023,7 +1041,7 @@ static const auto jlunlockfield_func = new JuliaFunction<>{
10231041 [](LLVMContext &C) { return AttributeList::get (C,
10241042 AttributeSet (),
10251043 AttributeSet (),
1026- {Attributes (C, {Attribute::NoCapture })}); },
1044+ {Attributes (C, {}, { NoCaptureAttr (C) })}); },
10271045};
10281046static const auto jlenter_func = new JuliaFunction<>{
10291047 XSTR (jl_enter_handler),
@@ -1489,7 +1507,7 @@ static const auto gc_loaded_func = new JuliaFunction<>{
14891507 RetAttrs.addAttribute (Attribute::NonNull);
14901508 RetAttrs.addAttribute (Attribute::NoUndef);
14911509 return AttributeList::get (C, AttributeSet::get (C,FnAttrs), AttributeSet::get (C,RetAttrs),
1492- { Attributes (C, {Attribute::NonNull, Attribute::NoUndef, Attribute::ReadNone, Attribute::NoCapture }),
1510+ { Attributes (C, {Attribute::NonNull, Attribute::NoUndef, Attribute::ReadNone}, { NoCaptureAttr (C) }),
14931511 Attributes (C, {Attribute::NonNull, Attribute::NoUndef, Attribute::ReadNone}) });
14941512 },
14951513};
@@ -1703,6 +1721,15 @@ struct jl_aliasinfo_t {
17031721 // memory region non-aliasing. It should be deleted once the TBAA metadata
17041722 // is improved to encode only memory layout and *not* memory regions.
17051723 static jl_aliasinfo_t fromTBAA (jl_codectx_t &ctx, MDNode *tbaa);
1724+
1725+ AAMDNodes toAAMDNodes () const
1726+ {
1727+ #if JL_LLVM_VERSION < 220000
1728+ return AAMDNodes (tbaa, tbaa_struct, scope, noalias);
1729+ #else
1730+ return AAMDNodes (tbaa, tbaa_struct, scope, noalias, nullptr );
1731+ #endif
1732+ }
17061733};
17071734
17081735// metadata tracking for a llvm Value* during codegen
@@ -2826,7 +2853,11 @@ std::unique_ptr<Module> jl_create_llvm_module(StringRef name, LLVMContext &conte
28262853 m->addModuleFlag (llvm::Module::Warning, " Debug Info Version" ,
28272854 llvm::DEBUG_METADATA_VERSION);
28282855 m->setDataLayout (DL);
2856+ #if JL_LLVM_VERSION < 210000
28292857 m->setTargetTriple (triple.str ());
2858+ #else
2859+ m->setTargetTriple (triple);
2860+ #endif
28302861
28312862 if (triple.isOSWindows () && triple.getArch () == Triple::x86) {
28322863 // tell Win32 to assume the stack is always 16-byte aligned,
@@ -8120,7 +8151,7 @@ static jl_returninfo_t get_specsig_function(jl_codegen_params_t ¶ms, Module
81208151 param.addAttribute (" julia.return_roots" , std::to_string (tracked_count));
81218152 }
81228153 param.addAttribute (Attribute::NoAlias);
8123- param. addAttribute (Attribute::NoCapture );
8154+ addNoCaptureAttr (param );
81248155 param.addAttribute (Attribute::NoUndef);
81258156 attrs.push_back (AttributeSet::get (M->getContext (), param));
81268157 assert (fsig.size () == 1 );
@@ -8132,7 +8163,7 @@ static jl_returninfo_t get_specsig_function(jl_codegen_params_t ¶ms, Module
81328163 param.addAttribute (" julia.return_roots" , std::to_string (tracked_count));
81338164 }
81348165 param.addAttribute (Attribute::NoAlias);
8135- param. addAttribute (Attribute::NoCapture );
8166+ addNoCaptureAttr (param );
81368167 param.addAttribute (Attribute::NoUndef);
81378168 attrs.push_back (AttributeSet::get (M->getContext (), param));
81388169 assert (fsig.size () == 1 );
@@ -8141,7 +8172,7 @@ static jl_returninfo_t get_specsig_function(jl_codegen_params_t ¶ms, Module
81418172 if (props.return_roots ) {
81428173 AttrBuilder param (M->getContext ());
81438174 param.addAttribute (Attribute::NoAlias);
8144- param. addAttribute (Attribute::NoCapture );
8175+ addNoCaptureAttr (param );
81458176 param.addAttribute (Attribute::NoUndef);
81468177 param.addAttribute (" julia.return_roots" , std::to_string (props.return_roots ));
81478178 attrs.push_back (AttributeSet::get (M->getContext (), param));
@@ -8176,7 +8207,7 @@ static jl_returninfo_t get_specsig_function(jl_codegen_params_t ¶ms, Module
81768207 AttrBuilder param (M->getContext ());
81778208 Type *ty = et;
81788209 if (et == nullptr || et->isAggregateType ()) { // aggregate types are passed by pointer
8179- param. addAttribute (Attribute::NoCapture );
8210+ addNoCaptureAttr (param );
81808211 param.addAttribute (Attribute::ReadOnly);
81818212 ty = PointerType::get (M->getContext (), AddressSpace::Derived);
81828213 }
@@ -10058,7 +10089,9 @@ void linkFunctionBody(Function &Dst, Function &Src)
1005810089 Dst.setPersonalityFn (Src.getPersonalityFn ());
1005910090 if (Src.hasPersonalityFn ())
1006010091 Dst.setPersonalityFn (Src.getPersonalityFn ());
10092+ #if JL_LLVM_VERSION < 210000
1006110093 assert (Src.IsNewDbgInfoFormat == Dst.IsNewDbgInfoFormat );
10094+ #endif
1006210095
1006310096 // Copy over the metadata attachments without remapping.
1006410097 Dst.copyMetadata (&Src, 0 );
0 commit comments