@@ -546,7 +546,7 @@ class ValueGenerator {
546546 if (Op == Intrinsic::abs || Op == Intrinsic::ctlz || Op == Intrinsic::cttz)
547547 Args.push_back (ConstantInt::get (Type::getInt1Ty (Ctx), C.flip () ? 1 : 0 ));
548548
549- auto Decl = Intrinsic::getDeclaration (M, Op, Ty);
549+ auto Decl = Intrinsic::getOrInsertDeclaration (M, Op, Ty);
550550 auto *I = CallInst::Create (Decl, Args, " " , BB);
551551 return I;
552552 }
@@ -610,7 +610,7 @@ class ValueGenerator {
610610 assert (false );
611611 }
612612
613- auto Decl = Intrinsic::getDeclaration (M, Op, Ty);
613+ auto Decl = Intrinsic::getOrInsertDeclaration (M, Op, Ty);
614614 auto *I = CallInst::Create (Decl, {LHS, RHS}, " " , BB);
615615 if (Op == Intrinsic::ssub_with_overflow ||
616616 Op == Intrinsic::usub_with_overflow ||
@@ -664,7 +664,7 @@ class ValueGenerator {
664664 Type::getInt32Ty (BB->getContext ()))
665665 : getVal (Ty);
666666
667- auto Decl = Intrinsic::getDeclaration (M, Op, Ty);
667+ auto Decl = Intrinsic::getOrInsertDeclaration (M, Op, Ty);
668668 auto *I = CallInst::Create (Decl, {A, B, C}, " " , BB);
669669 return I;
670670 }
0 commit comments