@@ -144,7 +144,7 @@ llvm::Value *lowerPFMINMAX(llvm::Value *x, llvm::Value *y,
144144
145145llvm::Value *lowerRound (llvm::Value *x)
146146{
147- llvm::Function *nearbyint = llvm::Intrinsic::getDeclaration (
147+ llvm::Function *nearbyint = llvm::Intrinsic::getOrInsertDeclaration (
148148 jit->module .get (), llvm::Intrinsic::nearbyint, { x->getType () });
149149 return jit->builder ->CreateCall (nearbyint, { x });
150150}
@@ -156,21 +156,21 @@ llvm::Value *lowerRoundInt(llvm::Value *x, llvm::Type *ty)
156156
157157llvm::Value *lowerFloor (llvm::Value *x)
158158{
159- llvm::Function *floor = llvm::Intrinsic::getDeclaration (
159+ llvm::Function *floor = llvm::Intrinsic::getOrInsertDeclaration (
160160 jit->module .get (), llvm::Intrinsic::floor, { x->getType () });
161161 return jit->builder ->CreateCall (floor, { x });
162162}
163163
164164llvm::Value *lowerTrunc (llvm::Value *x)
165165{
166- llvm::Function *trunc = llvm::Intrinsic::getDeclaration (
166+ llvm::Function *trunc = llvm::Intrinsic::getOrInsertDeclaration (
167167 jit->module .get (), llvm::Intrinsic::trunc, { x->getType () });
168168 return jit->builder ->CreateCall (trunc, { x });
169169}
170170
171171llvm::Value *lowerSQRT (llvm::Value *x)
172172{
173- llvm::Function *sqrt = llvm::Intrinsic::getDeclaration (
173+ llvm::Function *sqrt = llvm::Intrinsic::getOrInsertDeclaration (
174174 jit->module .get (), llvm::Intrinsic::sqrt, { x->getType () });
175175 return jit->builder ->CreateCall (sqrt, { x });
176176}
@@ -1080,14 +1080,17 @@ Value *Nucleus::createMaskedLoad(Value *ptr, Type *elTy, Value *mask, unsigned i
10801080
10811081 auto numEls = llvm::cast<llvm::FixedVectorType>(V (mask)->getType ())->getNumElements ();
10821082 auto i1Ty = llvm::Type::getInt1Ty (*jit->context );
1083- auto i32Ty = llvm::Type::getInt32Ty (*jit->context );
10841083 auto elVecTy = llvm::VectorType::get (T (elTy), numEls, false );
10851084 auto elVecPtrTy = elVecTy->getPointerTo ();
10861085 auto i8Mask = jit->builder ->CreateIntCast (V (mask), llvm::VectorType::get (i1Ty, numEls, false ), false ); // vec<int, int, ...> -> vec<bool, bool, ...>
10871086 auto passthrough = zeroMaskedLanes ? llvm::Constant::getNullValue (elVecTy) : llvm::UndefValue::get (elVecTy);
1088- auto align = llvm::ConstantInt::get (i32Ty, alignment);
1089- auto func = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::masked_load, { elVecTy, elVecPtrTy });
1090- return V (jit->builder ->CreateCall (func, { V (ptr), align, i8Mask, passthrough }));
1087+ auto func = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::masked_load, { elVecTy, elVecPtrTy });
1088+ auto *call = jit->builder ->CreateCall (func, { V (ptr), i8Mask, passthrough });
1089+ if (alignment != 0 )
1090+ {
1091+ call->addParamAttr (0 , llvm::Attribute::getWithAlignment (*jit->context , llvm::Align (alignment)));
1092+ }
1093+ return V (call);
10911094}
10921095
10931096void Nucleus::createMaskedStore (Value *ptr, Value *val, Value *mask, unsigned int alignment)
@@ -1104,9 +1107,12 @@ void Nucleus::createMaskedStore(Value *ptr, Value *val, Value *mask, unsigned in
11041107 auto elVecTy = V (val)->getType ();
11051108 auto elVecPtrTy = elVecTy->getPointerTo ();
11061109 auto i1Mask = jit->builder ->CreateIntCast (V (mask), llvm::VectorType::get (i1Ty, numEls, false ), false ); // vec<int, int, ...> -> vec<bool, bool, ...>
1107- auto align = llvm::ConstantInt::get (i32Ty, alignment);
1108- auto func = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::masked_store, { elVecTy, elVecPtrTy });
1109- jit->builder ->CreateCall (func, { V (val), V (ptr), align, i1Mask });
1110+ auto func = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::masked_store, { elVecTy, elVecPtrTy });
1111+ auto *call = jit->builder ->CreateCall (func, { V (val), V (ptr), i1Mask });
1112+ if (alignment != 0 )
1113+ {
1114+ call->addParamAttr (1 , llvm::Attribute::getWithAlignment (*jit->context , llvm::Align (alignment)));
1115+ }
11101116
11111117 if (__has_feature (memory_sanitizer) && !REACTOR_ENABLE_MEMORY_SANITIZER_INSTRUMENTATION )
11121118 {
@@ -1147,10 +1153,9 @@ static llvm::Value *createGather(llvm::Value *base, llvm::Type *elTy, llvm::Valu
11471153
11481154 auto numEls = llvm::cast<llvm::FixedVectorType>(mask->getType ())->getNumElements ();
11491155 auto i1Ty = llvm::Type::getInt1Ty (*jit->context );
1150- auto i32Ty = llvm::Type::getInt32Ty (*jit->context );
11511156 auto i8Ty = llvm::Type::getInt8Ty (*jit->context );
1152- auto i8PtrTy = i8Ty-> getPointerTo ( );
1153- auto elPtrTy = elTy-> getPointerTo ( );
1157+ auto i8PtrTy = llvm::PointerType::get (i8Ty, 0 );
1158+ auto elPtrTy = llvm::PointerType::get (elTy, 0 );
11541159 auto elVecTy = llvm::VectorType::get (elTy, numEls, false );
11551160 auto elPtrVecTy = llvm::VectorType::get (elPtrTy, numEls, false );
11561161 auto i8Base = jit->builder ->CreatePointerCast (base, i8PtrTy);
@@ -1161,9 +1166,13 @@ static llvm::Value *createGather(llvm::Value *base, llvm::Type *elTy, llvm::Valu
11611166
11621167 if (!__has_feature (memory_sanitizer))
11631168 {
1164- auto align = llvm::ConstantInt::get (i32Ty, alignment);
1165- auto func = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::masked_gather, { elVecTy, elPtrVecTy });
1166- return jit->builder ->CreateCall (func, { elPtrs, align, i1Mask, passthrough });
1169+ auto func = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::masked_gather, { elVecTy, elPtrVecTy });
1170+ auto *call = jit->builder ->CreateCall (func, { elPtrs, i1Mask, passthrough });
1171+ if (alignment != 0 )
1172+ {
1173+ call->addParamAttr (0 , llvm::Attribute::getWithAlignment (*jit->context , llvm::Align (alignment)));
1174+ }
1175+ return call;
11671176 }
11681177 else // __has_feature(memory_sanitizer)
11691178 {
@@ -1241,9 +1250,12 @@ static void createScatter(llvm::Value *base, llvm::Value *val, llvm::Value *offs
12411250
12421251 if (!__has_feature (memory_sanitizer))
12431252 {
1244- auto align = llvm::ConstantInt::get (i32Ty, alignment);
1245- auto func = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::masked_scatter, { elVecTy, elPtrVecTy });
1246- jit->builder ->CreateCall (func, { val, elPtrs, align, i1Mask });
1253+ auto func = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::masked_scatter, { elVecTy, elPtrVecTy });
1254+ auto *call = jit->builder ->CreateCall (func, { val, elPtrs, i1Mask });
1255+ if (alignment != 0 )
1256+ {
1257+ call->addParamAttr (1 , llvm::Attribute::getWithAlignment (*jit->context , llvm::Align (alignment)));
1258+ }
12471259 }
12481260 else // __has_feature(memory_sanitizer)
12491261 {
@@ -3287,13 +3299,13 @@ Type *Float2::type()
32873299
32883300RValue<Float> Exp2 (RValue<Float> v)
32893301{
3290- auto func = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::exp2, { T (Float::type ()) });
3302+ auto func = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::exp2, { T (Float::type ()) });
32913303 return RValue<Float>(V (jit->builder ->CreateCall (func, V (v.value ()))));
32923304}
32933305
32943306RValue<Float> Log2 (RValue<Float> v)
32953307{
3296- auto func = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::log2, { T (Float::type ()) });
3308+ auto func = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::log2, { T (Float::type ()) });
32973309 return RValue<Float>(V (jit->builder ->CreateCall (func, V (v.value ()))));
32983310}
32993311
@@ -3549,15 +3561,15 @@ template<typename FloatT>
35493561RValue<FloatT> Sin (RValue<FloatT> v)
35503562{
35513563 RR_DEBUG_INFO_UPDATE_LOC ();
3552- auto func = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::sin, { V (v.value ())->getType () });
3564+ auto func = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::sin, { V (v.value ())->getType () });
35533565 return RValue<FloatT>(V (jit->builder ->CreateCall (func, V (v.value ()))));
35543566}
35553567
35563568template <typename FloatT>
35573569RValue<FloatT> Cos (RValue<FloatT> v)
35583570{
35593571 RR_DEBUG_INFO_UPDATE_LOC ();
3560- auto func = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::cos, { V (v.value ())->getType () });
3572+ auto func = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::cos, { V (v.value ())->getType () });
35613573 return RValue<FloatT>(V (jit->builder ->CreateCall (func, V (v.value ()))));
35623574}
35633575
@@ -3668,47 +3680,47 @@ template<typename FloatT>
36683680RValue<FloatT> Pow (RValue<FloatT> x, RValue<FloatT> y)
36693681{
36703682 RR_DEBUG_INFO_UPDATE_LOC ();
3671- auto func = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::pow, { T (FloatT::type ()) });
3683+ auto func = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::pow, { T (FloatT::type ()) });
36723684 return RValue<FloatT>(V (jit->builder ->CreateCall (func, { V (x.value ()), V (y.value ()) })));
36733685}
36743686
36753687template <typename FloatT>
36763688RValue<FloatT> BuiltinPow (RValue<FloatT> x, RValue<FloatT> y)
36773689{
36783690 RR_DEBUG_INFO_UPDATE_LOC ();
3679- auto func = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::pow, { T (FloatT::type ()) });
3691+ auto func = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::pow, { T (FloatT::type ()) });
36803692 return RValue<FloatT>(V (jit->builder ->CreateCall (func, { V (x.value ()), V (y.value ()) })));
36813693}
36823694
36833695template <typename FloatT>
36843696RValue<FloatT> Exp (RValue<FloatT> v)
36853697{
36863698 RR_DEBUG_INFO_UPDATE_LOC ();
3687- auto func = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::exp, { T (FloatT::type ()) });
3699+ auto func = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::exp, { T (FloatT::type ()) });
36883700 return RValue<FloatT>(V (jit->builder ->CreateCall (func, V (v.value ()))));
36893701}
36903702
36913703template <typename FloatT>
36923704RValue<FloatT> Log (RValue<FloatT> v)
36933705{
36943706 RR_DEBUG_INFO_UPDATE_LOC ();
3695- auto func = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::log, { T (FloatT::type ()) });
3707+ auto func = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::log, { T (FloatT::type ()) });
36963708 return RValue<FloatT>(V (jit->builder ->CreateCall (func, V (v.value ()))));
36973709}
36983710
36993711template <typename FloatT>
37003712RValue<FloatT> Exp2 (RValue<FloatT> v)
37013713{
37023714 RR_DEBUG_INFO_UPDATE_LOC ();
3703- auto func = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::exp2, { T (FloatT::type ()) });
3715+ auto func = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::exp2, { T (FloatT::type ()) });
37043716 return RValue<FloatT>(V (jit->builder ->CreateCall (func, V (v.value ()))));
37053717}
37063718
37073719template <typename FloatT>
37083720RValue<FloatT> Log2 (RValue<FloatT> v)
37093721{
37103722 RR_DEBUG_INFO_UPDATE_LOC ();
3711- auto func = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::log2, { T (FloatT::type ()) });
3723+ auto func = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::log2, { T (FloatT::type ()) });
37123724 return RValue<FloatT>(V (jit->builder ->CreateCall (func, V (v.value ()))));
37133725}
37143726
@@ -3739,31 +3751,31 @@ INSTANTIATE_FUNCS(Float8);
37393751RValue<UInt> Ctlz (RValue<UInt> v, bool isZeroUndef)
37403752{
37413753 RR_DEBUG_INFO_UPDATE_LOC ();
3742- auto func = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::ctlz, { T (UInt::type ()) });
3754+ auto func = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::ctlz, { T (UInt::type ()) });
37433755 return RValue<UInt>(V (jit->builder ->CreateCall (func, { V (v.value ()),
37443756 isZeroUndef ? llvm::ConstantInt::getTrue (*jit->context ) : llvm::ConstantInt::getFalse (*jit->context ) })));
37453757}
37463758
37473759RValue<UInt4> Ctlz (RValue<UInt4> v, bool isZeroUndef)
37483760{
37493761 RR_DEBUG_INFO_UPDATE_LOC ();
3750- auto func = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::ctlz, { T (UInt4::type ()) });
3762+ auto func = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::ctlz, { T (UInt4::type ()) });
37513763 return RValue<UInt4>(V (jit->builder ->CreateCall (func, { V (v.value ()),
37523764 isZeroUndef ? llvm::ConstantInt::getTrue (*jit->context ) : llvm::ConstantInt::getFalse (*jit->context ) })));
37533765}
37543766
37553767RValue<UInt> Cttz (RValue<UInt> v, bool isZeroUndef)
37563768{
37573769 RR_DEBUG_INFO_UPDATE_LOC ();
3758- auto func = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::cttz, { T (UInt::type ()) });
3770+ auto func = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::cttz, { T (UInt::type ()) });
37593771 return RValue<UInt>(V (jit->builder ->CreateCall (func, { V (v.value ()),
37603772 isZeroUndef ? llvm::ConstantInt::getTrue (*jit->context ) : llvm::ConstantInt::getFalse (*jit->context ) })));
37613773}
37623774
37633775RValue<UInt4> Cttz (RValue<UInt4> v, bool isZeroUndef)
37643776{
37653777 RR_DEBUG_INFO_UPDATE_LOC ();
3766- auto func = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::cttz, { T (UInt4::type ()) });
3778+ auto func = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::cttz, { T (UInt4::type ()) });
37673779 return RValue<UInt4>(V (jit->builder ->CreateCall (func, { V (v.value ()),
37683780 isZeroUndef ? llvm::ConstantInt::getTrue (*jit->context ) : llvm::ConstantInt::getFalse (*jit->context ) })));
37693781}
@@ -3944,7 +3956,7 @@ RValue<Float8> Sqrt(RValue<Float8> x)
39443956RValue<Long> Ticks ()
39453957{
39463958 RR_DEBUG_INFO_UPDATE_LOC ();
3947- llvm::Function *rdtsc = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::readcyclecounter);
3959+ llvm::Function *rdtsc = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::readcyclecounter);
39483960
39493961 return RValue<Long>(V (jit->builder ->CreateCall (rdtsc)));
39503962}
@@ -3997,7 +4009,7 @@ Value *Call(RValue<Pointer<Byte>> fptr, Type *retTy, std::initializer_list<Value
39974009void Breakpoint ()
39984010{
39994011 RR_DEBUG_INFO_UPDATE_LOC ();
4000- llvm::Function *debugtrap = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::debugtrap);
4012+ llvm::Function *debugtrap = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::debugtrap);
40014013
40024014 jit->builder ->CreateCall (debugtrap);
40034015}
@@ -4013,7 +4025,7 @@ namespace x86 {
40134025// implicit types, such as 'x86_sse_rcp_ps' operating on v4f32, while 'sqrt' requires explicitly specifying the operand type.
40144026static Value *createInstruction (llvm::Intrinsic::ID id, Value *x)
40154027{
4016- llvm::Function *intrinsic = llvm::Intrinsic::getDeclaration (jit->module .get (), id);
4028+ llvm::Function *intrinsic = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), id);
40174029
40184030 return V (jit->builder ->CreateCall (intrinsic, V (x)));
40194031}
@@ -4022,7 +4034,7 @@ static Value *createInstruction(llvm::Intrinsic::ID id, Value *x)
40224034// implicit types, such as 'x86_sse_max_ps' operating on v4f32, while 'sadd_sat' requires explicitly specifying the operand types.
40234035static Value *createInstruction (llvm::Intrinsic::ID id, Value *x, Value *y)
40244036{
4025- llvm::Function *intrinsic = llvm::Intrinsic::getDeclaration (jit->module .get (), id);
4037+ llvm::Function *intrinsic = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), id);
40264038
40274039 return V (jit->builder ->CreateCall (intrinsic, { V (x), V (y) }));
40284040}
@@ -4111,7 +4123,7 @@ RValue<Float4> minps(RValue<Float4> x, RValue<Float4> y)
41114123
41124124RValue<Float> roundss (RValue<Float> val, unsigned char imm)
41134125{
4114- llvm::Function *roundss = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::x86_sse41_round_ss);
4126+ llvm::Function *roundss = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::x86_sse41_round_ss);
41154127
41164128 Value *undef = V (llvm::UndefValue::get (T (Float4::type ())));
41174129
@@ -4509,16 +4521,16 @@ void promoteFunctionToCoroutine()
45094521 auto promisePtrTy = promiseTy->getPointerTo ();
45104522
45114523 // LLVM intrinsics
4512- auto coro_id = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::coro_id);
4513- auto coro_size = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::coro_size, { i32Ty });
4514- auto coro_begin = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::coro_begin);
4515- auto coro_resume = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::coro_resume);
4516- auto coro_end = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::coro_end);
4517- auto coro_free = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::coro_free);
4518- auto coro_destroy = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::coro_destroy);
4519- auto coro_promise = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::coro_promise);
4520- auto coro_done = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::coro_done);
4521- auto coro_suspend = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::coro_suspend);
4524+ auto coro_id = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::coro_id);
4525+ auto coro_size = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::coro_size, { i32Ty });
4526+ auto coro_begin = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::coro_begin);
4527+ auto coro_resume = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::coro_resume);
4528+ auto coro_end = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::coro_end);
4529+ auto coro_free = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::coro_free);
4530+ auto coro_destroy = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::coro_destroy);
4531+ auto coro_promise = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::coro_promise);
4532+ auto coro_done = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::coro_done);
4533+ auto coro_suspend = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::coro_suspend);
45224534
45234535 auto allocFrameTy = llvm::FunctionType::get (i8PtrTy, { i32Ty }, false );
45244536 auto allocFrame = jit->module ->getOrInsertFunction (" coroutine_alloc_frame" , allocFrameTy);
@@ -4718,7 +4730,7 @@ void Nucleus::yield(Value *val)
47184730 auto i8Ty = llvm::Type::getInt8Ty (*jit->context );
47194731
47204732 // Intrinsics
4721- auto coro_suspend = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::coro_suspend);
4733+ auto coro_suspend = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::coro_suspend);
47224734
47234735 // Create a block to resume execution.
47244736 auto resumeBlock = llvm::BasicBlock::Create (*jit->context , " resume" , jit->function );
@@ -4828,7 +4840,7 @@ Nucleus::CoroutineHandle Nucleus::invokeCoroutineBegin(Routine &routine, std::fu
48284840RValue<Bool> isConstant (Value *a)
48294841{
48304842 llvm::Value *va = V (a);
4831- llvm::Function *intrinsic = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::is_constant, va->getType ());
4843+ llvm::Function *intrinsic = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::is_constant, va->getType ());
48324844
48334845 return As<Bool>(V (jit->builder ->CreateCall (intrinsic, va)));
48344846}
@@ -4888,7 +4900,7 @@ template<typename FloatT>
48884900RValue<FloatT> FMA (RValue<FloatT> a, RValue<FloatT> b, RValue<FloatT> c)
48894901{
48904902 llvm::Value *va = V (a.value ()), *vb = V (b.value ()), *vc = V (c.value ());
4891- llvm::Function *intrinsic = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::fma, va->getType ());
4903+ llvm::Function *intrinsic = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::fma, va->getType ());
48924904
48934905 return As<FloatT>(V (jit->builder ->CreateCall (intrinsic, { va, vb, vc })));
48944906}
@@ -4903,7 +4915,7 @@ RValue<Float8> TryFP16To32(RValue<UShort8> x, bool &ok)
49034915 return res;
49044916 ok = true ;
49054917 llvm::Value *vx = V (x.value ());
4906- llvm::Function *intrinsic = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::x86_vcvtph2ps_256, {});
4918+ llvm::Function *intrinsic = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::x86_vcvtph2ps_256, {});
49074919 return As<Float8>(V (jit->builder ->CreateCall (intrinsic, { vx })));
49084920#elif LLVM_VERSION_MAJOR >= 11
49094921 ok = true ;
@@ -4924,7 +4936,7 @@ RValue<UShort8> TryFP32To16(RValue<Float8> x, bool &ok)
49244936 ok = true ;
49254937 llvm::Value *vx = V (x.value ());
49264938 llvm::Value *zero = llvm::Constant::getNullValue (llvm::IntegerType::get (*jit->context , sizeof (int ) * 8 ));
4927- llvm::Function *intrinsic = llvm::Intrinsic::getDeclaration (jit->module .get (), llvm::Intrinsic::x86_vcvtps2ph_256, {});
4939+ llvm::Function *intrinsic = llvm::Intrinsic::getOrInsertDeclaration (jit->module .get (), llvm::Intrinsic::x86_vcvtps2ph_256, {});
49284940 return As<UShort8>(V (jit->builder ->CreateCall (intrinsic, { vx, zero })));
49294941#elif LLVM_VERSION_MAJOR >= 11
49304942 ok = true ;
0 commit comments