[NFC] Rename Intrinsic::getDeclaration
to getOrInsertDeclaration
(#111752)
Rename the function to reflect its correct behavior and to be consistent with `Module::getOrInsertFunction`. This is also in preparation of adding a new `Intrinsic::getDeclaration` that will have behavior similar to `Module::getFunction` (i.e, just lookup, no creation).
This commit is contained in:
parent
900ea21ffb
commit
fa789dffb1
@ -13648,7 +13648,7 @@ Value *CodeGenFunction::EmitBPFBuiltinExpr(unsigned BuiltinID,
|
||||
Value *InfoKind = ConstantInt::get(Int64Ty, C->getSExtValue());
|
||||
|
||||
// Built the IR for the preserve_field_info intrinsic.
|
||||
llvm::Function *FnGetFieldInfo = llvm::Intrinsic::getDeclaration(
|
||||
llvm::Function *FnGetFieldInfo = llvm::Intrinsic::getOrInsertDeclaration(
|
||||
&CGM.getModule(), llvm::Intrinsic::bpf_preserve_field_info,
|
||||
{FieldAddr->getType()});
|
||||
return Builder.CreateCall(FnGetFieldInfo, {FieldAddr, InfoKind});
|
||||
@ -13670,10 +13670,10 @@ Value *CodeGenFunction::EmitBPFBuiltinExpr(unsigned BuiltinID,
|
||||
|
||||
llvm::Function *FnDecl;
|
||||
if (BuiltinID == BPF::BI__builtin_btf_type_id)
|
||||
FnDecl = llvm::Intrinsic::getDeclaration(
|
||||
FnDecl = llvm::Intrinsic::getOrInsertDeclaration(
|
||||
&CGM.getModule(), llvm::Intrinsic::bpf_btf_type_id, {});
|
||||
else
|
||||
FnDecl = llvm::Intrinsic::getDeclaration(
|
||||
FnDecl = llvm::Intrinsic::getOrInsertDeclaration(
|
||||
&CGM.getModule(), llvm::Intrinsic::bpf_preserve_type_info, {});
|
||||
CallInst *Fn = Builder.CreateCall(FnDecl, {SeqNumVal, FlagValue});
|
||||
Fn->setMetadata(LLVMContext::MD_preserve_access_index, DbgInfo);
|
||||
@ -13708,7 +13708,7 @@ Value *CodeGenFunction::EmitBPFBuiltinExpr(unsigned BuiltinID,
|
||||
Value *FlagValue = ConstantInt::get(Int64Ty, Flag->getSExtValue());
|
||||
Value *SeqNumVal = ConstantInt::get(Int32Ty, BuiltinSeqNum++);
|
||||
|
||||
llvm::Function *IntrinsicFn = llvm::Intrinsic::getDeclaration(
|
||||
llvm::Function *IntrinsicFn = llvm::Intrinsic::getOrInsertDeclaration(
|
||||
&CGM.getModule(), llvm::Intrinsic::bpf_preserve_enum_value, {});
|
||||
CallInst *Fn =
|
||||
Builder.CreateCall(IntrinsicFn, {SeqNumVal, EnumStrVal, FlagValue});
|
||||
@ -18895,7 +18895,8 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: {
|
||||
}
|
||||
case Builtin::BI__builtin_hlsl_wave_is_first_lane: {
|
||||
Intrinsic::ID ID = CGM.getHLSLRuntime().getWaveIsFirstLaneIntrinsic();
|
||||
return EmitRuntimeCall(Intrinsic::getDeclaration(&CGM.getModule(), ID));
|
||||
return EmitRuntimeCall(
|
||||
Intrinsic::getOrInsertDeclaration(&CGM.getModule(), ID));
|
||||
}
|
||||
case Builtin::BI__builtin_hlsl_elementwise_sign: {
|
||||
auto *Arg0 = E->getArg(0);
|
||||
|
@ -2509,8 +2509,8 @@ void CodeGenFunction::pushRegularPartialArrayCleanup(llvm::Value *arrayBegin,
|
||||
llvm::Function *CodeGenModule::getLLVMLifetimeStartFn() {
|
||||
if (LifetimeStartFn)
|
||||
return LifetimeStartFn;
|
||||
LifetimeStartFn = llvm::Intrinsic::getDeclaration(&getModule(),
|
||||
llvm::Intrinsic::lifetime_start, AllocaInt8PtrTy);
|
||||
LifetimeStartFn = llvm::Intrinsic::getOrInsertDeclaration(
|
||||
&getModule(), llvm::Intrinsic::lifetime_start, AllocaInt8PtrTy);
|
||||
return LifetimeStartFn;
|
||||
}
|
||||
|
||||
@ -2518,8 +2518,8 @@ llvm::Function *CodeGenModule::getLLVMLifetimeStartFn() {
|
||||
llvm::Function *CodeGenModule::getLLVMLifetimeEndFn() {
|
||||
if (LifetimeEndFn)
|
||||
return LifetimeEndFn;
|
||||
LifetimeEndFn = llvm::Intrinsic::getDeclaration(&getModule(),
|
||||
llvm::Intrinsic::lifetime_end, AllocaInt8PtrTy);
|
||||
LifetimeEndFn = llvm::Intrinsic::getOrInsertDeclaration(
|
||||
&getModule(), llvm::Intrinsic::lifetime_end, AllocaInt8PtrTy);
|
||||
return LifetimeEndFn;
|
||||
}
|
||||
|
||||
|
@ -1843,7 +1843,7 @@ Address CodeGenFunction::recoverAddrOfEscapedLocal(CodeGenFunction &ParentCGF,
|
||||
std::make_pair(ParentAlloca, ParentCGF.EscapedLocals.size()));
|
||||
int FrameEscapeIdx = InsertPair.first->second;
|
||||
// call ptr @llvm.localrecover(ptr @parentFn, ptr %fp, i32 N)
|
||||
llvm::Function *FrameRecoverFn = llvm::Intrinsic::getDeclaration(
|
||||
llvm::Function *FrameRecoverFn = llvm::Intrinsic::getOrInsertDeclaration(
|
||||
&CGM.getModule(), llvm::Intrinsic::localrecover);
|
||||
RecoverCall = Builder.CreateCall(
|
||||
FrameRecoverFn, {ParentCGF.CurFn, ParentFP,
|
||||
@ -1942,7 +1942,7 @@ void CodeGenFunction::EmitCapturedLocals(CodeGenFunction &ParentCGF,
|
||||
// %1 = call ptr @llvm.localrecover(@"?fin$0@0@main@@",..)
|
||||
// %2 = load ptr, ptr %1, align 8
|
||||
// ==> %2 is the frame-pointer of outermost host function
|
||||
llvm::Function *FrameRecoverFn = llvm::Intrinsic::getDeclaration(
|
||||
llvm::Function *FrameRecoverFn = llvm::Intrinsic::getOrInsertDeclaration(
|
||||
&CGM.getModule(), llvm::Intrinsic::localrecover);
|
||||
ParentFP = Builder.CreateCall(
|
||||
FrameRecoverFn, {ParentCGF.CurFn, ParentFP,
|
||||
|
@ -463,7 +463,7 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) {
|
||||
EscapeArgs.resize(EscapedLocals.size());
|
||||
for (auto &Pair : EscapedLocals)
|
||||
EscapeArgs[Pair.second] = Pair.first;
|
||||
llvm::Function *FrameEscapeFn = llvm::Intrinsic::getDeclaration(
|
||||
llvm::Function *FrameEscapeFn = llvm::Intrinsic::getOrInsertDeclaration(
|
||||
&CGM.getModule(), llvm::Intrinsic::localescape);
|
||||
CGBuilderTy(*this, AllocaInsertPt).CreateCall(FrameEscapeFn, EscapeArgs);
|
||||
}
|
||||
@ -3130,7 +3130,7 @@ void CodeGenFunction::emitAlignmentAssumptionCheck(
|
||||
llvm::Instruction *Assumption) {
|
||||
assert(isa_and_nonnull<llvm::CallInst>(Assumption) &&
|
||||
cast<llvm::CallInst>(Assumption)->getCalledOperand() ==
|
||||
llvm::Intrinsic::getDeclaration(
|
||||
llvm::Intrinsic::getOrInsertDeclaration(
|
||||
Builder.GetInsertBlock()->getParent()->getParent(),
|
||||
llvm::Intrinsic::assume) &&
|
||||
"Assumption should be a call to llvm.assume().");
|
||||
|
@ -6218,8 +6218,8 @@ void CodeGenModule::emitIFuncDefinition(GlobalDecl GD) {
|
||||
|
||||
llvm::Function *CodeGenModule::getIntrinsic(unsigned IID,
|
||||
ArrayRef<llvm::Type*> Tys) {
|
||||
return llvm::Intrinsic::getDeclaration(&getModule(), (llvm::Intrinsic::ID)IID,
|
||||
Tys);
|
||||
return llvm::Intrinsic::getOrInsertDeclaration(&getModule(),
|
||||
(llvm::Intrinsic::ID)IID, Tys);
|
||||
}
|
||||
|
||||
static llvm::StringMapEntry<llvm::GlobalVariable *> &
|
||||
|
@ -110,8 +110,8 @@ public:
|
||||
if (Ty->isFloatTy() || Ty->isDoubleTy() || Ty->isFP128Ty()) {
|
||||
llvm::Module &M = CGM.getModule();
|
||||
auto &Ctx = M.getContext();
|
||||
llvm::Function *TDCFunc =
|
||||
llvm::Intrinsic::getDeclaration(&M, llvm::Intrinsic::s390_tdc, Ty);
|
||||
llvm::Function *TDCFunc = llvm::Intrinsic::getOrInsertDeclaration(
|
||||
&M, llvm::Intrinsic::s390_tdc, Ty);
|
||||
unsigned TDCBits = 0;
|
||||
switch (BuiltinID) {
|
||||
case Builtin::BI__builtin_isnan:
|
||||
|
@ -67,8 +67,8 @@ void BrainF::header(LLVMContext& C) {
|
||||
|
||||
//declare void @llvm.memset.p0i8.i32(i8 *, i8, i32, i1)
|
||||
Type *Tys[] = {PointerType::getUnqual(C), Type::getInt32Ty(C)};
|
||||
Function *memset_func = Intrinsic::getDeclaration(module, Intrinsic::memset,
|
||||
Tys);
|
||||
Function *memset_func =
|
||||
Intrinsic::getOrInsertDeclaration(module, Intrinsic::memset, Tys);
|
||||
|
||||
//declare i32 @getchar()
|
||||
getchar_func =
|
||||
|
@ -2807,10 +2807,10 @@ unsigned LLVMLookupIntrinsicID(const char *Name, size_t NameLen);
|
||||
unsigned LLVMGetIntrinsicID(LLVMValueRef Fn);
|
||||
|
||||
/**
|
||||
* Create or insert the declaration of an intrinsic. For overloaded intrinsics,
|
||||
* Get or insert the declaration of an intrinsic. For overloaded intrinsics,
|
||||
* parameter types must be provided to uniquely identify an overload.
|
||||
*
|
||||
* @see llvm::Intrinsic::getDeclaration()
|
||||
* @see llvm::Intrinsic::getOrInsertDeclaration()
|
||||
*/
|
||||
LLVMValueRef LLVMGetIntrinsicDeclaration(LLVMModuleRef Mod,
|
||||
unsigned ID,
|
||||
|
@ -568,9 +568,9 @@ public:
|
||||
/// \brief Declares a llvm.vp.* intrinsic in \p M that matches the parameters
|
||||
/// \p Params. Additionally, the load and gather intrinsics require
|
||||
/// \p ReturnType to be specified.
|
||||
static Function *getDeclarationForParams(Module *M, Intrinsic::ID,
|
||||
Type *ReturnType,
|
||||
ArrayRef<Value *> Params);
|
||||
static Function *getOrInsertDeclarationForParams(Module *M, Intrinsic::ID,
|
||||
Type *ReturnType,
|
||||
ArrayRef<Value *> Params);
|
||||
|
||||
static std::optional<unsigned> getMaskParamPos(Intrinsic::ID IntrinsicID);
|
||||
static std::optional<unsigned> getVectorLengthParamPos(
|
||||
|
@ -87,14 +87,15 @@ namespace Intrinsic {
|
||||
/// Return the attributes for an intrinsic.
|
||||
AttributeList getAttributes(LLVMContext &C, ID id);
|
||||
|
||||
/// Create or insert an LLVM Function declaration for an intrinsic, and return
|
||||
/// it.
|
||||
/// Look up the Function declaration of the intrinsic \p id in the Module
|
||||
/// \p M. If it does not exist, add a declaration and return it. Otherwise,
|
||||
/// return the existing declaration.
|
||||
///
|
||||
/// The Tys parameter is for intrinsics with overloaded types (e.g., those
|
||||
/// The \p Tys parameter is for intrinsics with overloaded types (e.g., those
|
||||
/// using iAny, fAny, vAny, or iPTRAny). For a declaration of an overloaded
|
||||
/// intrinsic, Tys must provide exactly one type for each overloaded type in
|
||||
/// the intrinsic.
|
||||
Function *getDeclaration(Module *M, ID id, ArrayRef<Type *> Tys = {});
|
||||
Function *getOrInsertDeclaration(Module *M, ID id, ArrayRef<Type *> Tys = {});
|
||||
|
||||
/// Looks up Name in NameTable via binary search. NameTable must be sorted
|
||||
/// and all entries must start with "llvm.". If NameTable contains an exact
|
||||
|
@ -72,7 +72,7 @@ public:
|
||||
B.getInt32(Columns)};
|
||||
Type *OverloadedTypes[] = {RetType, Stride->getType()};
|
||||
|
||||
Function *TheFn = Intrinsic::getDeclaration(
|
||||
Function *TheFn = Intrinsic::getOrInsertDeclaration(
|
||||
getModule(), Intrinsic::matrix_column_major_load, OverloadedTypes);
|
||||
|
||||
CallInst *Call = B.CreateCall(TheFn->getFunctionType(), TheFn, Ops, Name);
|
||||
@ -95,7 +95,7 @@ public:
|
||||
B.getInt32(Rows), B.getInt32(Columns)};
|
||||
Type *OverloadedTypes[] = {Matrix->getType(), Stride->getType()};
|
||||
|
||||
Function *TheFn = Intrinsic::getDeclaration(
|
||||
Function *TheFn = Intrinsic::getOrInsertDeclaration(
|
||||
getModule(), Intrinsic::matrix_column_major_store, OverloadedTypes);
|
||||
|
||||
CallInst *Call = B.CreateCall(TheFn->getFunctionType(), TheFn, Ops, Name);
|
||||
@ -115,7 +115,7 @@ public:
|
||||
|
||||
Type *OverloadedTypes[] = {ReturnType};
|
||||
Value *Ops[] = {Matrix, B.getInt32(Rows), B.getInt32(Columns)};
|
||||
Function *TheFn = Intrinsic::getDeclaration(
|
||||
Function *TheFn = Intrinsic::getOrInsertDeclaration(
|
||||
getModule(), Intrinsic::matrix_transpose, OverloadedTypes);
|
||||
|
||||
return B.CreateCall(TheFn->getFunctionType(), TheFn, Ops, Name);
|
||||
@ -136,7 +136,7 @@ public:
|
||||
B.getInt32(RHSColumns)};
|
||||
Type *OverloadedTypes[] = {ReturnType, LHSType, RHSType};
|
||||
|
||||
Function *TheFn = Intrinsic::getDeclaration(
|
||||
Function *TheFn = Intrinsic::getOrInsertDeclaration(
|
||||
getModule(), Intrinsic::matrix_multiply, OverloadedTypes);
|
||||
return B.CreateCall(TheFn->getFunctionType(), TheFn, Ops, Name);
|
||||
}
|
||||
|
@ -360,7 +360,7 @@ bool LLParser::validateEndOfModule(bool UpgradeDebugInfo) {
|
||||
OverloadTys))
|
||||
return error(Info.second, "invalid intrinsic signature");
|
||||
|
||||
U.set(Intrinsic::getDeclaration(M, IID, OverloadTys));
|
||||
U.set(Intrinsic::getOrInsertDeclaration(M, IID, OverloadTys));
|
||||
}
|
||||
|
||||
Info.first->eraseFromParent();
|
||||
|
@ -356,7 +356,7 @@ static void expandIToFP(Instruction *IToFP) {
|
||||
Entry->getTerminator()->eraseFromParent();
|
||||
|
||||
Function *CTLZ =
|
||||
Intrinsic::getDeclaration(F->getParent(), Intrinsic::ctlz, IntTy);
|
||||
Intrinsic::getOrInsertDeclaration(F->getParent(), Intrinsic::ctlz, IntTy);
|
||||
ConstantInt *True = Builder.getTrue();
|
||||
|
||||
// entry:
|
||||
|
@ -355,7 +355,7 @@ MemCmpExpansion::LoadPair MemCmpExpansion::getLoadPair(Type *LoadSizeType,
|
||||
|
||||
// Swap bytes if required.
|
||||
if (BSwapSizeType) {
|
||||
Function *Bswap = Intrinsic::getDeclaration(
|
||||
Function *Bswap = Intrinsic::getOrInsertDeclaration(
|
||||
CI->getModule(), Intrinsic::bswap, BSwapSizeType);
|
||||
Lhs = Builder.CreateCall(Bswap, Lhs);
|
||||
Rhs = Builder.CreateCall(Bswap, Rhs);
|
||||
|
@ -237,7 +237,7 @@ Value *CachingVPExpander::convertEVLToMask(IRBuilder<> &Builder,
|
||||
if (ElemCount.isScalable()) {
|
||||
auto *M = Builder.GetInsertBlock()->getModule();
|
||||
Type *BoolVecTy = VectorType::get(Builder.getInt1Ty(), ElemCount);
|
||||
Function *ActiveMaskFunc = Intrinsic::getDeclaration(
|
||||
Function *ActiveMaskFunc = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::get_active_lane_mask, {BoolVecTy, EVLParam->getType()});
|
||||
// `get_active_lane_mask` performs an implicit less-than comparison.
|
||||
Value *ConstZero = Builder.getInt32(0);
|
||||
@ -299,7 +299,7 @@ Value *CachingVPExpander::expandPredicationToIntCall(
|
||||
case Intrinsic::umin: {
|
||||
Value *Op0 = VPI.getOperand(0);
|
||||
Value *Op1 = VPI.getOperand(1);
|
||||
Function *Fn = Intrinsic::getDeclaration(
|
||||
Function *Fn = Intrinsic::getOrInsertDeclaration(
|
||||
VPI.getModule(), UnpredicatedIntrinsicID, {VPI.getType()});
|
||||
Value *NewOp = Builder.CreateCall(Fn, {Op0, Op1}, VPI.getName());
|
||||
replaceOperation(*NewOp, VPI);
|
||||
@ -308,7 +308,7 @@ Value *CachingVPExpander::expandPredicationToIntCall(
|
||||
case Intrinsic::bswap:
|
||||
case Intrinsic::bitreverse: {
|
||||
Value *Op = VPI.getOperand(0);
|
||||
Function *Fn = Intrinsic::getDeclaration(
|
||||
Function *Fn = Intrinsic::getOrInsertDeclaration(
|
||||
VPI.getModule(), UnpredicatedIntrinsicID, {VPI.getType()});
|
||||
Value *NewOp = Builder.CreateCall(Fn, {Op}, VPI.getName());
|
||||
replaceOperation(*NewOp, VPI);
|
||||
@ -327,7 +327,7 @@ Value *CachingVPExpander::expandPredicationToFPCall(
|
||||
case Intrinsic::fabs:
|
||||
case Intrinsic::sqrt: {
|
||||
Value *Op0 = VPI.getOperand(0);
|
||||
Function *Fn = Intrinsic::getDeclaration(
|
||||
Function *Fn = Intrinsic::getOrInsertDeclaration(
|
||||
VPI.getModule(), UnpredicatedIntrinsicID, {VPI.getType()});
|
||||
Value *NewOp = Builder.CreateCall(Fn, {Op0}, VPI.getName());
|
||||
replaceOperation(*NewOp, VPI);
|
||||
@ -337,7 +337,7 @@ Value *CachingVPExpander::expandPredicationToFPCall(
|
||||
case Intrinsic::minnum: {
|
||||
Value *Op0 = VPI.getOperand(0);
|
||||
Value *Op1 = VPI.getOperand(1);
|
||||
Function *Fn = Intrinsic::getDeclaration(
|
||||
Function *Fn = Intrinsic::getOrInsertDeclaration(
|
||||
VPI.getModule(), UnpredicatedIntrinsicID, {VPI.getType()});
|
||||
Value *NewOp = Builder.CreateCall(Fn, {Op0, Op1}, VPI.getName());
|
||||
replaceOperation(*NewOp, VPI);
|
||||
@ -350,7 +350,7 @@ Value *CachingVPExpander::expandPredicationToFPCall(
|
||||
Value *Op0 = VPI.getOperand(0);
|
||||
Value *Op1 = VPI.getOperand(1);
|
||||
Value *Op2 = VPI.getOperand(2);
|
||||
Function *Fn = Intrinsic::getDeclaration(
|
||||
Function *Fn = Intrinsic::getOrInsertDeclaration(
|
||||
VPI.getModule(), UnpredicatedIntrinsicID, {VPI.getType()});
|
||||
Value *NewOp;
|
||||
if (Intrinsic::isConstrainedFPIntrinsic(UnpredicatedIntrinsicID))
|
||||
@ -594,7 +594,7 @@ bool CachingVPExpander::discardEVLParameter(VPIntrinsic &VPI) {
|
||||
// TODO add caching
|
||||
auto *M = VPI.getModule();
|
||||
Function *VScaleFunc =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::vscale, Int32Ty);
|
||||
Intrinsic::getOrInsertDeclaration(M, Intrinsic::vscale, Int32Ty);
|
||||
IRBuilder<> Builder(VPI.getParent(), VPI.getIterator());
|
||||
Value *FactorConst = Builder.getInt32(StaticElemCount.getKnownMinValue());
|
||||
Value *VScale = Builder.CreateCall(VScaleFunc, {}, "vscale");
|
||||
|
@ -512,7 +512,7 @@ Value* HardwareLoop::InsertIterationSetup(Value *LoopCountInit) {
|
||||
: Intrinsic::test_set_loop_iterations)
|
||||
: (UsePhi ? Intrinsic::start_loop_iterations
|
||||
: Intrinsic::set_loop_iterations);
|
||||
Function *LoopIter = Intrinsic::getDeclaration(M, ID, Ty);
|
||||
Function *LoopIter = Intrinsic::getOrInsertDeclaration(M, ID, Ty);
|
||||
Value *LoopSetup = Builder.CreateCall(LoopIter, LoopCountInit);
|
||||
|
||||
// Use the return value of the intrinsic to control the entry of the loop.
|
||||
@ -541,9 +541,8 @@ void HardwareLoop::InsertLoopDec() {
|
||||
Attribute::StrictFP))
|
||||
CondBuilder.setIsFPConstrained(true);
|
||||
|
||||
Function *DecFunc =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::loop_decrement,
|
||||
LoopDecrement->getType());
|
||||
Function *DecFunc = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::loop_decrement, LoopDecrement->getType());
|
||||
Value *Ops[] = { LoopDecrement };
|
||||
Value *NewCond = CondBuilder.CreateCall(DecFunc, Ops);
|
||||
Value *OldCond = ExitBranch->getCondition();
|
||||
@ -566,9 +565,8 @@ Instruction* HardwareLoop::InsertLoopRegDec(Value *EltsRem) {
|
||||
Attribute::StrictFP))
|
||||
CondBuilder.setIsFPConstrained(true);
|
||||
|
||||
Function *DecFunc =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::loop_decrement_reg,
|
||||
{ EltsRem->getType() });
|
||||
Function *DecFunc = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::loop_decrement_reg, {EltsRem->getType()});
|
||||
Value *Ops[] = { EltsRem, LoopDecrement };
|
||||
Value *Call = CondBuilder.CreateCall(DecFunc, Ops);
|
||||
|
||||
|
@ -474,7 +474,7 @@ bool IntrinsicLowering::LowerToByteSwap(CallInst *CI) {
|
||||
|
||||
// Okay, we can do this xform, do so now.
|
||||
Module *M = CI->getModule();
|
||||
Function *Int = Intrinsic::getDeclaration(M, Intrinsic::bswap, Ty);
|
||||
Function *Int = Intrinsic::getOrInsertDeclaration(M, Intrinsic::bswap, Ty);
|
||||
|
||||
Value *Op = CI->getArgOperand(0);
|
||||
Op = CallInst::Create(Int, Op, CI->getName(), CI->getIterator());
|
||||
|
@ -368,7 +368,8 @@ Value *SafeStack::getStackGuard(IRBuilder<> &IRB, Function &F) {
|
||||
|
||||
if (!StackGuardVar) {
|
||||
TL.insertSSPDeclarations(*M);
|
||||
return IRB.CreateCall(Intrinsic::getDeclaration(M, Intrinsic::stackguard));
|
||||
return IRB.CreateCall(
|
||||
Intrinsic::getOrInsertDeclaration(M, Intrinsic::stackguard));
|
||||
}
|
||||
|
||||
return IRB.CreateLoad(StackPtrTy, StackGuardVar, "StackGuard");
|
||||
|
@ -508,17 +508,19 @@ bool SjLjEHPrepareImpl::runOnFunction(Function &F) {
|
||||
|
||||
PointerType *AllocaPtrTy = M.getDataLayout().getAllocaPtrType(M.getContext());
|
||||
|
||||
FrameAddrFn =
|
||||
Intrinsic::getDeclaration(&M, Intrinsic::frameaddress, {AllocaPtrTy});
|
||||
StackAddrFn =
|
||||
Intrinsic::getDeclaration(&M, Intrinsic::stacksave, {AllocaPtrTy});
|
||||
StackRestoreFn =
|
||||
Intrinsic::getDeclaration(&M, Intrinsic::stackrestore, {AllocaPtrTy});
|
||||
FrameAddrFn = Intrinsic::getOrInsertDeclaration(&M, Intrinsic::frameaddress,
|
||||
{AllocaPtrTy});
|
||||
StackAddrFn = Intrinsic::getOrInsertDeclaration(&M, Intrinsic::stacksave,
|
||||
{AllocaPtrTy});
|
||||
StackRestoreFn = Intrinsic::getOrInsertDeclaration(
|
||||
&M, Intrinsic::stackrestore, {AllocaPtrTy});
|
||||
BuiltinSetupDispatchFn =
|
||||
Intrinsic::getDeclaration(&M, Intrinsic::eh_sjlj_setup_dispatch);
|
||||
LSDAAddrFn = Intrinsic::getDeclaration(&M, Intrinsic::eh_sjlj_lsda);
|
||||
CallSiteFn = Intrinsic::getDeclaration(&M, Intrinsic::eh_sjlj_callsite);
|
||||
FuncCtxFn = Intrinsic::getDeclaration(&M, Intrinsic::eh_sjlj_functioncontext);
|
||||
Intrinsic::getOrInsertDeclaration(&M, Intrinsic::eh_sjlj_setup_dispatch);
|
||||
LSDAAddrFn = Intrinsic::getOrInsertDeclaration(&M, Intrinsic::eh_sjlj_lsda);
|
||||
CallSiteFn =
|
||||
Intrinsic::getOrInsertDeclaration(&M, Intrinsic::eh_sjlj_callsite);
|
||||
FuncCtxFn =
|
||||
Intrinsic::getOrInsertDeclaration(&M, Intrinsic::eh_sjlj_functioncontext);
|
||||
|
||||
bool Res = setupEntryBlockAndCallSites(F);
|
||||
return Res;
|
||||
|
@ -519,7 +519,8 @@ static Value *getStackGuard(const TargetLoweringBase *TLI, Module *M,
|
||||
if (SupportsSelectionDAGSP)
|
||||
*SupportsSelectionDAGSP = true;
|
||||
TLI->insertSSPDeclarations(*M);
|
||||
return B.CreateCall(Intrinsic::getDeclaration(M, Intrinsic::stackguard));
|
||||
return B.CreateCall(
|
||||
Intrinsic::getOrInsertDeclaration(M, Intrinsic::stackguard));
|
||||
}
|
||||
|
||||
/// Insert code into the entry block that stores the stack guard
|
||||
@ -540,7 +541,7 @@ static bool CreatePrologue(Function *F, Module *M, Instruction *CheckLoc,
|
||||
AI = B.CreateAlloca(PtrTy, nullptr, "StackGuardSlot");
|
||||
|
||||
Value *GuardSlot = getStackGuard(TLI, M, B, &SupportsSelectionDAGSP);
|
||||
B.CreateCall(Intrinsic::getDeclaration(M, Intrinsic::stackprotector),
|
||||
B.CreateCall(Intrinsic::getOrInsertDeclaration(M, Intrinsic::stackprotector),
|
||||
{GuardSlot, AI});
|
||||
return SupportsSelectionDAGSP;
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ bool WasmEHPrepareImpl::prepareThrows(Function &F) {
|
||||
bool Changed = false;
|
||||
|
||||
// wasm.throw() intinsic, which will be lowered to wasm 'throw' instruction.
|
||||
ThrowF = Intrinsic::getDeclaration(&M, Intrinsic::wasm_throw);
|
||||
ThrowF = Intrinsic::getOrInsertDeclaration(&M, Intrinsic::wasm_throw);
|
||||
// Insert an unreachable instruction after a call to @llvm.wasm.throw and
|
||||
// delete all following instructions within the BB, and delete all the dead
|
||||
// children of the BB as well.
|
||||
@ -260,18 +260,21 @@ bool WasmEHPrepareImpl::prepareEHPads(Function &F) {
|
||||
0, 2, "selector_gep");
|
||||
|
||||
// wasm.landingpad.index() intrinsic, which is to specify landingpad index
|
||||
LPadIndexF = Intrinsic::getDeclaration(&M, Intrinsic::wasm_landingpad_index);
|
||||
LPadIndexF =
|
||||
Intrinsic::getOrInsertDeclaration(&M, Intrinsic::wasm_landingpad_index);
|
||||
// wasm.lsda() intrinsic. Returns the address of LSDA table for the current
|
||||
// function.
|
||||
LSDAF = Intrinsic::getDeclaration(&M, Intrinsic::wasm_lsda);
|
||||
LSDAF = Intrinsic::getOrInsertDeclaration(&M, Intrinsic::wasm_lsda);
|
||||
// wasm.get.exception() and wasm.get.ehselector() intrinsics. Calls to these
|
||||
// are generated in clang.
|
||||
GetExnF = Intrinsic::getDeclaration(&M, Intrinsic::wasm_get_exception);
|
||||
GetSelectorF = Intrinsic::getDeclaration(&M, Intrinsic::wasm_get_ehselector);
|
||||
GetExnF =
|
||||
Intrinsic::getOrInsertDeclaration(&M, Intrinsic::wasm_get_exception);
|
||||
GetSelectorF =
|
||||
Intrinsic::getOrInsertDeclaration(&M, Intrinsic::wasm_get_ehselector);
|
||||
|
||||
// wasm.catch() will be lowered down to wasm 'catch' instruction in
|
||||
// instruction selection.
|
||||
CatchF = Intrinsic::getDeclaration(&M, Intrinsic::wasm_catch);
|
||||
CatchF = Intrinsic::getOrInsertDeclaration(&M, Intrinsic::wasm_catch);
|
||||
|
||||
// _Unwind_CallPersonality() wrapper function, which calls the personality
|
||||
CallPersonalityF = M.getOrInsertFunction("_Unwind_CallPersonality",
|
||||
|
@ -65,7 +65,7 @@ static bool upgradePTESTIntrinsic(Function *F, Intrinsic::ID IID,
|
||||
|
||||
// Yes, it's old, replace it with new version.
|
||||
rename(F);
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(), IID);
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(), IID);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ static bool upgradeX86IntrinsicsWith8BitMask(Function *F, Intrinsic::ID IID,
|
||||
|
||||
// Move this function aside and map down.
|
||||
rename(F);
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(), IID);
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(), IID);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -94,7 +94,7 @@ static bool upgradeX86MaskedFPCompare(Function *F, Intrinsic::ID IID,
|
||||
return false;
|
||||
|
||||
rename(F);
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(), IID);
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(), IID);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -104,7 +104,7 @@ static bool upgradeX86BF16Intrinsic(Function *F, Intrinsic::ID IID,
|
||||
return false;
|
||||
|
||||
rename(F);
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(), IID);
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(), IID);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ static bool upgradeX86BF16DPIntrinsic(Function *F, Intrinsic::ID IID,
|
||||
return false;
|
||||
|
||||
rename(F);
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(), IID);
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(), IID);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -502,8 +502,8 @@ static bool upgradeX86IntrinsicFunction(Function *F, StringRef Name,
|
||||
return false;
|
||||
|
||||
rename(F);
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(),
|
||||
Intrinsic::x86_rdtscp);
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(),
|
||||
Intrinsic::x86_rdtscp);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -609,14 +609,15 @@ static bool upgradeX86IntrinsicFunction(Function *F, StringRef Name,
|
||||
|
||||
if (ID != Intrinsic::not_intrinsic) {
|
||||
rename(F);
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(), ID);
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(), ID);
|
||||
return true;
|
||||
}
|
||||
return false; // No other 'x86.xop.*'
|
||||
}
|
||||
|
||||
if (Name == "seh.recoverfp") {
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::eh_recoverfp);
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(),
|
||||
Intrinsic::eh_recoverfp);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -630,15 +631,15 @@ static bool upgradeArmOrAarch64IntrinsicFunction(bool IsArm, Function *F,
|
||||
Function *&NewFn) {
|
||||
if (Name.starts_with("rbit")) {
|
||||
// '(arm|aarch64).rbit'.
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::bitreverse,
|
||||
F->arg_begin()->getType());
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(
|
||||
F->getParent(), Intrinsic::bitreverse, F->arg_begin()->getType());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Name == "thread.pointer") {
|
||||
// '(arm|aarch64).thread.pointer'.
|
||||
NewFn =
|
||||
Intrinsic::getDeclaration(F->getParent(), Intrinsic::thread_pointer);
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(),
|
||||
Intrinsic::thread_pointer);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -663,7 +664,7 @@ static bool upgradeArmOrAarch64IntrinsicFunction(bool IsArm, Function *F,
|
||||
std::array<Type *, 2> Tys{
|
||||
{F->getReturnType(),
|
||||
FixedVectorType::get(Type::getBFloatTy(Ctx), OperandWidth / 16)}};
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(), ID, Tys);
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(), ID, Tys);
|
||||
return true;
|
||||
}
|
||||
return false; // No other '(arm|aarch64).neon.bfdot.*'.
|
||||
@ -688,7 +689,7 @@ static bool upgradeArmOrAarch64IntrinsicFunction(bool IsArm, Function *F,
|
||||
: (Intrinsic::ID)Intrinsic::aarch64_neon_bfmlalt)
|
||||
.Default(Intrinsic::not_intrinsic);
|
||||
if (ID != Intrinsic::not_intrinsic) {
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(), ID);
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(), ID);
|
||||
return true;
|
||||
}
|
||||
return false; // No other '(arm|aarch64).neon.bfm*.v16i8'.
|
||||
@ -712,8 +713,8 @@ static bool upgradeArmOrAarch64IntrinsicFunction(bool IsArm, Function *F,
|
||||
.StartsWith("vqsubu.", Intrinsic::usub_sat)
|
||||
.Default(Intrinsic::not_intrinsic);
|
||||
if (ID != Intrinsic::not_intrinsic) {
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(), ID,
|
||||
F->arg_begin()->getType());
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(), ID,
|
||||
F->arg_begin()->getType());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -733,10 +734,10 @@ static bool upgradeArmOrAarch64IntrinsicFunction(bool IsArm, Function *F,
|
||||
auto fArgs = F->getFunctionType()->params();
|
||||
Type *Tys[] = {fArgs[0], fArgs[1]};
|
||||
if (Groups[1].size() == 1)
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(),
|
||||
StoreInts[fArgs.size() - 3], Tys);
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(
|
||||
F->getParent(), StoreInts[fArgs.size() - 3], Tys);
|
||||
else
|
||||
NewFn = Intrinsic::getDeclaration(
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(
|
||||
F->getParent(), StoreLaneInts[fArgs.size() - 5], Tys);
|
||||
return true;
|
||||
}
|
||||
@ -810,8 +811,8 @@ static bool upgradeArmOrAarch64IntrinsicFunction(bool IsArm, Function *F,
|
||||
.StartsWith("rbit", Intrinsic::bitreverse)
|
||||
.Default(Intrinsic::not_intrinsic);
|
||||
if (ID != Intrinsic::not_intrinsic) {
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(), ID,
|
||||
F->arg_begin()->getType());
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(), ID,
|
||||
F->arg_begin()->getType());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -821,8 +822,8 @@ static bool upgradeArmOrAarch64IntrinsicFunction(bool IsArm, Function *F,
|
||||
return false; // Invalid IR.
|
||||
VectorType *Ty = dyn_cast<VectorType>(F->getReturnType());
|
||||
if (Ty && Ty->getElementType()->isFloatingPointTy()) {
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(),
|
||||
Intrinsic::aarch64_neon_faddp, Ty);
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(
|
||||
F->getParent(), Intrinsic::aarch64_neon_faddp, Ty);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -840,7 +841,7 @@ static bool upgradeArmOrAarch64IntrinsicFunction(bool IsArm, Function *F,
|
||||
.Case("mlalt", Intrinsic::aarch64_sve_bfmlalt_lane_v2)
|
||||
.Default(Intrinsic::not_intrinsic);
|
||||
if (ID != Intrinsic::not_intrinsic) {
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(), ID);
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(), ID);
|
||||
return true;
|
||||
}
|
||||
return false; // No other 'aarch64.sve.bf*.lane'.
|
||||
@ -861,8 +862,8 @@ static bool upgradeArmOrAarch64IntrinsicFunction(bool IsArm, Function *F,
|
||||
|
||||
auto Args = F->getFunctionType()->params();
|
||||
Type *Tys[] = {F->getReturnType(), Args[1]};
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(),
|
||||
Intrinsic::aarch64_sve_faddqv, Tys);
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(
|
||||
F->getParent(), Intrinsic::aarch64_sve_faddqv, Tys);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -880,8 +881,8 @@ static bool upgradeArmOrAarch64IntrinsicFunction(bool IsArm, Function *F,
|
||||
Intrinsic::aarch64_sve_ld3_sret,
|
||||
Intrinsic::aarch64_sve_ld4_sret,
|
||||
};
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(),
|
||||
LoadIDs[Name[0] - '2'], Ty);
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(),
|
||||
LoadIDs[Name[0] - '2'], Ty);
|
||||
return true;
|
||||
}
|
||||
return false; // No other 'aarch64.sve.ld*'.
|
||||
@ -892,8 +893,8 @@ static bool upgradeArmOrAarch64IntrinsicFunction(bool IsArm, Function *F,
|
||||
if (Name.starts_with("get")) {
|
||||
// 'aarch64.sve.tuple.get*'.
|
||||
Type *Tys[] = {F->getReturnType(), F->arg_begin()->getType()};
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(),
|
||||
Intrinsic::vector_extract, Tys);
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(
|
||||
F->getParent(), Intrinsic::vector_extract, Tys);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -901,8 +902,8 @@ static bool upgradeArmOrAarch64IntrinsicFunction(bool IsArm, Function *F,
|
||||
// 'aarch64.sve.tuple.set*'.
|
||||
auto Args = F->getFunctionType()->params();
|
||||
Type *Tys[] = {Args[0], Args[2], Args[1]};
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(),
|
||||
Intrinsic::vector_insert, Tys);
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(
|
||||
F->getParent(), Intrinsic::vector_insert, Tys);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -911,8 +912,8 @@ static bool upgradeArmOrAarch64IntrinsicFunction(bool IsArm, Function *F,
|
||||
// 'aarch64.sve.tuple.create*'.
|
||||
auto Args = F->getFunctionType()->params();
|
||||
Type *Tys[] = {F->getReturnType(), Args[1]};
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(),
|
||||
Intrinsic::vector_insert, Tys);
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(
|
||||
F->getParent(), Intrinsic::vector_insert, Tys);
|
||||
return true;
|
||||
}
|
||||
return false; // No other 'aarch64.sve.tuple.*'.
|
||||
@ -1026,8 +1027,8 @@ static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn,
|
||||
if (Name.consume_front("amdgcn.")) {
|
||||
if (Name == "alignbit") {
|
||||
// Target specific intrinsic became redundant
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::fshr,
|
||||
{F->getReturnType()});
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(
|
||||
F->getParent(), Intrinsic::fshr, {F->getReturnType()});
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1056,9 +1057,9 @@ static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn,
|
||||
|
||||
if (Name.starts_with("ldexp.")) {
|
||||
// Target specific intrinsic became redundant
|
||||
NewFn = Intrinsic::getDeclaration(
|
||||
F->getParent(), Intrinsic::ldexp,
|
||||
{F->getReturnType(), F->getArg(1)->getType()});
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(
|
||||
F->getParent(), Intrinsic::ldexp,
|
||||
{F->getReturnType(), F->getArg(1)->getType()});
|
||||
return true;
|
||||
}
|
||||
break; // No other 'amdgcn.*'
|
||||
@ -1074,15 +1075,16 @@ static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn,
|
||||
.Default(Intrinsic::not_intrinsic);
|
||||
if (ID != Intrinsic::not_intrinsic) {
|
||||
rename(F);
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(), ID,
|
||||
F->arg_begin()->getType());
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(), ID,
|
||||
F->arg_begin()->getType());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (F->arg_size() == 2 && Name == "coro.end") {
|
||||
rename(F);
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::coro_end);
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(),
|
||||
Intrinsic::coro_end);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1105,7 +1107,8 @@ static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn,
|
||||
// converted to DbgVariableRecords later.
|
||||
if (Name == "addr" || (Name == "value" && F->arg_size() == 4)) {
|
||||
rename(F);
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::dbg_value);
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(),
|
||||
Intrinsic::dbg_value);
|
||||
return true;
|
||||
}
|
||||
break; // No other 'dbg.*'.
|
||||
@ -1135,7 +1138,7 @@ static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn,
|
||||
// Inserting overloads the inserted type.
|
||||
Tys.push_back(FT->getParamType(1));
|
||||
rename(F);
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(), ID, Tys);
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(), ID, Tys);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1171,8 +1174,8 @@ static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn,
|
||||
if (ID != Intrinsic::not_intrinsic) {
|
||||
rename(F);
|
||||
auto Args = F->getFunctionType()->params();
|
||||
NewFn =
|
||||
Intrinsic::getDeclaration(F->getParent(), ID, {Args[V2 ? 1 : 0]});
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(), ID,
|
||||
{Args[V2 ? 1 : 0]});
|
||||
return true;
|
||||
}
|
||||
break; // No other 'expermental.vector.reduce.*'.
|
||||
@ -1182,15 +1185,16 @@ static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn,
|
||||
if (Name.consume_front("experimental.stepvector.")) {
|
||||
Intrinsic::ID ID = Intrinsic::stepvector;
|
||||
rename(F);
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(), ID,
|
||||
F->getFunctionType()->getReturnType());
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(
|
||||
F->getParent(), ID, F->getFunctionType()->getReturnType());
|
||||
return true;
|
||||
}
|
||||
break; // No other 'e*'.
|
||||
case 'f':
|
||||
if (Name.starts_with("flt.rounds")) {
|
||||
rename(F);
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::get_rounding);
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(),
|
||||
Intrinsic::get_rounding);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
@ -1200,8 +1204,8 @@ static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn,
|
||||
auto Args = F->getFunctionType()->params();
|
||||
Type* ObjectPtr[1] = {Args[0]};
|
||||
rename(F);
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(),
|
||||
Intrinsic::launder_invariant_group, ObjectPtr);
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(
|
||||
F->getParent(), Intrinsic::launder_invariant_group, ObjectPtr);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
@ -1218,7 +1222,8 @@ static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn,
|
||||
// Get the types of dest, src, and len
|
||||
ArrayRef<Type *> ParamTypes =
|
||||
F->getFunctionType()->params().slice(0, 3);
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(), ID, ParamTypes);
|
||||
NewFn =
|
||||
Intrinsic::getOrInsertDeclaration(F->getParent(), ID, ParamTypes);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1230,8 +1235,8 @@ static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn,
|
||||
FT->getParamType(0), // Dest
|
||||
FT->getParamType(2) // len
|
||||
};
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::memset,
|
||||
ParamTypes);
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(),
|
||||
Intrinsic::memset, ParamTypes);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
@ -1247,8 +1252,8 @@ static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn,
|
||||
.Case("popc.i", Intrinsic::ctpop)
|
||||
.Default(Intrinsic::not_intrinsic);
|
||||
if (IID != Intrinsic::not_intrinsic) {
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(), IID,
|
||||
{F->getReturnType()});
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(), IID,
|
||||
{F->getReturnType()});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1316,8 +1321,8 @@ static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn,
|
||||
F->getName() !=
|
||||
Intrinsic::getName(Intrinsic::objectsize, Tys, F->getParent())) {
|
||||
rename(F);
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::objectsize,
|
||||
Tys);
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(),
|
||||
Intrinsic::objectsize, Tys);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1326,7 +1331,7 @@ static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn,
|
||||
case 'p':
|
||||
if (Name.starts_with("ptr.annotation.") && F->arg_size() == 4) {
|
||||
rename(F);
|
||||
NewFn = Intrinsic::getDeclaration(
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(
|
||||
F->getParent(), Intrinsic::ptr_annotation,
|
||||
{F->arg_begin()->getType(), F->getArg(1)->getType()});
|
||||
return true;
|
||||
@ -1345,7 +1350,7 @@ static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn,
|
||||
if (ID != Intrinsic::not_intrinsic) {
|
||||
if (!F->getFunctionType()->getParamType(2)->isIntegerTy(32)) {
|
||||
rename(F);
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(), ID);
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(), ID);
|
||||
return true;
|
||||
}
|
||||
break; // No other applicable upgrades.
|
||||
@ -1359,7 +1364,7 @@ static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn,
|
||||
if (!F->getFunctionType()->getParamType(2)->isIntegerTy(32) ||
|
||||
F->getFunctionType()->getReturnType()->isIntegerTy(64)) {
|
||||
rename(F);
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(), ID);
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(), ID);
|
||||
return true;
|
||||
}
|
||||
break; // No other applicable upgrades.
|
||||
@ -1376,7 +1381,7 @@ static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn,
|
||||
if (ID != Intrinsic::not_intrinsic) {
|
||||
if (F->getFunctionType()->getReturnType()->isIntegerTy(64)) {
|
||||
rename(F);
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(), ID);
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(), ID);
|
||||
return true;
|
||||
}
|
||||
break; // No other applicable upgrades.
|
||||
@ -1395,7 +1400,7 @@ static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn,
|
||||
case 'v': {
|
||||
if (Name == "var.annotation" && F->arg_size() == 4) {
|
||||
rename(F);
|
||||
NewFn = Intrinsic::getDeclaration(
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(
|
||||
F->getParent(), Intrinsic::var_annotation,
|
||||
{{F->arg_begin()->getType(), F->getArg(1)->getType()}});
|
||||
return true;
|
||||
@ -1413,8 +1418,8 @@ static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn,
|
||||
.Default(Intrinsic::not_intrinsic);
|
||||
if (ID != Intrinsic::not_intrinsic) {
|
||||
rename(F);
|
||||
NewFn =
|
||||
Intrinsic::getDeclaration(F->getParent(), ID, F->getReturnType());
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(), ID,
|
||||
F->getReturnType());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1426,7 +1431,7 @@ static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn,
|
||||
.Default(Intrinsic::not_intrinsic);
|
||||
if (ID != Intrinsic::not_intrinsic) {
|
||||
rename(F);
|
||||
NewFn = Intrinsic::getDeclaration(F->getParent(), ID);
|
||||
NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(), ID);
|
||||
return true;
|
||||
}
|
||||
break; // No other 'wasm.dot.i8x16.i7x16.*'.
|
||||
@ -1740,8 +1745,8 @@ static Value *upgradeX86VPERMT2Intrinsics(IRBuilder<> &Builder, CallBase &CI,
|
||||
if (!IndexForm)
|
||||
std::swap(Args[0], Args[1]);
|
||||
|
||||
Value *V = Builder.CreateCall(Intrinsic::getDeclaration(CI.getModule(), IID),
|
||||
Args);
|
||||
Value *V = Builder.CreateCall(
|
||||
Intrinsic::getOrInsertDeclaration(CI.getModule(), IID), Args);
|
||||
Value *PassThru = ZeroMask ? ConstantAggregateZero::get(Ty)
|
||||
: Builder.CreateBitCast(CI.getArgOperand(1),
|
||||
Ty);
|
||||
@ -1753,7 +1758,7 @@ static Value *upgradeX86BinaryIntrinsics(IRBuilder<> &Builder, CallBase &CI,
|
||||
Type *Ty = CI.getType();
|
||||
Value *Op0 = CI.getOperand(0);
|
||||
Value *Op1 = CI.getOperand(1);
|
||||
Function *Intrin = Intrinsic::getDeclaration(CI.getModule(), IID, Ty);
|
||||
Function *Intrin = Intrinsic::getOrInsertDeclaration(CI.getModule(), IID, Ty);
|
||||
Value *Res = Builder.CreateCall(Intrin, {Op0, Op1});
|
||||
|
||||
if (CI.arg_size() == 4) { // For masked intrinsics.
|
||||
@ -1780,7 +1785,7 @@ static Value *upgradeX86Rotate(IRBuilder<> &Builder, CallBase &CI,
|
||||
}
|
||||
|
||||
Intrinsic::ID IID = IsRotateRight ? Intrinsic::fshr : Intrinsic::fshl;
|
||||
Function *Intrin = Intrinsic::getDeclaration(CI.getModule(), IID, Ty);
|
||||
Function *Intrin = Intrinsic::getOrInsertDeclaration(CI.getModule(), IID, Ty);
|
||||
Value *Res = Builder.CreateCall(Intrin, {Src, Src, Amt});
|
||||
|
||||
if (CI.arg_size() == 4) { // For masked intrinsics.
|
||||
@ -1850,7 +1855,7 @@ static Value *upgradeX86ConcatShift(IRBuilder<> &Builder, CallBase &CI,
|
||||
}
|
||||
|
||||
Intrinsic::ID IID = IsShiftRight ? Intrinsic::fshr : Intrinsic::fshl;
|
||||
Function *Intrin = Intrinsic::getDeclaration(CI.getModule(), IID, Ty);
|
||||
Function *Intrin = Intrinsic::getOrInsertDeclaration(CI.getModule(), IID, Ty);
|
||||
Value *Res = Builder.CreateCall(Intrin, {Op0, Op1, Amt});
|
||||
|
||||
unsigned NumArgs = CI.arg_size();
|
||||
@ -1911,7 +1916,8 @@ static Value *upgradeMaskedLoad(IRBuilder<> &Builder, Value *Ptr,
|
||||
static Value *upgradeAbs(IRBuilder<> &Builder, CallBase &CI) {
|
||||
Type *Ty = CI.getType();
|
||||
Value *Op0 = CI.getArgOperand(0);
|
||||
Function *F = Intrinsic::getDeclaration(CI.getModule(), Intrinsic::abs, Ty);
|
||||
Function *F =
|
||||
Intrinsic::getOrInsertDeclaration(CI.getModule(), Intrinsic::abs, Ty);
|
||||
Value *Res = Builder.CreateCall(F, {Op0, Builder.getInt1(false)});
|
||||
if (CI.arg_size() == 3)
|
||||
Res = emitX86Select(Builder, CI.getArgOperand(2), Res, CI.getArgOperand(1));
|
||||
@ -2004,7 +2010,7 @@ static Value *upgradeMaskedCompare(IRBuilder<> &Builder, CallBase &CI,
|
||||
// Replace a masked intrinsic with an older unmasked intrinsic.
|
||||
static Value *upgradeX86MaskedShift(IRBuilder<> &Builder, CallBase &CI,
|
||||
Intrinsic::ID IID) {
|
||||
Function *Intrin = Intrinsic::getDeclaration(CI.getModule(), IID);
|
||||
Function *Intrin = Intrinsic::getOrInsertDeclaration(CI.getModule(), IID);
|
||||
Value *Rep = Builder.CreateCall(Intrin,
|
||||
{ CI.getArgOperand(0), CI.getArgOperand(1) });
|
||||
return emitX86Select(Builder, CI.getArgOperand(3), Rep, CI.getArgOperand(2));
|
||||
@ -2263,8 +2269,8 @@ static bool upgradeAVX512MaskToSelect(StringRef Name, IRBuilder<> &Builder,
|
||||
SmallVector<Value *, 4> Args(CI.args());
|
||||
Args.pop_back();
|
||||
Args.pop_back();
|
||||
Rep = Builder.CreateCall(Intrinsic::getDeclaration(CI.getModule(), IID),
|
||||
Args);
|
||||
Rep = Builder.CreateCall(
|
||||
Intrinsic::getOrInsertDeclaration(CI.getModule(), IID), Args);
|
||||
unsigned NumArgs = CI.arg_size();
|
||||
Rep = emitX86Select(Builder, CI.getArgOperand(NumArgs - 1), Rep,
|
||||
CI.getArgOperand(NumArgs - 2));
|
||||
@ -2320,8 +2326,8 @@ static Value *upgradeNVVMIntrinsicCall(StringRef Name, CallBase *CI,
|
||||
// llvm.nvvm.clz.ll returns an i32, but llvm.ctlz.i64 returns an i64.
|
||||
Value *Arg = CI->getArgOperand(0);
|
||||
Value *Ctlz = Builder.CreateCall(
|
||||
Intrinsic::getDeclaration(F->getParent(), Intrinsic::ctlz,
|
||||
{Arg->getType()}),
|
||||
Intrinsic::getOrInsertDeclaration(F->getParent(), Intrinsic::ctlz,
|
||||
{Arg->getType()}),
|
||||
{Arg, Builder.getFalse()}, "ctlz");
|
||||
Rep = Builder.CreateTrunc(Ctlz, Builder.getInt32Ty(), "ctlz.trunc");
|
||||
} else if (Name == "popc.ll") {
|
||||
@ -2329,15 +2335,15 @@ static Value *upgradeNVVMIntrinsicCall(StringRef Name, CallBase *CI,
|
||||
// i64.
|
||||
Value *Arg = CI->getArgOperand(0);
|
||||
Value *Popc = Builder.CreateCall(
|
||||
Intrinsic::getDeclaration(F->getParent(), Intrinsic::ctpop,
|
||||
{Arg->getType()}),
|
||||
Intrinsic::getOrInsertDeclaration(F->getParent(), Intrinsic::ctpop,
|
||||
{Arg->getType()}),
|
||||
Arg, "ctpop");
|
||||
Rep = Builder.CreateTrunc(Popc, Builder.getInt32Ty(), "ctpop.trunc");
|
||||
} else if (Name == "h2f") {
|
||||
Rep = Builder.CreateCall(
|
||||
Intrinsic::getDeclaration(F->getParent(), Intrinsic::convert_from_fp16,
|
||||
{Builder.getFloatTy()}),
|
||||
CI->getArgOperand(0), "h2f");
|
||||
Rep = Builder.CreateCall(Intrinsic::getOrInsertDeclaration(
|
||||
F->getParent(), Intrinsic::convert_from_fp16,
|
||||
{Builder.getFloatTy()}),
|
||||
CI->getArgOperand(0), "h2f");
|
||||
} else if (Name.consume_front("bitcast.") &&
|
||||
(Name == "f2i" || Name == "i2f" || Name == "ll2d" ||
|
||||
Name == "d2ll")) {
|
||||
@ -2373,7 +2379,7 @@ static Value *upgradeNVVMIntrinsicCall(StringRef Name, CallBase *CI,
|
||||
if (IID != Intrinsic::not_intrinsic &&
|
||||
!F->getReturnType()->getScalarType()->isBFloatTy()) {
|
||||
rename(F);
|
||||
Function *NewFn = Intrinsic::getDeclaration(F->getParent(), IID);
|
||||
Function *NewFn = Intrinsic::getOrInsertDeclaration(F->getParent(), IID);
|
||||
SmallVector<Value *, 2> Args;
|
||||
for (size_t I = 0; I < NewFn->arg_size(); ++I) {
|
||||
Value *Arg = CI->getArgOperand(I);
|
||||
@ -2480,15 +2486,15 @@ static Value *upgradeX86IntrinsicCall(StringRef Name, CallBase *CI, Function *F,
|
||||
} else if (Name == "sse.sqrt.ss" || Name == "sse2.sqrt.sd") {
|
||||
Value *Vec = CI->getArgOperand(0);
|
||||
Value *Elt0 = Builder.CreateExtractElement(Vec, (uint64_t)0);
|
||||
Function *Intr = Intrinsic::getDeclaration(F->getParent(), Intrinsic::sqrt,
|
||||
Elt0->getType());
|
||||
Function *Intr = Intrinsic::getOrInsertDeclaration(
|
||||
F->getParent(), Intrinsic::sqrt, Elt0->getType());
|
||||
Elt0 = Builder.CreateCall(Intr, Elt0);
|
||||
Rep = Builder.CreateInsertElement(Vec, Elt0, (uint64_t)0);
|
||||
} else if (Name.starts_with("avx.sqrt.p") ||
|
||||
Name.starts_with("sse2.sqrt.p") ||
|
||||
Name.starts_with("sse.sqrt.p")) {
|
||||
Rep =
|
||||
Builder.CreateCall(Intrinsic::getDeclaration(
|
||||
Builder.CreateCall(Intrinsic::getOrInsertDeclaration(
|
||||
F->getParent(), Intrinsic::sqrt, CI->getType()),
|
||||
{CI->getArgOperand(0)});
|
||||
} else if (Name.starts_with("avx512.mask.sqrt.p")) {
|
||||
@ -2499,13 +2505,13 @@ static Value *upgradeX86IntrinsicCall(StringRef Name, CallBase *CI, Function *F,
|
||||
: Intrinsic::x86_avx512_sqrt_pd_512;
|
||||
|
||||
Value *Args[] = {CI->getArgOperand(0), CI->getArgOperand(3)};
|
||||
Rep = Builder.CreateCall(Intrinsic::getDeclaration(CI->getModule(), IID),
|
||||
Args);
|
||||
Rep = Builder.CreateCall(
|
||||
Intrinsic::getOrInsertDeclaration(CI->getModule(), IID), Args);
|
||||
} else {
|
||||
Rep = Builder.CreateCall(Intrinsic::getDeclaration(F->getParent(),
|
||||
Intrinsic::sqrt,
|
||||
CI->getType()),
|
||||
{CI->getArgOperand(0)});
|
||||
Rep = Builder.CreateCall(
|
||||
Intrinsic::getOrInsertDeclaration(F->getParent(), Intrinsic::sqrt,
|
||||
CI->getType()),
|
||||
{CI->getArgOperand(0)});
|
||||
}
|
||||
Rep =
|
||||
emitX86Select(Builder, CI->getArgOperand(2), Rep, CI->getArgOperand(1));
|
||||
@ -2629,8 +2635,9 @@ static Value *upgradeX86IntrinsicCall(StringRef Name, CallBase *CI, Function *F,
|
||||
break;
|
||||
}
|
||||
|
||||
Rep = Builder.CreateCall(Intrinsic::getDeclaration(F->getParent(), IID),
|
||||
{CI->getOperand(0), CI->getArgOperand(1)});
|
||||
Rep = Builder.CreateCall(
|
||||
Intrinsic::getOrInsertDeclaration(F->getParent(), IID),
|
||||
{CI->getOperand(0), CI->getArgOperand(1)});
|
||||
Rep = applyX86MaskOn1BitsVec(Builder, Rep, CI->getArgOperand(2));
|
||||
} else if (Name.starts_with("avx512.mask.fpclass.p")) {
|
||||
Type *OpTy = CI->getArgOperand(0)->getType();
|
||||
@ -2652,8 +2659,9 @@ static Value *upgradeX86IntrinsicCall(StringRef Name, CallBase *CI, Function *F,
|
||||
else
|
||||
llvm_unreachable("Unexpected intrinsic");
|
||||
|
||||
Rep = Builder.CreateCall(Intrinsic::getDeclaration(F->getParent(), IID),
|
||||
{CI->getOperand(0), CI->getArgOperand(1)});
|
||||
Rep = Builder.CreateCall(
|
||||
Intrinsic::getOrInsertDeclaration(F->getParent(), IID),
|
||||
{CI->getOperand(0), CI->getArgOperand(1)});
|
||||
Rep = applyX86MaskOn1BitsVec(Builder, Rep, CI->getArgOperand(2));
|
||||
} else if (Name.starts_with("avx512.cmp.p")) {
|
||||
SmallVector<Value *, 4> Args(CI->args());
|
||||
@ -2681,8 +2689,8 @@ static Value *upgradeX86IntrinsicCall(StringRef Name, CallBase *CI, Function *F,
|
||||
std::swap(Mask, Args.back());
|
||||
Args.push_back(Mask);
|
||||
|
||||
Rep = Builder.CreateCall(Intrinsic::getDeclaration(F->getParent(), IID),
|
||||
Args);
|
||||
Rep = Builder.CreateCall(
|
||||
Intrinsic::getOrInsertDeclaration(F->getParent(), IID), Args);
|
||||
} else if (Name.starts_with("avx512.mask.cmp.")) {
|
||||
// Integer compare intrinsics.
|
||||
unsigned Imm = cast<ConstantInt>(CI->getArgOperand(2))->getZExtValue();
|
||||
@ -2776,8 +2784,8 @@ static Value *upgradeX86IntrinsicCall(StringRef Name, CallBase *CI, Function *F,
|
||||
cast<ConstantInt>(CI->getArgOperand(3))->getZExtValue() != 4)) {
|
||||
Intrinsic::ID IID = IsUnsigned ? Intrinsic::x86_avx512_uitofp_round
|
||||
: Intrinsic::x86_avx512_sitofp_round;
|
||||
Function *F =
|
||||
Intrinsic::getDeclaration(CI->getModule(), IID, {DstTy, SrcTy});
|
||||
Function *F = Intrinsic::getOrInsertDeclaration(CI->getModule(), IID,
|
||||
{DstTy, SrcTy});
|
||||
Rep = Builder.CreateCall(F, {Rep, CI->getArgOperand(3)});
|
||||
} else {
|
||||
Rep = IsUnsigned ? Builder.CreateUIToFP(Rep, DstTy, "cvt")
|
||||
@ -2819,7 +2827,7 @@ static Value *upgradeX86IntrinsicCall(StringRef Name, CallBase *CI, Function *F,
|
||||
Value *MaskVec = getX86MaskVec(Builder, CI->getArgOperand(2),
|
||||
ResultTy->getNumElements());
|
||||
|
||||
Function *ELd = Intrinsic::getDeclaration(
|
||||
Function *ELd = Intrinsic::getOrInsertDeclaration(
|
||||
F->getParent(), Intrinsic::masked_expandload, ResultTy);
|
||||
Rep = Builder.CreateCall(ELd, {Ptr, MaskVec, CI->getOperand(1)});
|
||||
} else if (Name.starts_with("avx512.mask.compress.store.")) {
|
||||
@ -2834,7 +2842,7 @@ static Value *upgradeX86IntrinsicCall(StringRef Name, CallBase *CI, Function *F,
|
||||
getX86MaskVec(Builder, CI->getArgOperand(2),
|
||||
cast<FixedVectorType>(ResultTy)->getNumElements());
|
||||
|
||||
Function *CSt = Intrinsic::getDeclaration(
|
||||
Function *CSt = Intrinsic::getOrInsertDeclaration(
|
||||
F->getParent(), Intrinsic::masked_compressstore, ResultTy);
|
||||
Rep = Builder.CreateCall(CSt, {CI->getArgOperand(1), Ptr, MaskVec});
|
||||
} else if (Name.starts_with("avx512.mask.compress.") ||
|
||||
@ -2847,7 +2855,8 @@ static Value *upgradeX86IntrinsicCall(StringRef Name, CallBase *CI, Function *F,
|
||||
bool IsCompress = Name[12] == 'c';
|
||||
Intrinsic::ID IID = IsCompress ? Intrinsic::x86_avx512_mask_compress
|
||||
: Intrinsic::x86_avx512_mask_expand;
|
||||
Function *Intr = Intrinsic::getDeclaration(F->getParent(), IID, ResultTy);
|
||||
Function *Intr =
|
||||
Intrinsic::getOrInsertDeclaration(F->getParent(), IID, ResultTy);
|
||||
Rep = Builder.CreateCall(Intr,
|
||||
{CI->getOperand(0), CI->getOperand(1), MaskVec});
|
||||
} else if (Name.starts_with("xop.vpcom")) {
|
||||
@ -2910,7 +2919,7 @@ static Value *upgradeX86IntrinsicCall(StringRef Name, CallBase *CI, Function *F,
|
||||
bool ZeroMask = Name[11] == 'z';
|
||||
Rep = upgradeX86ConcatShift(Builder, *CI, true, ZeroMask);
|
||||
} else if (Name == "sse42.crc32.64.8") {
|
||||
Function *CRC32 = Intrinsic::getDeclaration(
|
||||
Function *CRC32 = Intrinsic::getOrInsertDeclaration(
|
||||
F->getParent(), Intrinsic::x86_sse42_crc32_32_8);
|
||||
Value *Trunc0 =
|
||||
Builder.CreateTrunc(CI->getArgOperand(0), Type::getInt32Ty(C));
|
||||
@ -3405,7 +3414,7 @@ static Value *upgradeX86IntrinsicCall(StringRef Name, CallBase *CI, Function *F,
|
||||
IID = Intrinsic::x86_avx512_add_pd_512;
|
||||
|
||||
Rep = Builder.CreateCall(
|
||||
Intrinsic::getDeclaration(F->getParent(), IID),
|
||||
Intrinsic::getOrInsertDeclaration(F->getParent(), IID),
|
||||
{CI->getArgOperand(0), CI->getArgOperand(1), CI->getArgOperand(4)});
|
||||
} else {
|
||||
Rep = Builder.CreateFAdd(CI->getArgOperand(0), CI->getArgOperand(1));
|
||||
@ -3421,7 +3430,7 @@ static Value *upgradeX86IntrinsicCall(StringRef Name, CallBase *CI, Function *F,
|
||||
IID = Intrinsic::x86_avx512_div_pd_512;
|
||||
|
||||
Rep = Builder.CreateCall(
|
||||
Intrinsic::getDeclaration(F->getParent(), IID),
|
||||
Intrinsic::getOrInsertDeclaration(F->getParent(), IID),
|
||||
{CI->getArgOperand(0), CI->getArgOperand(1), CI->getArgOperand(4)});
|
||||
} else {
|
||||
Rep = Builder.CreateFDiv(CI->getArgOperand(0), CI->getArgOperand(1));
|
||||
@ -3437,7 +3446,7 @@ static Value *upgradeX86IntrinsicCall(StringRef Name, CallBase *CI, Function *F,
|
||||
IID = Intrinsic::x86_avx512_mul_pd_512;
|
||||
|
||||
Rep = Builder.CreateCall(
|
||||
Intrinsic::getDeclaration(F->getParent(), IID),
|
||||
Intrinsic::getOrInsertDeclaration(F->getParent(), IID),
|
||||
{CI->getArgOperand(0), CI->getArgOperand(1), CI->getArgOperand(4)});
|
||||
} else {
|
||||
Rep = Builder.CreateFMul(CI->getArgOperand(0), CI->getArgOperand(1));
|
||||
@ -3453,7 +3462,7 @@ static Value *upgradeX86IntrinsicCall(StringRef Name, CallBase *CI, Function *F,
|
||||
IID = Intrinsic::x86_avx512_sub_pd_512;
|
||||
|
||||
Rep = Builder.CreateCall(
|
||||
Intrinsic::getDeclaration(F->getParent(), IID),
|
||||
Intrinsic::getOrInsertDeclaration(F->getParent(), IID),
|
||||
{CI->getArgOperand(0), CI->getArgOperand(1), CI->getArgOperand(4)});
|
||||
} else {
|
||||
Rep = Builder.CreateFSub(CI->getArgOperand(0), CI->getArgOperand(1));
|
||||
@ -3471,13 +3480,13 @@ static Value *upgradeX86IntrinsicCall(StringRef Name, CallBase *CI, Function *F,
|
||||
Intrinsic::ID IID = MinMaxTbl[IsMin][IsDouble];
|
||||
|
||||
Rep = Builder.CreateCall(
|
||||
Intrinsic::getDeclaration(F->getParent(), IID),
|
||||
Intrinsic::getOrInsertDeclaration(F->getParent(), IID),
|
||||
{CI->getArgOperand(0), CI->getArgOperand(1), CI->getArgOperand(4)});
|
||||
Rep =
|
||||
emitX86Select(Builder, CI->getArgOperand(3), Rep, CI->getArgOperand(2));
|
||||
} else if (Name.starts_with("avx512.mask.lzcnt.")) {
|
||||
Rep =
|
||||
Builder.CreateCall(Intrinsic::getDeclaration(
|
||||
Builder.CreateCall(Intrinsic::getOrInsertDeclaration(
|
||||
F->getParent(), Intrinsic::ctlz, CI->getType()),
|
||||
{CI->getArgOperand(0), Builder.getInt1(false)});
|
||||
Rep =
|
||||
@ -3723,10 +3732,10 @@ static Value *upgradeX86IntrinsicCall(StringRef Name, CallBase *CI, Function *F,
|
||||
if (NegAcc)
|
||||
Ops[2] = Builder.CreateFNeg(Ops[2]);
|
||||
|
||||
Rep = Builder.CreateCall(Intrinsic::getDeclaration(CI->getModule(),
|
||||
Intrinsic::fma,
|
||||
Ops[0]->getType()),
|
||||
Ops);
|
||||
Rep = Builder.CreateCall(
|
||||
Intrinsic::getOrInsertDeclaration(CI->getModule(), Intrinsic::fma,
|
||||
Ops[0]->getType()),
|
||||
Ops);
|
||||
|
||||
if (IsScalar)
|
||||
Rep = Builder.CreateInsertElement(CI->getArgOperand(0), Rep, (uint64_t)0);
|
||||
@ -3738,10 +3747,10 @@ static Value *upgradeX86IntrinsicCall(StringRef Name, CallBase *CI, Function *F,
|
||||
Ops[1] = Builder.CreateExtractElement(Ops[1], (uint64_t)0);
|
||||
Ops[2] = Builder.CreateExtractElement(Ops[2], (uint64_t)0);
|
||||
|
||||
Rep = Builder.CreateCall(Intrinsic::getDeclaration(CI->getModule(),
|
||||
Intrinsic::fma,
|
||||
Ops[0]->getType()),
|
||||
Ops);
|
||||
Rep = Builder.CreateCall(
|
||||
Intrinsic::getOrInsertDeclaration(CI->getModule(), Intrinsic::fma,
|
||||
Ops[0]->getType()),
|
||||
Ops);
|
||||
|
||||
Rep = Builder.CreateInsertElement(Constant::getNullValue(CI->getType()),
|
||||
Rep, (uint64_t)0);
|
||||
@ -3781,11 +3790,11 @@ static Value *upgradeX86IntrinsicCall(StringRef Name, CallBase *CI, Function *F,
|
||||
IID = Intrinsic::x86_avx512_vfmadd_f64;
|
||||
else
|
||||
IID = Intrinsic::x86_avx512_vfmadd_f32;
|
||||
Function *FMA = Intrinsic::getDeclaration(CI->getModule(), IID);
|
||||
Function *FMA = Intrinsic::getOrInsertDeclaration(CI->getModule(), IID);
|
||||
Rep = Builder.CreateCall(FMA, Ops);
|
||||
} else {
|
||||
Function *FMA = Intrinsic::getDeclaration(CI->getModule(), Intrinsic::fma,
|
||||
A->getType());
|
||||
Function *FMA = Intrinsic::getOrInsertDeclaration(
|
||||
CI->getModule(), Intrinsic::fma, A->getType());
|
||||
Rep = Builder.CreateCall(FMA, {A, B, C});
|
||||
}
|
||||
|
||||
@ -3837,11 +3846,12 @@ static Value *upgradeX86IntrinsicCall(StringRef Name, CallBase *CI, Function *F,
|
||||
else
|
||||
IID = Intrinsic::x86_avx512_vfmadd_pd_512;
|
||||
|
||||
Rep = Builder.CreateCall(Intrinsic::getDeclaration(F->getParent(), IID),
|
||||
{A, B, C, CI->getArgOperand(4)});
|
||||
Rep = Builder.CreateCall(
|
||||
Intrinsic::getOrInsertDeclaration(F->getParent(), IID),
|
||||
{A, B, C, CI->getArgOperand(4)});
|
||||
} else {
|
||||
Function *FMA = Intrinsic::getDeclaration(CI->getModule(), Intrinsic::fma,
|
||||
A->getType());
|
||||
Function *FMA = Intrinsic::getOrInsertDeclaration(
|
||||
CI->getModule(), Intrinsic::fma, A->getType());
|
||||
Rep = Builder.CreateCall(FMA, {A, B, C});
|
||||
}
|
||||
|
||||
@ -3868,8 +3878,8 @@ static Value *upgradeX86IntrinsicCall(StringRef Name, CallBase *CI, Function *F,
|
||||
Value *Ops[] = {CI->getArgOperand(0), CI->getArgOperand(1),
|
||||
CI->getArgOperand(2)};
|
||||
Ops[2] = Builder.CreateFNeg(Ops[2]);
|
||||
Rep =
|
||||
Builder.CreateCall(Intrinsic::getDeclaration(F->getParent(), IID), Ops);
|
||||
Rep = Builder.CreateCall(
|
||||
Intrinsic::getOrInsertDeclaration(F->getParent(), IID), Ops);
|
||||
} else if (Name.starts_with("avx512.mask.vfmaddsub.p") ||
|
||||
Name.starts_with("avx512.mask3.vfmaddsub.p") ||
|
||||
Name.starts_with("avx512.maskz.vfmaddsub.p") ||
|
||||
@ -3892,16 +3902,16 @@ static Value *upgradeX86IntrinsicCall(StringRef Name, CallBase *CI, Function *F,
|
||||
if (IsSubAdd)
|
||||
Ops[2] = Builder.CreateFNeg(Ops[2]);
|
||||
|
||||
Rep = Builder.CreateCall(Intrinsic::getDeclaration(F->getParent(), IID),
|
||||
Ops);
|
||||
Rep = Builder.CreateCall(
|
||||
Intrinsic::getOrInsertDeclaration(F->getParent(), IID), Ops);
|
||||
} else {
|
||||
int NumElts = cast<FixedVectorType>(CI->getType())->getNumElements();
|
||||
|
||||
Value *Ops[] = {CI->getArgOperand(0), CI->getArgOperand(1),
|
||||
CI->getArgOperand(2)};
|
||||
|
||||
Function *FMA = Intrinsic::getDeclaration(CI->getModule(), Intrinsic::fma,
|
||||
Ops[0]->getType());
|
||||
Function *FMA = Intrinsic::getOrInsertDeclaration(
|
||||
CI->getModule(), Intrinsic::fma, Ops[0]->getType());
|
||||
Value *Odd = Builder.CreateCall(FMA, Ops);
|
||||
Ops[2] = Builder.CreateFNeg(Ops[2]);
|
||||
Value *Even = Builder.CreateCall(FMA, Ops);
|
||||
@ -3944,8 +3954,8 @@ static Value *upgradeX86IntrinsicCall(StringRef Name, CallBase *CI, Function *F,
|
||||
|
||||
Value *Args[] = {CI->getArgOperand(0), CI->getArgOperand(1),
|
||||
CI->getArgOperand(2), CI->getArgOperand(3)};
|
||||
Rep = Builder.CreateCall(Intrinsic::getDeclaration(CI->getModule(), IID),
|
||||
Args);
|
||||
Rep = Builder.CreateCall(
|
||||
Intrinsic::getOrInsertDeclaration(CI->getModule(), IID), Args);
|
||||
Value *PassThru = ZeroMask ? ConstantAggregateZero::get(CI->getType())
|
||||
: CI->getArgOperand(0);
|
||||
Rep = emitX86Select(Builder, CI->getArgOperand(4), Rep, PassThru);
|
||||
@ -3972,8 +3982,8 @@ static Value *upgradeX86IntrinsicCall(StringRef Name, CallBase *CI, Function *F,
|
||||
|
||||
Value *Args[] = {CI->getArgOperand(0), CI->getArgOperand(1),
|
||||
CI->getArgOperand(2)};
|
||||
Rep = Builder.CreateCall(Intrinsic::getDeclaration(CI->getModule(), IID),
|
||||
Args);
|
||||
Rep = Builder.CreateCall(
|
||||
Intrinsic::getOrInsertDeclaration(CI->getModule(), IID), Args);
|
||||
Value *PassThru = ZeroMask ? ConstantAggregateZero::get(CI->getType())
|
||||
: CI->getArgOperand(0);
|
||||
Rep = emitX86Select(Builder, CI->getArgOperand(3), Rep, PassThru);
|
||||
@ -4008,8 +4018,8 @@ static Value *upgradeX86IntrinsicCall(StringRef Name, CallBase *CI, Function *F,
|
||||
|
||||
Value *Args[] = {CI->getArgOperand(0), CI->getArgOperand(1),
|
||||
CI->getArgOperand(2)};
|
||||
Rep = Builder.CreateCall(Intrinsic::getDeclaration(CI->getModule(), IID),
|
||||
Args);
|
||||
Rep = Builder.CreateCall(
|
||||
Intrinsic::getOrInsertDeclaration(CI->getModule(), IID), Args);
|
||||
Value *PassThru = ZeroMask ? ConstantAggregateZero::get(CI->getType())
|
||||
: CI->getArgOperand(0);
|
||||
Rep = emitX86Select(Builder, CI->getArgOperand(3), Rep, PassThru);
|
||||
@ -4038,8 +4048,8 @@ static Value *upgradeX86IntrinsicCall(StringRef Name, CallBase *CI, Function *F,
|
||||
|
||||
Value *Args[] = {CI->getArgOperand(0), CI->getArgOperand(1),
|
||||
CI->getArgOperand(2)};
|
||||
Rep = Builder.CreateCall(Intrinsic::getDeclaration(CI->getModule(), IID),
|
||||
Args);
|
||||
Rep = Builder.CreateCall(
|
||||
Intrinsic::getOrInsertDeclaration(CI->getModule(), IID), Args);
|
||||
Value *PassThru = ZeroMask ? ConstantAggregateZero::get(CI->getType())
|
||||
: CI->getArgOperand(0);
|
||||
Rep = emitX86Select(Builder, CI->getArgOperand(3), Rep, PassThru);
|
||||
@ -4062,7 +4072,7 @@ static Value *upgradeX86IntrinsicCall(StringRef Name, CallBase *CI, Function *F,
|
||||
Value *Args[] = {CI->getArgOperand(0), CI->getArgOperand(1),
|
||||
CI->getArgOperand(2)};
|
||||
Value *NewCall = Builder.CreateCall(
|
||||
Intrinsic::getDeclaration(CI->getModule(), IID), Args);
|
||||
Intrinsic::getOrInsertDeclaration(CI->getModule(), IID), Args);
|
||||
|
||||
// Extract the second result and store it.
|
||||
Value *Data = Builder.CreateExtractValue(NewCall, 1);
|
||||
@ -4108,7 +4118,7 @@ static Value *upgradeAArch64IntrinsicCall(StringRef Name, CallBase *CI,
|
||||
Args[1] = Builder.CreateIntrinsic(Intrinsic::aarch64_sve_convert_from_svbool,
|
||||
GoodPredTy, Args[1]);
|
||||
|
||||
Function *NewF = Intrinsic::getDeclaration(CI->getModule(), NewID);
|
||||
Function *NewF = Intrinsic::getOrInsertDeclaration(CI->getModule(), NewID);
|
||||
return Builder.CreateCall(NewF, Args, CI->getName());
|
||||
}
|
||||
|
||||
@ -4117,16 +4127,17 @@ static Value *upgradeARMIntrinsicCall(StringRef Name, CallBase *CI, Function *F,
|
||||
if (Name == "mve.vctp64.old") {
|
||||
// Replace the old v4i1 vctp64 with a v2i1 vctp and predicate-casts to the
|
||||
// correct type.
|
||||
Value *VCTP = Builder.CreateCall(
|
||||
Intrinsic::getDeclaration(F->getParent(), Intrinsic::arm_mve_vctp64),
|
||||
CI->getArgOperand(0), CI->getName());
|
||||
Value *VCTP =
|
||||
Builder.CreateCall(Intrinsic::getOrInsertDeclaration(
|
||||
F->getParent(), Intrinsic::arm_mve_vctp64),
|
||||
CI->getArgOperand(0), CI->getName());
|
||||
Value *C1 = Builder.CreateCall(
|
||||
Intrinsic::getDeclaration(
|
||||
Intrinsic::getOrInsertDeclaration(
|
||||
F->getParent(), Intrinsic::arm_mve_pred_v2i,
|
||||
{VectorType::get(Builder.getInt1Ty(), 2, false)}),
|
||||
VCTP);
|
||||
return Builder.CreateCall(
|
||||
Intrinsic::getDeclaration(
|
||||
Intrinsic::getOrInsertDeclaration(
|
||||
F->getParent(), Intrinsic::arm_mve_pred_i2v,
|
||||
{VectorType::get(Builder.getInt1Ty(), 4, false)}),
|
||||
C1);
|
||||
@ -4188,19 +4199,19 @@ static Value *upgradeARMIntrinsicCall(StringRef Name, CallBase *CI, Function *F,
|
||||
Type *Ty = Op->getType();
|
||||
if (Ty->getScalarSizeInBits() == 1) {
|
||||
Value *C1 = Builder.CreateCall(
|
||||
Intrinsic::getDeclaration(
|
||||
Intrinsic::getOrInsertDeclaration(
|
||||
F->getParent(), Intrinsic::arm_mve_pred_v2i,
|
||||
{VectorType::get(Builder.getInt1Ty(), 4, false)}),
|
||||
Op);
|
||||
Op = Builder.CreateCall(
|
||||
Intrinsic::getDeclaration(F->getParent(),
|
||||
Intrinsic::arm_mve_pred_i2v, {V2I1Ty}),
|
||||
Intrinsic::getOrInsertDeclaration(
|
||||
F->getParent(), Intrinsic::arm_mve_pred_i2v, {V2I1Ty}),
|
||||
C1);
|
||||
}
|
||||
Ops.push_back(Op);
|
||||
}
|
||||
|
||||
Function *Fn = Intrinsic::getDeclaration(F->getParent(), ID, Tys);
|
||||
Function *Fn = Intrinsic::getOrInsertDeclaration(F->getParent(), ID, Tys);
|
||||
return Builder.CreateCall(Fn, Ops, CI->getName());
|
||||
}
|
||||
llvm_unreachable("Unknown function for ARM CallBase upgrade.");
|
||||
@ -5088,7 +5099,8 @@ void llvm::UpgradeARCRuntime(Module &M) {
|
||||
if (!Fn)
|
||||
return;
|
||||
|
||||
Function *NewFn = llvm::Intrinsic::getDeclaration(&M, IntrinsicFunc);
|
||||
Function *NewFn =
|
||||
llvm::Intrinsic::getOrInsertDeclaration(&M, IntrinsicFunc);
|
||||
|
||||
for (User *U : make_early_inc_range(Fn->users())) {
|
||||
CallInst *CI = dyn_cast<CallInst>(U);
|
||||
|
@ -2468,7 +2468,7 @@ LLVMValueRef LLVMGetIntrinsicDeclaration(LLVMModuleRef Mod,
|
||||
size_t ParamCount) {
|
||||
ArrayRef<Type*> Tys(unwrap(ParamTypes), ParamCount);
|
||||
auto IID = llvm_map_to_intrinsic_id(ID);
|
||||
return wrap(llvm::Intrinsic::getDeclaration(unwrap(Mod), IID, Tys));
|
||||
return wrap(llvm::Intrinsic::getOrInsertDeclaration(unwrap(Mod), IID, Tys));
|
||||
}
|
||||
|
||||
const char *LLVMIntrinsicGetName(unsigned ID, size_t *NameLength) {
|
||||
|
@ -991,7 +991,7 @@ DbgInstPtr DIBuilder::insertDbgAssign(Instruction *LinkedInstr, Value *Val,
|
||||
LLVMContext &Ctx = LinkedInstr->getContext();
|
||||
Module *M = LinkedInstr->getModule();
|
||||
if (!AssignFn)
|
||||
AssignFn = Intrinsic::getDeclaration(M, Intrinsic::dbg_assign);
|
||||
AssignFn = Intrinsic::getOrInsertDeclaration(M, Intrinsic::dbg_assign);
|
||||
|
||||
std::array<Value *, 6> Args = {
|
||||
MetadataAsValue::get(Ctx, ValueAsMetadata::get(Val)),
|
||||
@ -1060,7 +1060,7 @@ static Value *getDbgIntrinsicValueImpl(LLVMContext &VMContext, Value *V) {
|
||||
}
|
||||
|
||||
static Function *getDeclareIntrin(Module &M) {
|
||||
return Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
|
||||
return Intrinsic::getOrInsertDeclaration(&M, Intrinsic::dbg_declare);
|
||||
}
|
||||
|
||||
DbgInstPtr DIBuilder::insertDbgValueIntrinsic(
|
||||
@ -1074,7 +1074,7 @@ DbgInstPtr DIBuilder::insertDbgValueIntrinsic(
|
||||
}
|
||||
|
||||
if (!ValueFn)
|
||||
ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
|
||||
ValueFn = Intrinsic::getOrInsertDeclaration(&M, Intrinsic::dbg_value);
|
||||
return insertDbgIntrinsic(ValueFn, Val, VarInfo, Expr, DL, InsertBB,
|
||||
InsertBefore);
|
||||
}
|
||||
@ -1175,7 +1175,7 @@ DbgInstPtr DIBuilder::insertLabel(DILabel *LabelInfo, const DILocation *DL,
|
||||
}
|
||||
|
||||
if (!LabelFn)
|
||||
LabelFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_label);
|
||||
LabelFn = Intrinsic::getOrInsertDeclaration(&M, Intrinsic::dbg_label);
|
||||
|
||||
Value *Args[] = {MetadataAsValue::get(VMContext, LabelInfo)};
|
||||
|
||||
|
@ -413,13 +413,13 @@ DbgVariableRecord::createDebugIntrinsic(Module *M,
|
||||
// Work out what sort of intrinsic we're going to produce.
|
||||
switch (getType()) {
|
||||
case DbgVariableRecord::LocationType::Declare:
|
||||
IntrinsicFn = Intrinsic::getDeclaration(M, Intrinsic::dbg_declare);
|
||||
IntrinsicFn = Intrinsic::getOrInsertDeclaration(M, Intrinsic::dbg_declare);
|
||||
break;
|
||||
case DbgVariableRecord::LocationType::Value:
|
||||
IntrinsicFn = Intrinsic::getDeclaration(M, Intrinsic::dbg_value);
|
||||
IntrinsicFn = Intrinsic::getOrInsertDeclaration(M, Intrinsic::dbg_value);
|
||||
break;
|
||||
case DbgVariableRecord::LocationType::Assign:
|
||||
IntrinsicFn = Intrinsic::getDeclaration(M, Intrinsic::dbg_assign);
|
||||
IntrinsicFn = Intrinsic::getOrInsertDeclaration(M, Intrinsic::dbg_assign);
|
||||
break;
|
||||
case DbgVariableRecord::LocationType::End:
|
||||
case DbgVariableRecord::LocationType::Any:
|
||||
@ -459,7 +459,7 @@ DbgVariableRecord::createDebugIntrinsic(Module *M,
|
||||
DbgLabelInst *
|
||||
DbgLabelRecord::createDebugIntrinsic(Module *M,
|
||||
Instruction *InsertBefore) const {
|
||||
auto *LabelFn = Intrinsic::getDeclaration(M, Intrinsic::dbg_label);
|
||||
auto *LabelFn = Intrinsic::getOrInsertDeclaration(M, Intrinsic::dbg_label);
|
||||
Value *Args[] = {
|
||||
MetadataAsValue::get(getDebugLoc()->getContext(), getLabel())};
|
||||
DbgLabelInst *DbgLabel = cast<DbgLabelInst>(
|
||||
|
@ -91,8 +91,8 @@ Value *IRBuilderBase::CreateVScale(Constant *Scaling, const Twine &Name) {
|
||||
if (cast<ConstantInt>(Scaling)->isZero())
|
||||
return Scaling;
|
||||
Module *M = GetInsertBlock()->getParent()->getParent();
|
||||
Function *TheFn =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::vscale, {Scaling->getType()});
|
||||
Function *TheFn = Intrinsic::getOrInsertDeclaration(M, Intrinsic::vscale,
|
||||
{Scaling->getType()});
|
||||
CallInst *CI = CreateCall(TheFn, {}, {}, Name);
|
||||
return cast<ConstantInt>(Scaling)->isOne() ? CI : CreateMul(CI, Scaling);
|
||||
}
|
||||
@ -142,7 +142,8 @@ CallInst *IRBuilderBase::CreateMemSet(Value *Ptr, Value *Val, Value *Size,
|
||||
Value *Ops[] = {Ptr, Val, Size, getInt1(isVolatile)};
|
||||
Type *Tys[] = { Ptr->getType(), Size->getType() };
|
||||
Module *M = BB->getParent()->getParent();
|
||||
Function *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys);
|
||||
Function *TheFn =
|
||||
Intrinsic::getOrInsertDeclaration(M, Intrinsic::memset, Tys);
|
||||
|
||||
CallInst *CI = CreateCall(TheFn, Ops);
|
||||
|
||||
@ -170,7 +171,8 @@ CallInst *IRBuilderBase::CreateMemSetInline(Value *Dst, MaybeAlign DstAlign,
|
||||
Value *Ops[] = {Dst, Val, Size, getInt1(IsVolatile)};
|
||||
Type *Tys[] = {Dst->getType(), Size->getType()};
|
||||
Module *M = BB->getParent()->getParent();
|
||||
Function *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memset_inline, Tys);
|
||||
Function *TheFn =
|
||||
Intrinsic::getOrInsertDeclaration(M, Intrinsic::memset_inline, Tys);
|
||||
|
||||
CallInst *CI = CreateCall(TheFn, Ops);
|
||||
|
||||
@ -197,7 +199,7 @@ CallInst *IRBuilderBase::CreateElementUnorderedAtomicMemSet(
|
||||
Value *Ops[] = {Ptr, Val, Size, getInt32(ElementSize)};
|
||||
Type *Tys[] = {Ptr->getType(), Size->getType()};
|
||||
Module *M = BB->getParent()->getParent();
|
||||
Function *TheFn = Intrinsic::getDeclaration(
|
||||
Function *TheFn = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::memset_element_unordered_atomic, Tys);
|
||||
|
||||
CallInst *CI = CreateCall(TheFn, Ops);
|
||||
@ -227,7 +229,7 @@ CallInst *IRBuilderBase::CreateMemTransferInst(
|
||||
Value *Ops[] = {Dst, Src, Size, getInt1(isVolatile)};
|
||||
Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() };
|
||||
Module *M = BB->getParent()->getParent();
|
||||
Function *TheFn = Intrinsic::getDeclaration(M, IntrID, Tys);
|
||||
Function *TheFn = Intrinsic::getOrInsertDeclaration(M, IntrID, Tys);
|
||||
|
||||
CallInst *CI = CreateCall(TheFn, Ops);
|
||||
|
||||
@ -265,7 +267,7 @@ CallInst *IRBuilderBase::CreateElementUnorderedAtomicMemCpy(
|
||||
Value *Ops[] = {Dst, Src, Size, getInt32(ElementSize)};
|
||||
Type *Tys[] = {Dst->getType(), Src->getType(), Size->getType()};
|
||||
Module *M = BB->getParent()->getParent();
|
||||
Function *TheFn = Intrinsic::getDeclaration(
|
||||
Function *TheFn = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::memcpy_element_unordered_atomic, Tys);
|
||||
|
||||
CallInst *CI = CreateCall(TheFn, Ops);
|
||||
@ -381,7 +383,7 @@ CallInst *IRBuilderBase::CreateElementUnorderedAtomicMemMove(
|
||||
Value *Ops[] = {Dst, Src, Size, getInt32(ElementSize)};
|
||||
Type *Tys[] = {Dst->getType(), Src->getType(), Size->getType()};
|
||||
Module *M = BB->getParent()->getParent();
|
||||
Function *TheFn = Intrinsic::getDeclaration(
|
||||
Function *TheFn = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::memmove_element_unordered_atomic, Tys);
|
||||
|
||||
CallInst *CI = CreateCall(TheFn, Ops);
|
||||
@ -411,23 +413,23 @@ CallInst *IRBuilderBase::getReductionIntrinsic(Intrinsic::ID ID, Value *Src) {
|
||||
Module *M = GetInsertBlock()->getParent()->getParent();
|
||||
Value *Ops[] = {Src};
|
||||
Type *Tys[] = { Src->getType() };
|
||||
auto Decl = Intrinsic::getDeclaration(M, ID, Tys);
|
||||
auto Decl = Intrinsic::getOrInsertDeclaration(M, ID, Tys);
|
||||
return CreateCall(Decl, Ops);
|
||||
}
|
||||
|
||||
CallInst *IRBuilderBase::CreateFAddReduce(Value *Acc, Value *Src) {
|
||||
Module *M = GetInsertBlock()->getParent()->getParent();
|
||||
Value *Ops[] = {Acc, Src};
|
||||
auto Decl = Intrinsic::getDeclaration(M, Intrinsic::vector_reduce_fadd,
|
||||
{Src->getType()});
|
||||
auto Decl = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::vector_reduce_fadd, {Src->getType()});
|
||||
return CreateCall(Decl, Ops);
|
||||
}
|
||||
|
||||
CallInst *IRBuilderBase::CreateFMulReduce(Value *Acc, Value *Src) {
|
||||
Module *M = GetInsertBlock()->getParent()->getParent();
|
||||
Value *Ops[] = {Acc, Src};
|
||||
auto Decl = Intrinsic::getDeclaration(M, Intrinsic::vector_reduce_fmul,
|
||||
{Src->getType()});
|
||||
auto Decl = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::vector_reduce_fmul, {Src->getType()});
|
||||
return CreateCall(Decl, Ops);
|
||||
}
|
||||
|
||||
@ -489,8 +491,8 @@ CallInst *IRBuilderBase::CreateLifetimeStart(Value *Ptr, ConstantInt *Size) {
|
||||
"lifetime.start requires the size to be an i64");
|
||||
Value *Ops[] = { Size, Ptr };
|
||||
Module *M = BB->getParent()->getParent();
|
||||
Function *TheFn =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::lifetime_start, {Ptr->getType()});
|
||||
Function *TheFn = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::lifetime_start, {Ptr->getType()});
|
||||
return CreateCall(TheFn, Ops);
|
||||
}
|
||||
|
||||
@ -504,8 +506,8 @@ CallInst *IRBuilderBase::CreateLifetimeEnd(Value *Ptr, ConstantInt *Size) {
|
||||
"lifetime.end requires the size to be an i64");
|
||||
Value *Ops[] = { Size, Ptr };
|
||||
Module *M = BB->getParent()->getParent();
|
||||
Function *TheFn =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::lifetime_end, {Ptr->getType()});
|
||||
Function *TheFn = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::lifetime_end, {Ptr->getType()});
|
||||
return CreateCall(TheFn, Ops);
|
||||
}
|
||||
|
||||
@ -523,8 +525,8 @@ CallInst *IRBuilderBase::CreateInvariantStart(Value *Ptr, ConstantInt *Size) {
|
||||
// Fill in the single overloaded type: memory object type.
|
||||
Type *ObjectPtr[1] = {Ptr->getType()};
|
||||
Module *M = BB->getParent()->getParent();
|
||||
Function *TheFn =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::invariant_start, ObjectPtr);
|
||||
Function *TheFn = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::invariant_start, ObjectPtr);
|
||||
return CreateCall(TheFn, Ops);
|
||||
}
|
||||
|
||||
@ -556,13 +558,13 @@ IRBuilderBase::CreateAssumption(Value *Cond,
|
||||
|
||||
Value *Ops[] = { Cond };
|
||||
Module *M = BB->getParent()->getParent();
|
||||
Function *FnAssume = Intrinsic::getDeclaration(M, Intrinsic::assume);
|
||||
Function *FnAssume = Intrinsic::getOrInsertDeclaration(M, Intrinsic::assume);
|
||||
return CreateCall(FnAssume, Ops, OpBundles);
|
||||
}
|
||||
|
||||
Instruction *IRBuilderBase::CreateNoAliasScopeDeclaration(Value *Scope) {
|
||||
Module *M = BB->getModule();
|
||||
auto *FnIntrinsic = Intrinsic::getDeclaration(
|
||||
auto *FnIntrinsic = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::experimental_noalias_scope_decl, {});
|
||||
return CreateCall(FnIntrinsic, {Scope});
|
||||
}
|
||||
@ -615,7 +617,7 @@ CallInst *IRBuilderBase::CreateMaskedIntrinsic(Intrinsic::ID Id,
|
||||
ArrayRef<Type *> OverloadedTypes,
|
||||
const Twine &Name) {
|
||||
Module *M = BB->getParent()->getParent();
|
||||
Function *TheFn = Intrinsic::getDeclaration(M, Id, OverloadedTypes);
|
||||
Function *TheFn = Intrinsic::getOrInsertDeclaration(M, Id, OverloadedTypes);
|
||||
return CreateCall(TheFn, Ops, {}, Name);
|
||||
}
|
||||
|
||||
@ -765,9 +767,9 @@ static CallInst *CreateGCStatepointCallCommon(
|
||||
const Twine &Name) {
|
||||
Module *M = Builder->GetInsertBlock()->getParent()->getParent();
|
||||
// Fill in the one generic type'd argument (the function is also vararg)
|
||||
Function *FnStatepoint =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::experimental_gc_statepoint,
|
||||
{ActualCallee.getCallee()->getType()});
|
||||
Function *FnStatepoint = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::experimental_gc_statepoint,
|
||||
{ActualCallee.getCallee()->getType()});
|
||||
|
||||
std::vector<Value *> Args = getStatepointArgs(
|
||||
*Builder, ID, NumPatchBytes, ActualCallee.getCallee(), Flags, CallArgs);
|
||||
@ -820,9 +822,9 @@ static InvokeInst *CreateGCStatepointInvokeCommon(
|
||||
const Twine &Name) {
|
||||
Module *M = Builder->GetInsertBlock()->getParent()->getParent();
|
||||
// Fill in the one generic type'd argument (the function is also vararg)
|
||||
Function *FnStatepoint =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::experimental_gc_statepoint,
|
||||
{ActualInvokee.getCallee()->getType()});
|
||||
Function *FnStatepoint = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::experimental_gc_statepoint,
|
||||
{ActualInvokee.getCallee()->getType()});
|
||||
|
||||
std::vector<Value *> Args =
|
||||
getStatepointArgs(*Builder, ID, NumPatchBytes, ActualInvokee.getCallee(),
|
||||
@ -875,7 +877,7 @@ CallInst *IRBuilderBase::CreateGCResult(Instruction *Statepoint,
|
||||
Intrinsic::ID ID = Intrinsic::experimental_gc_result;
|
||||
Module *M = BB->getParent()->getParent();
|
||||
Type *Types[] = {ResultType};
|
||||
Function *FnGCResult = Intrinsic::getDeclaration(M, ID, Types);
|
||||
Function *FnGCResult = Intrinsic::getOrInsertDeclaration(M, ID, Types);
|
||||
|
||||
Value *Args[] = {Statepoint};
|
||||
return CreateCall(FnGCResult, Args, {}, Name);
|
||||
@ -886,8 +888,8 @@ CallInst *IRBuilderBase::CreateGCRelocate(Instruction *Statepoint,
|
||||
Type *ResultType, const Twine &Name) {
|
||||
Module *M = BB->getParent()->getParent();
|
||||
Type *Types[] = {ResultType};
|
||||
Function *FnGCRelocate =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::experimental_gc_relocate, Types);
|
||||
Function *FnGCRelocate = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::experimental_gc_relocate, Types);
|
||||
|
||||
Value *Args[] = {Statepoint, getInt32(BaseOffset), getInt32(DerivedOffset)};
|
||||
return CreateCall(FnGCRelocate, Args, {}, Name);
|
||||
@ -897,7 +899,7 @@ CallInst *IRBuilderBase::CreateGCGetPointerBase(Value *DerivedPtr,
|
||||
const Twine &Name) {
|
||||
Module *M = BB->getParent()->getParent();
|
||||
Type *PtrTy = DerivedPtr->getType();
|
||||
Function *FnGCFindBase = Intrinsic::getDeclaration(
|
||||
Function *FnGCFindBase = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::experimental_gc_get_pointer_base, {PtrTy, PtrTy});
|
||||
return CreateCall(FnGCFindBase, {DerivedPtr}, {}, Name);
|
||||
}
|
||||
@ -906,7 +908,7 @@ CallInst *IRBuilderBase::CreateGCGetPointerOffset(Value *DerivedPtr,
|
||||
const Twine &Name) {
|
||||
Module *M = BB->getParent()->getParent();
|
||||
Type *PtrTy = DerivedPtr->getType();
|
||||
Function *FnGCGetOffset = Intrinsic::getDeclaration(
|
||||
Function *FnGCGetOffset = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::experimental_gc_get_pointer_offset, {PtrTy});
|
||||
return CreateCall(FnGCGetOffset, {DerivedPtr}, {}, Name);
|
||||
}
|
||||
@ -915,7 +917,7 @@ CallInst *IRBuilderBase::CreateUnaryIntrinsic(Intrinsic::ID ID, Value *V,
|
||||
Instruction *FMFSource,
|
||||
const Twine &Name) {
|
||||
Module *M = BB->getModule();
|
||||
Function *Fn = Intrinsic::getDeclaration(M, ID, {V->getType()});
|
||||
Function *Fn = Intrinsic::getOrInsertDeclaration(M, ID, {V->getType()});
|
||||
return createCallHelper(Fn, {V}, Name, FMFSource);
|
||||
}
|
||||
|
||||
@ -923,7 +925,7 @@ Value *IRBuilderBase::CreateBinaryIntrinsic(Intrinsic::ID ID, Value *LHS,
|
||||
Value *RHS, Instruction *FMFSource,
|
||||
const Twine &Name) {
|
||||
Module *M = BB->getModule();
|
||||
Function *Fn = Intrinsic::getDeclaration(M, ID, { LHS->getType() });
|
||||
Function *Fn = Intrinsic::getOrInsertDeclaration(M, ID, {LHS->getType()});
|
||||
if (Value *V = Folder.FoldBinaryIntrinsic(ID, LHS, RHS, Fn->getReturnType(),
|
||||
FMFSource))
|
||||
return V;
|
||||
@ -936,7 +938,7 @@ CallInst *IRBuilderBase::CreateIntrinsic(Intrinsic::ID ID,
|
||||
Instruction *FMFSource,
|
||||
const Twine &Name) {
|
||||
Module *M = BB->getModule();
|
||||
Function *Fn = Intrinsic::getDeclaration(M, ID, Types);
|
||||
Function *Fn = Intrinsic::getOrInsertDeclaration(M, ID, Types);
|
||||
return createCallHelper(Fn, Args, Name, FMFSource);
|
||||
}
|
||||
|
||||
@ -963,7 +965,7 @@ CallInst *IRBuilderBase::CreateIntrinsic(Type *RetTy, Intrinsic::ID ID,
|
||||
"Wrong types for intrinsic!");
|
||||
// TODO: Handle varargs intrinsics.
|
||||
|
||||
Function *Fn = Intrinsic::getDeclaration(M, ID, OverloadTys);
|
||||
Function *Fn = Intrinsic::getOrInsertDeclaration(M, ID, OverloadTys);
|
||||
return createCallHelper(Fn, Args, Name, FMFSource);
|
||||
}
|
||||
|
||||
@ -1120,7 +1122,7 @@ Value *IRBuilderBase::CreateLaunderInvariantGroup(Value *Ptr) {
|
||||
"launder.invariant.group only applies to pointers.");
|
||||
auto *PtrType = Ptr->getType();
|
||||
Module *M = BB->getParent()->getParent();
|
||||
Function *FnLaunderInvariantGroup = Intrinsic::getDeclaration(
|
||||
Function *FnLaunderInvariantGroup = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::launder_invariant_group, {PtrType});
|
||||
|
||||
assert(FnLaunderInvariantGroup->getReturnType() == PtrType &&
|
||||
@ -1137,7 +1139,7 @@ Value *IRBuilderBase::CreateStripInvariantGroup(Value *Ptr) {
|
||||
|
||||
auto *PtrType = Ptr->getType();
|
||||
Module *M = BB->getParent()->getParent();
|
||||
Function *FnStripInvariantGroup = Intrinsic::getDeclaration(
|
||||
Function *FnStripInvariantGroup = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::strip_invariant_group, {PtrType});
|
||||
|
||||
assert(FnStripInvariantGroup->getReturnType() == PtrType &&
|
||||
@ -1152,7 +1154,8 @@ Value *IRBuilderBase::CreateVectorReverse(Value *V, const Twine &Name) {
|
||||
auto *Ty = cast<VectorType>(V->getType());
|
||||
if (isa<ScalableVectorType>(Ty)) {
|
||||
Module *M = BB->getParent()->getParent();
|
||||
Function *F = Intrinsic::getDeclaration(M, Intrinsic::vector_reverse, Ty);
|
||||
Function *F =
|
||||
Intrinsic::getOrInsertDeclaration(M, Intrinsic::vector_reverse, Ty);
|
||||
return Insert(CallInst::Create(F, V), Name);
|
||||
}
|
||||
// Keep the original behaviour for fixed vector
|
||||
@ -1171,7 +1174,8 @@ Value *IRBuilderBase::CreateVectorSplice(Value *V1, Value *V2, int64_t Imm,
|
||||
|
||||
if (auto *VTy = dyn_cast<ScalableVectorType>(V1->getType())) {
|
||||
Module *M = BB->getParent()->getParent();
|
||||
Function *F = Intrinsic::getDeclaration(M, Intrinsic::vector_splice, VTy);
|
||||
Function *F =
|
||||
Intrinsic::getOrInsertDeclaration(M, Intrinsic::vector_splice, VTy);
|
||||
|
||||
Value *Ops[] = {V1, V2, getInt32(Imm)};
|
||||
return Insert(CallInst::Create(F, Ops), Name);
|
||||
@ -1225,7 +1229,7 @@ Value *IRBuilderBase::CreatePreserveArrayAccessIndex(
|
||||
Type *ResultType = GetElementPtrInst::getGEPReturnType(Base, IdxList);
|
||||
|
||||
Module *M = BB->getParent()->getParent();
|
||||
Function *FnPreserveArrayAccessIndex = Intrinsic::getDeclaration(
|
||||
Function *FnPreserveArrayAccessIndex = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::preserve_array_access_index, {ResultType, BaseType});
|
||||
|
||||
Value *DimV = getInt32(Dimension);
|
||||
@ -1246,7 +1250,7 @@ Value *IRBuilderBase::CreatePreserveUnionAccessIndex(
|
||||
auto *BaseType = Base->getType();
|
||||
|
||||
Module *M = BB->getParent()->getParent();
|
||||
Function *FnPreserveUnionAccessIndex = Intrinsic::getDeclaration(
|
||||
Function *FnPreserveUnionAccessIndex = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::preserve_union_access_index, {BaseType, BaseType});
|
||||
|
||||
Value *DIIndex = getInt32(FieldIndex);
|
||||
@ -1271,7 +1275,7 @@ Value *IRBuilderBase::CreatePreserveStructAccessIndex(
|
||||
GetElementPtrInst::getGEPReturnType(Base, {Zero, GEPIndex});
|
||||
|
||||
Module *M = BB->getParent()->getParent();
|
||||
Function *FnPreserveStructAccessIndex = Intrinsic::getDeclaration(
|
||||
Function *FnPreserveStructAccessIndex = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::preserve_struct_access_index, {ResultType, BaseType});
|
||||
|
||||
Value *DIIndex = getInt32(FieldIndex);
|
||||
@ -1288,8 +1292,8 @@ Value *IRBuilderBase::CreatePreserveStructAccessIndex(
|
||||
Value *IRBuilderBase::createIsFPClass(Value *FPNum, unsigned Test) {
|
||||
ConstantInt *TestV = getInt32(Test);
|
||||
Module *M = BB->getParent()->getParent();
|
||||
Function *FnIsFPClass =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::is_fpclass, {FPNum->getType()});
|
||||
Function *FnIsFPClass = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::is_fpclass, {FPNum->getType()});
|
||||
return CreateCall(FnIsFPClass, {FPNum, TestV});
|
||||
}
|
||||
|
||||
|
@ -629,9 +629,8 @@ bool VPIntrinsic::canIgnoreVectorLengthParam() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
Function *VPIntrinsic::getDeclarationForParams(Module *M, Intrinsic::ID VPID,
|
||||
Type *ReturnType,
|
||||
ArrayRef<Value *> Params) {
|
||||
Function *VPIntrinsic::getOrInsertDeclarationForParams(
|
||||
Module *M, Intrinsic::ID VPID, Type *ReturnType, ArrayRef<Value *> Params) {
|
||||
assert(isVPIntrinsic(VPID) && "not a VP intrinsic");
|
||||
Function *VPFunc;
|
||||
switch (VPID) {
|
||||
@ -641,7 +640,7 @@ Function *VPIntrinsic::getDeclarationForParams(Module *M, Intrinsic::ID VPID,
|
||||
OverloadTy =
|
||||
Params[*VPReductionIntrinsic::getVectorParamPos(VPID)]->getType();
|
||||
|
||||
VPFunc = Intrinsic::getDeclaration(M, VPID, OverloadTy);
|
||||
VPFunc = Intrinsic::getOrInsertDeclaration(M, VPID, OverloadTy);
|
||||
break;
|
||||
}
|
||||
case Intrinsic::vp_trunc:
|
||||
@ -658,43 +657,43 @@ Function *VPIntrinsic::getDeclarationForParams(Module *M, Intrinsic::ID VPID,
|
||||
case Intrinsic::vp_lrint:
|
||||
case Intrinsic::vp_llrint:
|
||||
case Intrinsic::vp_cttz_elts:
|
||||
VPFunc =
|
||||
Intrinsic::getDeclaration(M, VPID, {ReturnType, Params[0]->getType()});
|
||||
VPFunc = Intrinsic::getOrInsertDeclaration(
|
||||
M, VPID, {ReturnType, Params[0]->getType()});
|
||||
break;
|
||||
case Intrinsic::vp_is_fpclass:
|
||||
VPFunc = Intrinsic::getDeclaration(M, VPID, {Params[0]->getType()});
|
||||
VPFunc = Intrinsic::getOrInsertDeclaration(M, VPID, {Params[0]->getType()});
|
||||
break;
|
||||
case Intrinsic::vp_merge:
|
||||
case Intrinsic::vp_select:
|
||||
VPFunc = Intrinsic::getDeclaration(M, VPID, {Params[1]->getType()});
|
||||
VPFunc = Intrinsic::getOrInsertDeclaration(M, VPID, {Params[1]->getType()});
|
||||
break;
|
||||
case Intrinsic::vp_load:
|
||||
VPFunc = Intrinsic::getDeclaration(
|
||||
VPFunc = Intrinsic::getOrInsertDeclaration(
|
||||
M, VPID, {ReturnType, Params[0]->getType()});
|
||||
break;
|
||||
case Intrinsic::experimental_vp_strided_load:
|
||||
VPFunc = Intrinsic::getDeclaration(
|
||||
VPFunc = Intrinsic::getOrInsertDeclaration(
|
||||
M, VPID, {ReturnType, Params[0]->getType(), Params[1]->getType()});
|
||||
break;
|
||||
case Intrinsic::vp_gather:
|
||||
VPFunc = Intrinsic::getDeclaration(
|
||||
VPFunc = Intrinsic::getOrInsertDeclaration(
|
||||
M, VPID, {ReturnType, Params[0]->getType()});
|
||||
break;
|
||||
case Intrinsic::vp_store:
|
||||
VPFunc = Intrinsic::getDeclaration(
|
||||
VPFunc = Intrinsic::getOrInsertDeclaration(
|
||||
M, VPID, {Params[0]->getType(), Params[1]->getType()});
|
||||
break;
|
||||
case Intrinsic::experimental_vp_strided_store:
|
||||
VPFunc = Intrinsic::getDeclaration(
|
||||
VPFunc = Intrinsic::getOrInsertDeclaration(
|
||||
M, VPID,
|
||||
{Params[0]->getType(), Params[1]->getType(), Params[2]->getType()});
|
||||
break;
|
||||
case Intrinsic::vp_scatter:
|
||||
VPFunc = Intrinsic::getDeclaration(
|
||||
VPFunc = Intrinsic::getOrInsertDeclaration(
|
||||
M, VPID, {Params[0]->getType(), Params[1]->getType()});
|
||||
break;
|
||||
case Intrinsic::experimental_vp_splat:
|
||||
VPFunc = Intrinsic::getDeclaration(M, VPID, ReturnType);
|
||||
VPFunc = Intrinsic::getOrInsertDeclaration(M, VPID, ReturnType);
|
||||
break;
|
||||
}
|
||||
assert(VPFunc && "Could not declare VP intrinsic");
|
||||
|
@ -713,7 +713,8 @@ Intrinsic::ID Intrinsic::lookupIntrinsicID(StringRef Name) {
|
||||
#include "llvm/IR/IntrinsicImpl.inc"
|
||||
#undef GET_INTRINSIC_ATTRIBUTES
|
||||
|
||||
Function *Intrinsic::getDeclaration(Module *M, ID id, ArrayRef<Type *> Tys) {
|
||||
Function *Intrinsic::getOrInsertDeclaration(Module *M, ID id,
|
||||
ArrayRef<Type *> Tys) {
|
||||
// There can never be multiple globals with the same name of different types,
|
||||
// because intrinsics must be a specific type.
|
||||
auto *FT = getType(M->getContext(), id, Tys);
|
||||
@ -1078,7 +1079,7 @@ std::optional<Function *> Intrinsic::remangleIntrinsicFunction(Function *F) {
|
||||
// invalid and we'll get an error.
|
||||
ExistingGV->setName(WantedName + ".renamed");
|
||||
}
|
||||
return Intrinsic::getDeclaration(F->getParent(), ID, ArgTys);
|
||||
return Intrinsic::getOrInsertDeclaration(F->getParent(), ID, ArgTys);
|
||||
}();
|
||||
|
||||
NewDecl->setCallingConv(F->getCallingConv());
|
||||
|
@ -89,21 +89,22 @@ Module::~Module() {
|
||||
|
||||
void Module::removeDebugIntrinsicDeclarations() {
|
||||
auto *DeclareIntrinsicFn =
|
||||
Intrinsic::getDeclaration(this, Intrinsic::dbg_declare);
|
||||
Intrinsic::getOrInsertDeclaration(this, Intrinsic::dbg_declare);
|
||||
assert((!isMaterialized() || DeclareIntrinsicFn->hasZeroLiveUses()) &&
|
||||
"Debug declare intrinsic should have had uses removed.");
|
||||
DeclareIntrinsicFn->eraseFromParent();
|
||||
auto *ValueIntrinsicFn =
|
||||
Intrinsic::getDeclaration(this, Intrinsic::dbg_value);
|
||||
Intrinsic::getOrInsertDeclaration(this, Intrinsic::dbg_value);
|
||||
assert((!isMaterialized() || ValueIntrinsicFn->hasZeroLiveUses()) &&
|
||||
"Debug value intrinsic should have had uses removed.");
|
||||
ValueIntrinsicFn->eraseFromParent();
|
||||
auto *AssignIntrinsicFn =
|
||||
Intrinsic::getDeclaration(this, Intrinsic::dbg_assign);
|
||||
Intrinsic::getOrInsertDeclaration(this, Intrinsic::dbg_assign);
|
||||
assert((!isMaterialized() || AssignIntrinsicFn->hasZeroLiveUses()) &&
|
||||
"Debug assign intrinsic should have had uses removed.");
|
||||
AssignIntrinsicFn->eraseFromParent();
|
||||
auto *LabelntrinsicFn = Intrinsic::getDeclaration(this, Intrinsic::dbg_label);
|
||||
auto *LabelntrinsicFn =
|
||||
Intrinsic::getOrInsertDeclaration(this, Intrinsic::dbg_label);
|
||||
assert((!isMaterialized() || LabelntrinsicFn->hasZeroLiveUses()) &&
|
||||
"Debug label intrinsic should have had uses removed.");
|
||||
LabelntrinsicFn->eraseFromParent();
|
||||
|
@ -108,8 +108,8 @@ Value *VectorBuilder::createVectorInstructionImpl(Intrinsic::ID VPID,
|
||||
if (VLenPosOpt)
|
||||
IntrinParams[*VLenPosOpt] = &requestEVL();
|
||||
|
||||
auto *VPDecl = VPIntrinsic::getDeclarationForParams(&getModule(), VPID,
|
||||
ReturnTy, IntrinParams);
|
||||
auto *VPDecl = VPIntrinsic::getOrInsertDeclarationForParams(
|
||||
&getModule(), VPID, ReturnTy, IntrinParams);
|
||||
return Builder.CreateCall(VPDecl, IntrinParams, Name);
|
||||
}
|
||||
|
||||
|
@ -16454,8 +16454,8 @@ static void createTblForTrunc(TruncInst *TI, bool IsLittleEndian) {
|
||||
Builder.CreateShuffleVector(TI->getOperand(0), ShuffleLanes), VecTy));
|
||||
|
||||
if (Parts.size() == 4) {
|
||||
auto *F = Intrinsic::getDeclaration(TI->getModule(),
|
||||
Intrinsic::aarch64_neon_tbl4, VecTy);
|
||||
auto *F = Intrinsic::getOrInsertDeclaration(
|
||||
TI->getModule(), Intrinsic::aarch64_neon_tbl4, VecTy);
|
||||
Parts.push_back(ConstantVector::get(MaskConst));
|
||||
Results.push_back(Builder.CreateCall(F, Parts));
|
||||
Parts.clear();
|
||||
@ -16484,7 +16484,7 @@ static void createTblForTrunc(TruncInst *TI, bool IsLittleEndian) {
|
||||
break;
|
||||
}
|
||||
|
||||
auto *F = Intrinsic::getDeclaration(TI->getModule(), TblID, VecTy);
|
||||
auto *F = Intrinsic::getOrInsertDeclaration(TI->getModule(), TblID, VecTy);
|
||||
Parts.push_back(ConstantVector::get(MaskConst));
|
||||
Results.push_back(Builder.CreateCall(F, Parts));
|
||||
}
|
||||
@ -16765,9 +16765,10 @@ static Function *getStructuredLoadFunction(Module *M, unsigned Factor,
|
||||
Intrinsic::aarch64_neon_ld3,
|
||||
Intrinsic::aarch64_neon_ld4};
|
||||
if (Scalable)
|
||||
return Intrinsic::getDeclaration(M, SVELoads[Factor - 2], {LDVTy});
|
||||
return Intrinsic::getOrInsertDeclaration(M, SVELoads[Factor - 2], {LDVTy});
|
||||
|
||||
return Intrinsic::getDeclaration(M, NEONLoads[Factor - 2], {LDVTy, PtrTy});
|
||||
return Intrinsic::getOrInsertDeclaration(M, NEONLoads[Factor - 2],
|
||||
{LDVTy, PtrTy});
|
||||
}
|
||||
|
||||
static Function *getStructuredStoreFunction(Module *M, unsigned Factor,
|
||||
@ -16781,9 +16782,10 @@ static Function *getStructuredStoreFunction(Module *M, unsigned Factor,
|
||||
Intrinsic::aarch64_neon_st3,
|
||||
Intrinsic::aarch64_neon_st4};
|
||||
if (Scalable)
|
||||
return Intrinsic::getDeclaration(M, SVEStores[Factor - 2], {STVTy});
|
||||
return Intrinsic::getOrInsertDeclaration(M, SVEStores[Factor - 2], {STVTy});
|
||||
|
||||
return Intrinsic::getDeclaration(M, NEONStores[Factor - 2], {STVTy, PtrTy});
|
||||
return Intrinsic::getOrInsertDeclaration(M, NEONStores[Factor - 2],
|
||||
{STVTy, PtrTy});
|
||||
}
|
||||
|
||||
/// Lower an interleaved load into a ldN intrinsic.
|
||||
@ -27247,7 +27249,7 @@ Value *AArch64TargetLowering::emitLoadLinked(IRBuilderBase &Builder,
|
||||
if (ValueTy->getPrimitiveSizeInBits() == 128) {
|
||||
Intrinsic::ID Int =
|
||||
IsAcquire ? Intrinsic::aarch64_ldaxp : Intrinsic::aarch64_ldxp;
|
||||
Function *Ldxr = Intrinsic::getDeclaration(M, Int);
|
||||
Function *Ldxr = Intrinsic::getOrInsertDeclaration(M, Int);
|
||||
|
||||
Value *LoHi = Builder.CreateCall(Ldxr, Addr, "lohi");
|
||||
|
||||
@ -27266,7 +27268,7 @@ Value *AArch64TargetLowering::emitLoadLinked(IRBuilderBase &Builder,
|
||||
Type *Tys[] = { Addr->getType() };
|
||||
Intrinsic::ID Int =
|
||||
IsAcquire ? Intrinsic::aarch64_ldaxr : Intrinsic::aarch64_ldxr;
|
||||
Function *Ldxr = Intrinsic::getDeclaration(M, Int, Tys);
|
||||
Function *Ldxr = Intrinsic::getOrInsertDeclaration(M, Int, Tys);
|
||||
|
||||
const DataLayout &DL = M->getDataLayout();
|
||||
IntegerType *IntEltTy = Builder.getIntNTy(DL.getTypeSizeInBits(ValueTy));
|
||||
@ -27281,7 +27283,8 @@ Value *AArch64TargetLowering::emitLoadLinked(IRBuilderBase &Builder,
|
||||
void AArch64TargetLowering::emitAtomicCmpXchgNoStoreLLBalance(
|
||||
IRBuilderBase &Builder) const {
|
||||
Module *M = Builder.GetInsertBlock()->getParent()->getParent();
|
||||
Builder.CreateCall(Intrinsic::getDeclaration(M, Intrinsic::aarch64_clrex));
|
||||
Builder.CreateCall(
|
||||
Intrinsic::getOrInsertDeclaration(M, Intrinsic::aarch64_clrex));
|
||||
}
|
||||
|
||||
Value *AArch64TargetLowering::emitStoreConditional(IRBuilderBase &Builder,
|
||||
@ -27296,7 +27299,7 @@ Value *AArch64TargetLowering::emitStoreConditional(IRBuilderBase &Builder,
|
||||
if (Val->getType()->getPrimitiveSizeInBits() == 128) {
|
||||
Intrinsic::ID Int =
|
||||
IsRelease ? Intrinsic::aarch64_stlxp : Intrinsic::aarch64_stxp;
|
||||
Function *Stxr = Intrinsic::getDeclaration(M, Int);
|
||||
Function *Stxr = Intrinsic::getOrInsertDeclaration(M, Int);
|
||||
Type *Int64Ty = Type::getInt64Ty(M->getContext());
|
||||
Type *Int128Ty = Type::getInt128Ty(M->getContext());
|
||||
|
||||
@ -27311,7 +27314,7 @@ Value *AArch64TargetLowering::emitStoreConditional(IRBuilderBase &Builder,
|
||||
Intrinsic::ID Int =
|
||||
IsRelease ? Intrinsic::aarch64_stlxr : Intrinsic::aarch64_stxr;
|
||||
Type *Tys[] = { Addr->getType() };
|
||||
Function *Stxr = Intrinsic::getDeclaration(M, Int, Tys);
|
||||
Function *Stxr = Intrinsic::getOrInsertDeclaration(M, Int, Tys);
|
||||
|
||||
const DataLayout &DL = M->getDataLayout();
|
||||
IntegerType *IntValTy = Builder.getIntNTy(DL.getTypeSizeInBits(Val->getType()));
|
||||
@ -27348,7 +27351,7 @@ bool AArch64TargetLowering::shouldNormalizeToSelectSequence(LLVMContext &,
|
||||
static Value *UseTlsOffset(IRBuilderBase &IRB, unsigned Offset) {
|
||||
Module *M = IRB.GetInsertBlock()->getParent()->getParent();
|
||||
Function *ThreadPointerFunc =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::thread_pointer);
|
||||
Intrinsic::getOrInsertDeclaration(M, Intrinsic::thread_pointer);
|
||||
return IRB.CreatePointerCast(
|
||||
IRB.CreateConstGEP1_32(IRB.getInt8Ty(), IRB.CreateCall(ThreadPointerFunc),
|
||||
Offset),
|
||||
|
@ -436,10 +436,10 @@ Instruction *AArch64StackTagging::collectInitializers(Instruction *StartInst,
|
||||
|
||||
void AArch64StackTagging::tagAlloca(AllocaInst *AI, Instruction *InsertBefore,
|
||||
Value *Ptr, uint64_t Size) {
|
||||
auto SetTagZeroFunc =
|
||||
Intrinsic::getDeclaration(F->getParent(), Intrinsic::aarch64_settag_zero);
|
||||
auto StgpFunc =
|
||||
Intrinsic::getDeclaration(F->getParent(), Intrinsic::aarch64_stgp);
|
||||
auto SetTagZeroFunc = Intrinsic::getOrInsertDeclaration(
|
||||
F->getParent(), Intrinsic::aarch64_settag_zero);
|
||||
auto StgpFunc = Intrinsic::getOrInsertDeclaration(F->getParent(),
|
||||
Intrinsic::aarch64_stgp);
|
||||
|
||||
InitializerBuilder IB(Size, DL, Ptr, SetTagFunc, SetTagZeroFunc, StgpFunc);
|
||||
bool LittleEndian =
|
||||
@ -481,8 +481,8 @@ Instruction *AArch64StackTagging::insertBaseTaggedPointer(
|
||||
assert(PrologueBB);
|
||||
|
||||
IRBuilder<> IRB(&PrologueBB->front());
|
||||
Function *IRG_SP =
|
||||
Intrinsic::getDeclaration(F->getParent(), Intrinsic::aarch64_irg_sp);
|
||||
Function *IRG_SP = Intrinsic::getOrInsertDeclaration(
|
||||
F->getParent(), Intrinsic::aarch64_irg_sp);
|
||||
Instruction *Base =
|
||||
IRB.CreateCall(IRG_SP, {Constant::getNullValue(IRB.getInt64Ty())});
|
||||
Base->setName("basetag");
|
||||
@ -563,8 +563,8 @@ bool AArch64StackTagging::runOnFunction(Function &Fn) {
|
||||
LI = DeleteLI.get();
|
||||
}
|
||||
|
||||
SetTagFunc =
|
||||
Intrinsic::getDeclaration(F->getParent(), Intrinsic::aarch64_settag);
|
||||
SetTagFunc = Intrinsic::getOrInsertDeclaration(F->getParent(),
|
||||
Intrinsic::aarch64_settag);
|
||||
|
||||
Instruction *Base =
|
||||
insertBaseTaggedPointer(*Fn.getParent(), SInfo.AllocasToInstrument, DT);
|
||||
@ -580,7 +580,7 @@ bool AArch64StackTagging::runOnFunction(Function &Fn) {
|
||||
NextTag = (NextTag + 1) % 16;
|
||||
// Replace alloca with tagp(alloca).
|
||||
IRBuilder<> IRB(Info.AI->getNextNode());
|
||||
Function *TagP = Intrinsic::getDeclaration(
|
||||
Function *TagP = Intrinsic::getOrInsertDeclaration(
|
||||
F->getParent(), Intrinsic::aarch64_tagp, {Info.AI->getType()});
|
||||
Instruction *TagPCall =
|
||||
IRB.CreateCall(TagP, {Constant::getNullValue(Info.AI->getType()), Base,
|
||||
|
@ -1637,7 +1637,7 @@ static std::optional<Instruction *> instCombineSVEAllActive(IntrinsicInst &II,
|
||||
return std::nullopt;
|
||||
|
||||
auto *Mod = II.getModule();
|
||||
auto *NewDecl = Intrinsic::getDeclaration(Mod, IID, {II.getType()});
|
||||
auto *NewDecl = Intrinsic::getOrInsertDeclaration(Mod, IID, {II.getType()});
|
||||
II.setCalledFunction(NewDecl);
|
||||
|
||||
return &II;
|
||||
|
@ -71,7 +71,7 @@ void emitTPIDR2Save(Module *M, IRBuilder<> &Builder) {
|
||||
|
||||
// A save to TPIDR2 should be followed by clearing TPIDR2_EL0.
|
||||
Function *WriteIntr =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::aarch64_sme_set_tpidr2);
|
||||
Intrinsic::getOrInsertDeclaration(M, Intrinsic::aarch64_sme_set_tpidr2);
|
||||
Builder.CreateCall(WriteIntr->getFunctionType(), WriteIntr,
|
||||
Builder.getInt64(0));
|
||||
}
|
||||
@ -114,7 +114,7 @@ bool SMEABI::updateNewStateFunctions(Module *M, Function *F,
|
||||
// Read TPIDR2_EL0 in PreludeBB & branch to SaveBB if not 0.
|
||||
Builder.SetInsertPoint(PreludeBB);
|
||||
Function *TPIDR2Intr =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::aarch64_sme_get_tpidr2);
|
||||
Intrinsic::getOrInsertDeclaration(M, Intrinsic::aarch64_sme_get_tpidr2);
|
||||
auto *TPIDR2 = Builder.CreateCall(TPIDR2Intr->getFunctionType(), TPIDR2Intr,
|
||||
{}, "tpidr2");
|
||||
auto *Cmp = Builder.CreateCmp(ICmpInst::ICMP_NE, TPIDR2,
|
||||
@ -128,20 +128,20 @@ bool SMEABI::updateNewStateFunctions(Module *M, Function *F,
|
||||
// Enable pstate.za at the start of the function.
|
||||
Builder.SetInsertPoint(&OrigBB->front());
|
||||
Function *EnableZAIntr =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::aarch64_sme_za_enable);
|
||||
Intrinsic::getOrInsertDeclaration(M, Intrinsic::aarch64_sme_za_enable);
|
||||
Builder.CreateCall(EnableZAIntr->getFunctionType(), EnableZAIntr);
|
||||
}
|
||||
|
||||
if (FnAttrs.isNewZA()) {
|
||||
Function *ZeroIntr =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::aarch64_sme_zero);
|
||||
Intrinsic::getOrInsertDeclaration(M, Intrinsic::aarch64_sme_zero);
|
||||
Builder.CreateCall(ZeroIntr->getFunctionType(), ZeroIntr,
|
||||
Builder.getInt32(0xff));
|
||||
}
|
||||
|
||||
if (FnAttrs.isNewZT0()) {
|
||||
Function *ClearZT0Intr =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::aarch64_sme_zero_zt);
|
||||
Intrinsic::getOrInsertDeclaration(M, Intrinsic::aarch64_sme_zero_zt);
|
||||
Builder.CreateCall(ClearZT0Intr->getFunctionType(), ClearZT0Intr,
|
||||
{Builder.getInt32(0)});
|
||||
}
|
||||
@ -153,8 +153,8 @@ bool SMEABI::updateNewStateFunctions(Module *M, Function *F,
|
||||
if (!T || !isa<ReturnInst>(T))
|
||||
continue;
|
||||
Builder.SetInsertPoint(T);
|
||||
Function *DisableZAIntr =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::aarch64_sme_za_disable);
|
||||
Function *DisableZAIntr = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::aarch64_sme_za_disable);
|
||||
Builder.CreateCall(DisableZAIntr->getFunctionType(), DisableZAIntr);
|
||||
}
|
||||
}
|
||||
|
@ -407,8 +407,8 @@ Value *AMDGPUAtomicOptimizerImpl::buildReduction(IRBuilder<> &B,
|
||||
Value *const Identity) const {
|
||||
Type *AtomicTy = V->getType();
|
||||
Module *M = B.GetInsertBlock()->getModule();
|
||||
Function *UpdateDPP =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::amdgcn_update_dpp, AtomicTy);
|
||||
Function *UpdateDPP = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::amdgcn_update_dpp, AtomicTy);
|
||||
|
||||
// Reduce within each row of 16 lanes.
|
||||
for (unsigned Idx = 0; Idx < 4; Idx++) {
|
||||
@ -439,8 +439,8 @@ Value *AMDGPUAtomicOptimizerImpl::buildReduction(IRBuilder<> &B,
|
||||
|
||||
// Pick an arbitrary lane from 0..31 and an arbitrary lane from 32..63 and
|
||||
// combine them with a scalar operation.
|
||||
Function *ReadLane =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::amdgcn_readlane, AtomicTy);
|
||||
Function *ReadLane = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::amdgcn_readlane, AtomicTy);
|
||||
Value *Lane0 = B.CreateCall(ReadLane, {V, B.getInt32(0)});
|
||||
Value *Lane32 = B.CreateCall(ReadLane, {V, B.getInt32(32)});
|
||||
return buildNonAtomicBinOp(B, Op, Lane0, Lane32);
|
||||
@ -453,8 +453,8 @@ Value *AMDGPUAtomicOptimizerImpl::buildScan(IRBuilder<> &B,
|
||||
Value *Identity) const {
|
||||
Type *AtomicTy = V->getType();
|
||||
Module *M = B.GetInsertBlock()->getModule();
|
||||
Function *UpdateDPP =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::amdgcn_update_dpp, AtomicTy);
|
||||
Function *UpdateDPP = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::amdgcn_update_dpp, AtomicTy);
|
||||
|
||||
for (unsigned Idx = 0; Idx < 4; Idx++) {
|
||||
V = buildNonAtomicBinOp(
|
||||
@ -513,18 +513,18 @@ Value *AMDGPUAtomicOptimizerImpl::buildShiftRight(IRBuilder<> &B, Value *V,
|
||||
Value *Identity) const {
|
||||
Type *AtomicTy = V->getType();
|
||||
Module *M = B.GetInsertBlock()->getModule();
|
||||
Function *UpdateDPP =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::amdgcn_update_dpp, AtomicTy);
|
||||
Function *UpdateDPP = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::amdgcn_update_dpp, AtomicTy);
|
||||
if (ST->hasDPPWavefrontShifts()) {
|
||||
// GFX9 has DPP wavefront shift operations.
|
||||
V = B.CreateCall(UpdateDPP,
|
||||
{Identity, V, B.getInt32(DPP::WAVE_SHR1), B.getInt32(0xf),
|
||||
B.getInt32(0xf), B.getFalse()});
|
||||
} else {
|
||||
Function *ReadLane =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::amdgcn_readlane, AtomicTy);
|
||||
Function *WriteLane =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::amdgcn_writelane, AtomicTy);
|
||||
Function *ReadLane = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::amdgcn_readlane, AtomicTy);
|
||||
Function *WriteLane = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::amdgcn_writelane, AtomicTy);
|
||||
|
||||
// On GFX10 all DPP operations are confined to a single row. To get cross-
|
||||
// row operations we have to use permlane or readlane.
|
||||
|
@ -119,8 +119,8 @@ public:
|
||||
return SqrtF32;
|
||||
|
||||
LLVMContext &Ctx = Mod->getContext();
|
||||
SqrtF32 = Intrinsic::getDeclaration(Mod, Intrinsic::amdgcn_sqrt,
|
||||
{Type::getFloatTy(Ctx)});
|
||||
SqrtF32 = Intrinsic::getOrInsertDeclaration(Mod, Intrinsic::amdgcn_sqrt,
|
||||
{Type::getFloatTy(Ctx)});
|
||||
return SqrtF32;
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ public:
|
||||
return LdexpF32;
|
||||
|
||||
LLVMContext &Ctx = Mod->getContext();
|
||||
LdexpF32 = Intrinsic::getDeclaration(
|
||||
LdexpF32 = Intrinsic::getOrInsertDeclaration(
|
||||
Mod, Intrinsic::ldexp, {Type::getFloatTy(Ctx), Type::getInt32Ty(Ctx)});
|
||||
return LdexpF32;
|
||||
}
|
||||
@ -577,7 +577,7 @@ bool AMDGPUCodeGenPrepareImpl::promoteUniformBitreverseToI32(
|
||||
|
||||
Type *I32Ty = getI32Ty(Builder, I.getType());
|
||||
Function *I32 =
|
||||
Intrinsic::getDeclaration(Mod, Intrinsic::bitreverse, { I32Ty });
|
||||
Intrinsic::getOrInsertDeclaration(Mod, Intrinsic::bitreverse, {I32Ty});
|
||||
Value *ExtOp = Builder.CreateZExt(I.getOperand(0), I32Ty);
|
||||
Value *ExtRes = Builder.CreateCall(I32, { ExtOp });
|
||||
Value *LShrOp =
|
||||
@ -1260,8 +1260,8 @@ Value *AMDGPUCodeGenPrepareImpl::expandDivRem24Impl(
|
||||
Value *FB = IsSigned ? Builder.CreateSIToFP(IB,F32Ty)
|
||||
: Builder.CreateUIToFP(IB,F32Ty);
|
||||
|
||||
Function *RcpDecl = Intrinsic::getDeclaration(Mod, Intrinsic::amdgcn_rcp,
|
||||
Builder.getFloatTy());
|
||||
Function *RcpDecl = Intrinsic::getOrInsertDeclaration(
|
||||
Mod, Intrinsic::amdgcn_rcp, Builder.getFloatTy());
|
||||
Value *RCP = Builder.CreateCall(RcpDecl, { FB });
|
||||
Value *FQM = Builder.CreateFMul(FA, RCP);
|
||||
|
||||
@ -1455,7 +1455,8 @@ Value *AMDGPUCodeGenPrepareImpl::expandDivRem32(IRBuilder<> &Builder,
|
||||
|
||||
// Initial estimate of inv(y).
|
||||
Value *FloatY = Builder.CreateUIToFP(Y, F32Ty);
|
||||
Function *Rcp = Intrinsic::getDeclaration(Mod, Intrinsic::amdgcn_rcp, F32Ty);
|
||||
Function *Rcp =
|
||||
Intrinsic::getOrInsertDeclaration(Mod, Intrinsic::amdgcn_rcp, F32Ty);
|
||||
Value *RcpY = Builder.CreateCall(Rcp, {FloatY});
|
||||
Constant *Scale = ConstantFP::get(F32Ty, llvm::bit_cast<float>(0x4F7FFFFE));
|
||||
Value *ScaledY = Builder.CreateFMul(RcpY, Scale);
|
||||
|
@ -237,7 +237,7 @@ bool optimizeSection(ArrayRef<SmallVector<IntrinsicInst *, 4>> MergeableInsts) {
|
||||
else
|
||||
NewIntrinID = Intrinsic::amdgcn_image_msaa_load_2darraymsaa;
|
||||
|
||||
Function *NewIntrin = Intrinsic::getDeclaration(
|
||||
Function *NewIntrin = Intrinsic::getOrInsertDeclaration(
|
||||
IIList.front()->getModule(), NewIntrinID, OverloadTys);
|
||||
Args[ImageDimIntr->DMaskIndex] =
|
||||
ConstantInt::get(DMask->getType(), NewMaskVal);
|
||||
|
@ -130,7 +130,8 @@ static std::optional<Instruction *> modifyIntrinsicCall(
|
||||
// Modify arguments and types
|
||||
Func(Args, ArgTys);
|
||||
|
||||
Function *I = Intrinsic::getDeclaration(OldIntr.getModule(), NewIntr, ArgTys);
|
||||
Function *I =
|
||||
Intrinsic::getOrInsertDeclaration(OldIntr.getModule(), NewIntr, ArgTys);
|
||||
|
||||
CallInst *NewCall = IC.Builder.CreateCall(I, Args);
|
||||
NewCall->takeName(&OldIntr);
|
||||
@ -502,7 +503,7 @@ GCNTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
|
||||
if (IID == Intrinsic::sqrt && !canContractSqrtToRsq(SqrtOp))
|
||||
break;
|
||||
|
||||
Function *NewDecl = Intrinsic::getDeclaration(
|
||||
Function *NewDecl = Intrinsic::getOrInsertDeclaration(
|
||||
SrcCI->getModule(), Intrinsic::amdgcn_rsq, {SrcCI->getType()});
|
||||
|
||||
InnerFMF |= FMF;
|
||||
@ -527,7 +528,7 @@ GCNTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
|
||||
|
||||
// f16 amdgcn.sqrt is identical to regular sqrt.
|
||||
if (IID == Intrinsic::amdgcn_sqrt && Src->getType()->isHalfTy()) {
|
||||
Function *NewDecl = Intrinsic::getDeclaration(
|
||||
Function *NewDecl = Intrinsic::getOrInsertDeclaration(
|
||||
II.getModule(), Intrinsic::sqrt, {II.getType()});
|
||||
II.setCalledFunction(NewDecl);
|
||||
return &II;
|
||||
@ -614,7 +615,7 @@ GCNTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
|
||||
Value *Src1 = II.getArgOperand(1);
|
||||
const ConstantInt *CMask = dyn_cast<ConstantInt>(Src1);
|
||||
if (CMask) {
|
||||
II.setCalledOperand(Intrinsic::getDeclaration(
|
||||
II.setCalledOperand(Intrinsic::getOrInsertDeclaration(
|
||||
II.getModule(), Intrinsic::is_fpclass, Src0->getType()));
|
||||
|
||||
// Clamp any excess bits, as they're illegal for the generic intrinsic.
|
||||
@ -890,7 +891,7 @@ GCNTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
|
||||
// register (which contains the bitmask of live threads). So a
|
||||
// comparison that always returns true is the same as a read of the
|
||||
// EXEC register.
|
||||
Function *NewF = Intrinsic::getDeclaration(
|
||||
Function *NewF = Intrinsic::getOrInsertDeclaration(
|
||||
II.getModule(), Intrinsic::read_register, II.getType());
|
||||
Metadata *MDArgs[] = {MDString::get(II.getContext(), "exec")};
|
||||
MDNode *MD = MDNode::get(II.getContext(), MDArgs);
|
||||
@ -989,7 +990,7 @@ GCNTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
|
||||
} else if (!Ty->isFloatTy() && !Ty->isDoubleTy() && !Ty->isHalfTy())
|
||||
break;
|
||||
|
||||
Function *NewF = Intrinsic::getDeclaration(
|
||||
Function *NewF = Intrinsic::getOrInsertDeclaration(
|
||||
II.getModule(), NewIID, {II.getType(), SrcLHS->getType()});
|
||||
Value *Args[] = {SrcLHS, SrcRHS,
|
||||
ConstantInt::get(CC->getType(), SrcPred)};
|
||||
@ -1205,7 +1206,7 @@ GCNTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
|
||||
// If we can prove we don't have one of the special cases then we can use a
|
||||
// normal fma instead.
|
||||
if (canSimplifyLegacyMulToMul(II, Op0, Op1, IC)) {
|
||||
II.setCalledOperand(Intrinsic::getDeclaration(
|
||||
II.setCalledOperand(Intrinsic::getOrInsertDeclaration(
|
||||
II.getModule(), Intrinsic::fma, II.getType()));
|
||||
return &II;
|
||||
}
|
||||
@ -1401,7 +1402,7 @@ static Value *simplifyAMDGCNMemoryIntrinsicDemanded(InstCombiner &IC,
|
||||
Args[0] = IC.Builder.CreateShuffleVector(II.getOperand(0), EltMask);
|
||||
}
|
||||
|
||||
Function *NewIntrin = Intrinsic::getDeclaration(
|
||||
Function *NewIntrin = Intrinsic::getOrInsertDeclaration(
|
||||
II.getModule(), II.getIntrinsicID(), OverloadTys);
|
||||
CallInst *NewCall = IC.Builder.CreateCall(NewIntrin, Args);
|
||||
NewCall->takeName(&II);
|
||||
|
@ -1555,8 +1555,8 @@ bool AMDGPUInstructionSelector::selectGroupStaticSize(MachineInstr &I) const {
|
||||
MIB.addImm(MFI->getLDSSize());
|
||||
} else {
|
||||
Module *M = MF->getFunction().getParent();
|
||||
const GlobalValue *GV
|
||||
= Intrinsic::getDeclaration(M, Intrinsic::amdgcn_groupstaticsize);
|
||||
const GlobalValue *GV =
|
||||
Intrinsic::getOrInsertDeclaration(M, Intrinsic::amdgcn_groupstaticsize);
|
||||
MIB.addGlobalAddress(GV, 0, SIInstrInfo::MO_ABS32_LO);
|
||||
}
|
||||
|
||||
|
@ -753,7 +753,7 @@ bool AMDGPULibCalls::fold(CallInst *CI) {
|
||||
CI->setArgOperand(1, SplatArg1);
|
||||
}
|
||||
|
||||
CI->setCalledFunction(Intrinsic::getDeclaration(
|
||||
CI->setCalledFunction(Intrinsic::getOrInsertDeclaration(
|
||||
CI->getModule(), Intrinsic::ldexp,
|
||||
{CI->getType(), CI->getArgOperand(1)->getType()}));
|
||||
return true;
|
||||
@ -1034,7 +1034,8 @@ bool AMDGPULibCalls::fold_pow(FPMathOperator *FPOp, IRBuilder<> &B,
|
||||
// pown/pow ---> powr(fabs(x), y) | (x & ((int)y << 31))
|
||||
FunctionCallee ExpExpr;
|
||||
if (ShouldUseIntrinsic)
|
||||
ExpExpr = Intrinsic::getDeclaration(M, Intrinsic::exp2, {FPOp->getType()});
|
||||
ExpExpr = Intrinsic::getOrInsertDeclaration(M, Intrinsic::exp2,
|
||||
{FPOp->getType()});
|
||||
else {
|
||||
ExpExpr = getFunction(M, AMDGPULibFunc(AMDGPULibFunc::EI_EXP2, FInfo));
|
||||
if (!ExpExpr)
|
||||
@ -1108,8 +1109,8 @@ bool AMDGPULibCalls::fold_pow(FPMathOperator *FPOp, IRBuilder<> &B,
|
||||
if (needlog) {
|
||||
FunctionCallee LogExpr;
|
||||
if (ShouldUseIntrinsic) {
|
||||
LogExpr =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::log2, {FPOp->getType()});
|
||||
LogExpr = Intrinsic::getOrInsertDeclaration(M, Intrinsic::log2,
|
||||
{FPOp->getType()});
|
||||
} else {
|
||||
LogExpr = getFunction(M, AMDGPULibFunc(AMDGPULibFunc::EI_LOG2, FInfo));
|
||||
if (!LogExpr)
|
||||
@ -1298,8 +1299,8 @@ void AMDGPULibCalls::replaceLibCallWithSimpleIntrinsic(IRBuilder<> &B,
|
||||
}
|
||||
}
|
||||
|
||||
CI->setCalledFunction(
|
||||
Intrinsic::getDeclaration(CI->getModule(), IntrID, {CI->getType()}));
|
||||
CI->setCalledFunction(Intrinsic::getOrInsertDeclaration(
|
||||
CI->getModule(), IntrID, {CI->getType()}));
|
||||
}
|
||||
|
||||
bool AMDGPULibCalls::tryReplaceLibcallWithSimpleIntrinsic(
|
||||
|
@ -285,8 +285,8 @@ class AMDGPULowerModuleLDS {
|
||||
BasicBlock *Entry = &Func->getEntryBlock();
|
||||
IRBuilder<> Builder(Entry, Entry->getFirstNonPHIIt());
|
||||
|
||||
Function *Decl =
|
||||
Intrinsic::getDeclaration(Func->getParent(), Intrinsic::donothing, {});
|
||||
Function *Decl = Intrinsic::getOrInsertDeclaration(
|
||||
Func->getParent(), Intrinsic::donothing, {});
|
||||
|
||||
Value *UseInstance[1] = {
|
||||
Builder.CreateConstInBoundsGEP1_32(SGV->getValueType(), SGV, 0)};
|
||||
@ -529,8 +529,8 @@ public:
|
||||
// block to spare deduplicating it later.
|
||||
auto [It, Inserted] = tableKernelIndexCache.try_emplace(F);
|
||||
if (Inserted) {
|
||||
Function *Decl =
|
||||
Intrinsic::getDeclaration(&M, Intrinsic::amdgcn_lds_kernel_id, {});
|
||||
Function *Decl = Intrinsic::getOrInsertDeclaration(
|
||||
&M, Intrinsic::amdgcn_lds_kernel_id, {});
|
||||
|
||||
auto InsertAt = F->getEntryBlock().getFirstNonPHIOrDbgOrAlloca();
|
||||
IRBuilder<> Builder(&*InsertAt);
|
||||
|
@ -973,10 +973,10 @@ AMDGPUPromoteAllocaImpl::getLocalSizeYZ(IRBuilder<> &Builder) {
|
||||
const AMDGPUSubtarget &ST = AMDGPUSubtarget::get(TM, F);
|
||||
|
||||
if (!IsAMDHSA) {
|
||||
Function *LocalSizeYFn =
|
||||
Intrinsic::getDeclaration(Mod, Intrinsic::r600_read_local_size_y);
|
||||
Function *LocalSizeZFn =
|
||||
Intrinsic::getDeclaration(Mod, Intrinsic::r600_read_local_size_z);
|
||||
Function *LocalSizeYFn = Intrinsic::getOrInsertDeclaration(
|
||||
Mod, Intrinsic::r600_read_local_size_y);
|
||||
Function *LocalSizeZFn = Intrinsic::getOrInsertDeclaration(
|
||||
Mod, Intrinsic::r600_read_local_size_z);
|
||||
|
||||
CallInst *LocalSizeY = Builder.CreateCall(LocalSizeYFn, {});
|
||||
CallInst *LocalSizeZ = Builder.CreateCall(LocalSizeZFn, {});
|
||||
@ -1022,7 +1022,7 @@ AMDGPUPromoteAllocaImpl::getLocalSizeYZ(IRBuilder<> &Builder) {
|
||||
// } hsa_kernel_dispatch_packet_t
|
||||
//
|
||||
Function *DispatchPtrFn =
|
||||
Intrinsic::getDeclaration(Mod, Intrinsic::amdgcn_dispatch_ptr);
|
||||
Intrinsic::getOrInsertDeclaration(Mod, Intrinsic::amdgcn_dispatch_ptr);
|
||||
|
||||
CallInst *DispatchPtr = Builder.CreateCall(DispatchPtrFn, {});
|
||||
DispatchPtr->addRetAttr(Attribute::NoAlias);
|
||||
@ -1082,7 +1082,7 @@ Value *AMDGPUPromoteAllocaImpl::getWorkitemID(IRBuilder<> &Builder,
|
||||
llvm_unreachable("invalid dimension");
|
||||
}
|
||||
|
||||
Function *WorkitemIdFn = Intrinsic::getDeclaration(Mod, IntrID);
|
||||
Function *WorkitemIdFn = Intrinsic::getOrInsertDeclaration(Mod, IntrID);
|
||||
CallInst *CI = Builder.CreateCall(WorkitemIdFn);
|
||||
ST.makeLIDRangeMetadata(CI);
|
||||
F->removeFnAttr(AttrName);
|
||||
@ -1564,7 +1564,7 @@ bool AMDGPUPromoteAllocaImpl::tryPromoteAllocaToLDS(AllocaInst &I,
|
||||
continue;
|
||||
case Intrinsic::objectsize: {
|
||||
Value *Src = Intr->getOperand(0);
|
||||
Function *ObjectSize = Intrinsic::getDeclaration(
|
||||
Function *ObjectSize = Intrinsic::getOrInsertDeclaration(
|
||||
Mod, Intrinsic::objectsize,
|
||||
{Intr->getType(),
|
||||
PointerType::get(Context, AMDGPUAS::LOCAL_ADDRESS)});
|
||||
|
@ -336,8 +336,8 @@ static void markUsedByKernel(Function *Func, GlobalVariable *SGV) {
|
||||
BasicBlock *Entry = &Func->getEntryBlock();
|
||||
IRBuilder<> Builder(Entry, Entry->getFirstNonPHIIt());
|
||||
|
||||
Function *Decl =
|
||||
Intrinsic::getDeclaration(Func->getParent(), Intrinsic::donothing, {});
|
||||
Function *Decl = Intrinsic::getOrInsertDeclaration(Func->getParent(),
|
||||
Intrinsic::donothing, {});
|
||||
|
||||
Value *UseInstance[1] = {
|
||||
Builder.CreateConstInBoundsGEP1_32(SGV->getValueType(), SGV, 0)};
|
||||
@ -922,7 +922,8 @@ void AMDGPUSwLowerLDS::lowerKernelLDSAccesses(Function *Func,
|
||||
StringRef("__asan_free_impl"),
|
||||
FunctionType::get(IRB.getVoidTy(), {Int64Ty, Int64Ty}, false));
|
||||
Value *ReturnAddr = IRB.CreateCall(
|
||||
Intrinsic::getDeclaration(&M, Intrinsic::returnaddress), IRB.getInt32(0));
|
||||
Intrinsic::getOrInsertDeclaration(&M, Intrinsic::returnaddress),
|
||||
IRB.getInt32(0));
|
||||
Value *RAPToInt = IRB.CreatePtrToInt(ReturnAddr, Int64Ty);
|
||||
Value *MallocPtrToInt = IRB.CreatePtrToInt(LoadMallocPtr, Int64Ty);
|
||||
IRB.CreateCall(AsanFreeFunc, {MallocPtrToInt, RAPToInt});
|
||||
@ -1055,8 +1056,8 @@ void AMDGPUSwLowerLDS::lowerNonKernelLDSAccesses(
|
||||
SetVector<Instruction *> LDSInstructions;
|
||||
getLDSMemoryInstructions(Func, LDSInstructions);
|
||||
|
||||
Function *Decl =
|
||||
Intrinsic::getDeclaration(&M, Intrinsic::amdgcn_lds_kernel_id, {});
|
||||
Function *Decl = Intrinsic::getOrInsertDeclaration(
|
||||
&M, Intrinsic::amdgcn_lds_kernel_id, {});
|
||||
auto *KernelId = IRB.CreateCall(Decl, {});
|
||||
GlobalVariable *LDSBaseTable = NKLDSParams.LDSBaseTable;
|
||||
GlobalVariable *LDSOffsetTable = NKLDSParams.LDSOffsetTable;
|
||||
|
@ -1112,8 +1112,8 @@ Value *GCNTTIImpl::rewriteIntrinsicWithAddressSpace(IntrinsicInst *II,
|
||||
if (!AMDGPU::isExtendedGlobalAddrSpace(NewAS))
|
||||
return nullptr;
|
||||
Module *M = II->getModule();
|
||||
Function *NewDecl = Intrinsic::getDeclaration(M, II->getIntrinsicID(),
|
||||
{DestTy, SrcTy, DestTy});
|
||||
Function *NewDecl = Intrinsic::getOrInsertDeclaration(
|
||||
M, II->getIntrinsicID(), {DestTy, SrcTy, DestTy});
|
||||
II->setArgOperand(0, NewV);
|
||||
II->setCalledFunction(NewDecl);
|
||||
return II;
|
||||
|
@ -295,8 +295,8 @@ bool AMDGPUUnifyDivergentExitNodesImpl::run(Function &F, DominatorTree *DT,
|
||||
// Remove and delete the unreachable inst.
|
||||
UnreachableBlock->getTerminator()->eraseFromParent();
|
||||
|
||||
Function *UnreachableIntrin =
|
||||
Intrinsic::getDeclaration(F.getParent(), Intrinsic::amdgcn_unreachable);
|
||||
Function *UnreachableIntrin = Intrinsic::getOrInsertDeclaration(
|
||||
F.getParent(), Intrinsic::amdgcn_unreachable);
|
||||
|
||||
// Insert a call to an intrinsic tracking that this is an unreachable
|
||||
// point, in case we want to kill the active lanes or something later.
|
||||
|
@ -117,13 +117,15 @@ void SIAnnotateControlFlow::initialize(Module &M, const GCNSubtarget &ST) {
|
||||
BoolUndef = PoisonValue::get(Boolean);
|
||||
IntMaskZero = ConstantInt::get(IntMask, 0);
|
||||
|
||||
If = Intrinsic::getDeclaration(&M, Intrinsic::amdgcn_if, { IntMask });
|
||||
Else = Intrinsic::getDeclaration(&M, Intrinsic::amdgcn_else,
|
||||
{ IntMask, IntMask });
|
||||
IfBreak = Intrinsic::getDeclaration(&M, Intrinsic::amdgcn_if_break,
|
||||
{ IntMask });
|
||||
Loop = Intrinsic::getDeclaration(&M, Intrinsic::amdgcn_loop, { IntMask });
|
||||
EndCf = Intrinsic::getDeclaration(&M, Intrinsic::amdgcn_end_cf, { IntMask });
|
||||
If = Intrinsic::getOrInsertDeclaration(&M, Intrinsic::amdgcn_if, {IntMask});
|
||||
Else = Intrinsic::getOrInsertDeclaration(&M, Intrinsic::amdgcn_else,
|
||||
{IntMask, IntMask});
|
||||
IfBreak = Intrinsic::getOrInsertDeclaration(&M, Intrinsic::amdgcn_if_break,
|
||||
{IntMask});
|
||||
Loop =
|
||||
Intrinsic::getOrInsertDeclaration(&M, Intrinsic::amdgcn_loop, {IntMask});
|
||||
EndCf = Intrinsic::getOrInsertDeclaration(&M, Intrinsic::amdgcn_end_cf,
|
||||
{IntMask});
|
||||
}
|
||||
|
||||
/// Is the branch condition uniform or did the StructurizeCFG pass
|
||||
|
@ -21149,7 +21149,7 @@ Instruction *ARMTargetLowering::makeDMB(IRBuilderBase &Builder,
|
||||
// Thumb1 and pre-v6 ARM mode use a libcall instead and should never get
|
||||
// here.
|
||||
if (Subtarget->hasV6Ops() && !Subtarget->isThumb()) {
|
||||
Function *MCR = Intrinsic::getDeclaration(M, Intrinsic::arm_mcr);
|
||||
Function *MCR = Intrinsic::getOrInsertDeclaration(M, Intrinsic::arm_mcr);
|
||||
Value* args[6] = {Builder.getInt32(15), Builder.getInt32(0),
|
||||
Builder.getInt32(0), Builder.getInt32(7),
|
||||
Builder.getInt32(10), Builder.getInt32(5)};
|
||||
@ -21160,7 +21160,7 @@ Instruction *ARMTargetLowering::makeDMB(IRBuilderBase &Builder,
|
||||
llvm_unreachable("makeDMB on a target so old that it has no barriers");
|
||||
}
|
||||
} else {
|
||||
Function *DMB = Intrinsic::getDeclaration(M, Intrinsic::arm_dmb);
|
||||
Function *DMB = Intrinsic::getOrInsertDeclaration(M, Intrinsic::arm_dmb);
|
||||
// Only a full system barrier exists in the M-class architectures.
|
||||
Domain = Subtarget->isMClass() ? ARM_MB::SY : Domain;
|
||||
Constant *CDomain = Builder.getInt32(Domain);
|
||||
@ -21417,7 +21417,7 @@ Value *ARMTargetLowering::emitLoadLinked(IRBuilderBase &Builder, Type *ValueTy,
|
||||
if (ValueTy->getPrimitiveSizeInBits() == 64) {
|
||||
Intrinsic::ID Int =
|
||||
IsAcquire ? Intrinsic::arm_ldaexd : Intrinsic::arm_ldrexd;
|
||||
Function *Ldrex = Intrinsic::getDeclaration(M, Int);
|
||||
Function *Ldrex = Intrinsic::getOrInsertDeclaration(M, Int);
|
||||
|
||||
Value *LoHi = Builder.CreateCall(Ldrex, Addr, "lohi");
|
||||
|
||||
@ -21433,7 +21433,7 @@ Value *ARMTargetLowering::emitLoadLinked(IRBuilderBase &Builder, Type *ValueTy,
|
||||
|
||||
Type *Tys[] = { Addr->getType() };
|
||||
Intrinsic::ID Int = IsAcquire ? Intrinsic::arm_ldaex : Intrinsic::arm_ldrex;
|
||||
Function *Ldrex = Intrinsic::getDeclaration(M, Int, Tys);
|
||||
Function *Ldrex = Intrinsic::getOrInsertDeclaration(M, Int, Tys);
|
||||
CallInst *CI = Builder.CreateCall(Ldrex, Addr);
|
||||
|
||||
CI->addParamAttr(
|
||||
@ -21446,7 +21446,8 @@ void ARMTargetLowering::emitAtomicCmpXchgNoStoreLLBalance(
|
||||
if (!Subtarget->hasV7Ops())
|
||||
return;
|
||||
Module *M = Builder.GetInsertBlock()->getParent()->getParent();
|
||||
Builder.CreateCall(Intrinsic::getDeclaration(M, Intrinsic::arm_clrex));
|
||||
Builder.CreateCall(
|
||||
Intrinsic::getOrInsertDeclaration(M, Intrinsic::arm_clrex));
|
||||
}
|
||||
|
||||
Value *ARMTargetLowering::emitStoreConditional(IRBuilderBase &Builder,
|
||||
@ -21461,7 +21462,7 @@ Value *ARMTargetLowering::emitStoreConditional(IRBuilderBase &Builder,
|
||||
if (Val->getType()->getPrimitiveSizeInBits() == 64) {
|
||||
Intrinsic::ID Int =
|
||||
IsRelease ? Intrinsic::arm_stlexd : Intrinsic::arm_strexd;
|
||||
Function *Strex = Intrinsic::getDeclaration(M, Int);
|
||||
Function *Strex = Intrinsic::getOrInsertDeclaration(M, Int);
|
||||
Type *Int32Ty = Type::getInt32Ty(M->getContext());
|
||||
|
||||
Value *Lo = Builder.CreateTrunc(Val, Int32Ty, "lo");
|
||||
@ -21473,7 +21474,7 @@ Value *ARMTargetLowering::emitStoreConditional(IRBuilderBase &Builder,
|
||||
|
||||
Intrinsic::ID Int = IsRelease ? Intrinsic::arm_stlex : Intrinsic::arm_strex;
|
||||
Type *Tys[] = { Addr->getType() };
|
||||
Function *Strex = Intrinsic::getDeclaration(M, Int, Tys);
|
||||
Function *Strex = Intrinsic::getOrInsertDeclaration(M, Int, Tys);
|
||||
|
||||
CallInst *CI = Builder.CreateCall(
|
||||
Strex, {Builder.CreateZExtOrBitCast(
|
||||
@ -21601,8 +21602,8 @@ bool ARMTargetLowering::lowerInterleavedLoad(
|
||||
static const Intrinsic::ID LoadInts[3] = {Intrinsic::arm_neon_vld2,
|
||||
Intrinsic::arm_neon_vld3,
|
||||
Intrinsic::arm_neon_vld4};
|
||||
Function *VldnFunc =
|
||||
Intrinsic::getDeclaration(LI->getModule(), LoadInts[Factor - 2], Tys);
|
||||
Function *VldnFunc = Intrinsic::getOrInsertDeclaration(
|
||||
LI->getModule(), LoadInts[Factor - 2], Tys);
|
||||
|
||||
SmallVector<Value *, 2> Ops;
|
||||
Ops.push_back(BaseAddr);
|
||||
@ -21617,7 +21618,7 @@ bool ARMTargetLowering::lowerInterleavedLoad(
|
||||
Type *PtrTy = Builder.getPtrTy(LI->getPointerAddressSpace());
|
||||
Type *Tys[] = {VecTy, PtrTy};
|
||||
Function *VldnFunc =
|
||||
Intrinsic::getDeclaration(LI->getModule(), LoadInts, Tys);
|
||||
Intrinsic::getOrInsertDeclaration(LI->getModule(), LoadInts, Tys);
|
||||
|
||||
SmallVector<Value *, 2> Ops;
|
||||
Ops.push_back(BaseAddr);
|
||||
@ -21762,7 +21763,7 @@ bool ARMTargetLowering::lowerInterleavedStore(StoreInst *SI,
|
||||
Type *PtrTy = Builder.getPtrTy(SI->getPointerAddressSpace());
|
||||
Type *Tys[] = {PtrTy, SubVecTy};
|
||||
|
||||
Function *VstNFunc = Intrinsic::getDeclaration(
|
||||
Function *VstNFunc = Intrinsic::getOrInsertDeclaration(
|
||||
SI->getModule(), StoreInts[Factor - 2], Tys);
|
||||
|
||||
SmallVector<Value *, 6> Ops;
|
||||
@ -21778,7 +21779,7 @@ bool ARMTargetLowering::lowerInterleavedStore(StoreInst *SI,
|
||||
Type *PtrTy = Builder.getPtrTy(SI->getPointerAddressSpace());
|
||||
Type *Tys[] = {PtrTy, SubVecTy};
|
||||
Function *VstNFunc =
|
||||
Intrinsic::getDeclaration(SI->getModule(), StoreInts, Tys);
|
||||
Intrinsic::getOrInsertDeclaration(SI->getModule(), StoreInts, Tys);
|
||||
|
||||
SmallVector<Value *, 6> Ops;
|
||||
Ops.push_back(BaseAddr);
|
||||
|
@ -630,13 +630,14 @@ void ARMParallelDSP::InsertParallelMACs(Reduction &R) {
|
||||
Value* Args[] = { WideLd0, WideLd1, Acc };
|
||||
Function *SMLAD = nullptr;
|
||||
if (Exchange)
|
||||
SMLAD = Acc->getType()->isIntegerTy(32) ?
|
||||
Intrinsic::getDeclaration(M, Intrinsic::arm_smladx) :
|
||||
Intrinsic::getDeclaration(M, Intrinsic::arm_smlaldx);
|
||||
SMLAD =
|
||||
Acc->getType()->isIntegerTy(32)
|
||||
? Intrinsic::getOrInsertDeclaration(M, Intrinsic::arm_smladx)
|
||||
: Intrinsic::getOrInsertDeclaration(M, Intrinsic::arm_smlaldx);
|
||||
else
|
||||
SMLAD = Acc->getType()->isIntegerTy(32) ?
|
||||
Intrinsic::getDeclaration(M, Intrinsic::arm_smlad) :
|
||||
Intrinsic::getDeclaration(M, Intrinsic::arm_smlald);
|
||||
SMLAD = Acc->getType()->isIntegerTy(32)
|
||||
? Intrinsic::getOrInsertDeclaration(M, Intrinsic::arm_smlad)
|
||||
: Intrinsic::getOrInsertDeclaration(M, Intrinsic::arm_smlald);
|
||||
|
||||
IRBuilder<NoFolder> Builder(InsertAfter->getParent(),
|
||||
BasicBlock::iterator(InsertAfter));
|
||||
|
@ -401,7 +401,7 @@ void MVETailPredication::InsertVCTPIntrinsic(IntrinsicInst *ActiveLaneMask,
|
||||
case 8: VCTPID = Intrinsic::arm_mve_vctp16; break;
|
||||
case 16: VCTPID = Intrinsic::arm_mve_vctp8; break;
|
||||
}
|
||||
Function *VCTP = Intrinsic::getDeclaration(M, VCTPID);
|
||||
Function *VCTP = Intrinsic::getOrInsertDeclaration(M, VCTPID);
|
||||
Value *VCTPCall = Builder.CreateCall(VCTP, Processed);
|
||||
ActiveLaneMask->replaceAllUsesWith(VCTPCall);
|
||||
|
||||
|
@ -103,7 +103,7 @@ uint32_t BPFCoreSharedInfo::SeqNum;
|
||||
Instruction *BPFCoreSharedInfo::insertPassThrough(Module *M, BasicBlock *BB,
|
||||
Instruction *Input,
|
||||
Instruction *Before) {
|
||||
Function *Fn = Intrinsic::getDeclaration(
|
||||
Function *Fn = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::bpf_passthrough, {Input->getType(), Input->getType()});
|
||||
Constant *SeqNumVal = ConstantInt::get(Type::getInt32Ty(BB->getContext()),
|
||||
BPFCoreSharedInfo::SeqNum++);
|
||||
|
@ -126,7 +126,7 @@ bool BPFAdjustOptImpl::adjustICmpToBuiltin() {
|
||||
|
||||
Constant *Opcode =
|
||||
ConstantInt::get(Type::getInt32Ty(BB.getContext()), Op);
|
||||
Function *Fn = Intrinsic::getDeclaration(
|
||||
Function *Fn = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::bpf_compare, {Op0->getType(), ConstOp1->getType()});
|
||||
auto *NewInst = CallInst::Create(Fn, {Opcode, Op0, ConstOp1});
|
||||
NewInst->insertBefore(&I);
|
||||
|
@ -163,7 +163,7 @@ static CallInst *makeIntrinsicCall(Module *M,
|
||||
ArrayRef<Type *> Types,
|
||||
ArrayRef<Value *> Args) {
|
||||
|
||||
Function *Fn = Intrinsic::getDeclaration(M, Intrinsic, Types);
|
||||
Function *Fn = Intrinsic::getOrInsertDeclaration(M, Intrinsic, Types);
|
||||
return CallInst::Create(Fn, Args);
|
||||
}
|
||||
|
||||
|
@ -134,8 +134,8 @@ public:
|
||||
/// piecemeal way - we can add the casts in to avoid updating all of the uses
|
||||
/// or defs, and by the end all of the casts will be redundant.
|
||||
Value *createTmpHandleCast(Value *V, Type *Ty) {
|
||||
Function *CastFn = Intrinsic::getDeclaration(&M, Intrinsic::dx_cast_handle,
|
||||
{Ty, V->getType()});
|
||||
Function *CastFn = Intrinsic::getOrInsertDeclaration(
|
||||
&M, Intrinsic::dx_cast_handle, {Ty, V->getType()});
|
||||
CallInst *Cast = OpBuilder.getIRB().CreateCall(CastFn, {V});
|
||||
CleanupCasts.push_back(Cast);
|
||||
return Cast;
|
||||
|
@ -212,7 +212,7 @@ bool HexagonGenExtract::convert(Instruction *In) {
|
||||
Intrinsic::ID IntId = (BW == 32) ? Intrinsic::hexagon_S2_extractu
|
||||
: Intrinsic::hexagon_S2_extractup;
|
||||
Module *Mod = BB->getParent()->getParent();
|
||||
Function *ExtF = Intrinsic::getDeclaration(Mod, IntId);
|
||||
Function *ExtF = Intrinsic::getOrInsertDeclaration(Mod, IntId);
|
||||
Value *NewIn = IRB.CreateCall(ExtF, {BF, IRB.getInt32(W), IRB.getInt32(SR)});
|
||||
if (SL != 0)
|
||||
NewIn = IRB.CreateShl(NewIn, SL, CSL->getName());
|
||||
|
@ -3865,7 +3865,7 @@ Value *HexagonTargetLowering::emitLoadLinked(IRBuilderBase &Builder,
|
||||
assert((SZ == 32 || SZ == 64) && "Only 32/64-bit atomic loads supported");
|
||||
Intrinsic::ID IntID = (SZ == 32) ? Intrinsic::hexagon_L2_loadw_locked
|
||||
: Intrinsic::hexagon_L4_loadd_locked;
|
||||
Function *Fn = Intrinsic::getDeclaration(M, IntID);
|
||||
Function *Fn = Intrinsic::getOrInsertDeclaration(M, IntID);
|
||||
|
||||
Value *Call = Builder.CreateCall(Fn, Addr, "larx");
|
||||
|
||||
@ -3886,7 +3886,7 @@ Value *HexagonTargetLowering::emitStoreConditional(IRBuilderBase &Builder,
|
||||
assert((SZ == 32 || SZ == 64) && "Only 32/64-bit atomic stores supported");
|
||||
Intrinsic::ID IntID = (SZ == 32) ? Intrinsic::hexagon_S2_storew_locked
|
||||
: Intrinsic::hexagon_S4_stored_locked;
|
||||
Function *Fn = Intrinsic::getDeclaration(M, IntID);
|
||||
Function *Fn = Intrinsic::getOrInsertDeclaration(M, IntID);
|
||||
|
||||
Val = Builder.CreateBitCast(Val, CastTy);
|
||||
|
||||
|
@ -1532,7 +1532,8 @@ Value *PolynomialMultiplyRecognize::generate(BasicBlock::iterator At,
|
||||
ParsedValues &PV) {
|
||||
IRBuilder<> B(&*At);
|
||||
Module *M = At->getParent()->getParent()->getParent();
|
||||
Function *PMF = Intrinsic::getDeclaration(M, Intrinsic::hexagon_M4_pmpyw);
|
||||
Function *PMF =
|
||||
Intrinsic::getOrInsertDeclaration(M, Intrinsic::hexagon_M4_pmpyw);
|
||||
|
||||
Value *P = PV.P, *Q = PV.Q, *P0 = P;
|
||||
unsigned IC = PV.IterCount;
|
||||
|
@ -2390,8 +2390,8 @@ auto HexagonVectorCombine::vralignb(IRBuilderBase &Builder, Value *Lo,
|
||||
Type *Int64Ty = Type::getInt64Ty(F.getContext());
|
||||
Value *Lo64 = Builder.CreateBitCast(Lo, Int64Ty, "cst");
|
||||
Value *Hi64 = Builder.CreateBitCast(Hi, Int64Ty, "cst");
|
||||
Function *FI = Intrinsic::getDeclaration(F.getParent(),
|
||||
Intrinsic::hexagon_S2_valignrb);
|
||||
Function *FI = Intrinsic::getOrInsertDeclaration(
|
||||
F.getParent(), Intrinsic::hexagon_S2_valignrb);
|
||||
Value *Call = Builder.CreateCall(FI, {Hi64, Lo64, Amt}, "cup");
|
||||
return Builder.CreateBitCast(Call, Lo->getType(), "cst");
|
||||
}
|
||||
@ -2587,12 +2587,13 @@ auto HexagonVectorCombine::createHvxIntrinsic(IRBuilderBase &Builder,
|
||||
unsigned HwLen = HST.getVectorLength();
|
||||
Intrinsic::ID TC = HwLen == 64 ? Intrinsic::hexagon_V6_pred_typecast
|
||||
: Intrinsic::hexagon_V6_pred_typecast_128B;
|
||||
Function *FI =
|
||||
Intrinsic::getDeclaration(F.getParent(), TC, {DestTy, Val->getType()});
|
||||
Function *FI = Intrinsic::getOrInsertDeclaration(F.getParent(), TC,
|
||||
{DestTy, Val->getType()});
|
||||
return Builder.CreateCall(FI, {Val}, "cup");
|
||||
};
|
||||
|
||||
Function *IntrFn = Intrinsic::getDeclaration(F.getParent(), IntID, ArgTys);
|
||||
Function *IntrFn =
|
||||
Intrinsic::getOrInsertDeclaration(F.getParent(), IntID, ArgTys);
|
||||
FunctionType *IntrTy = IntrFn->getFunctionType();
|
||||
|
||||
SmallVector<Value *, 4> IntrArgs;
|
||||
|
@ -5808,7 +5808,7 @@ Value *LoongArchTargetLowering::emitMaskedAtomicCmpXchgIntrinsic(
|
||||
Mask = Builder.CreateSExt(Mask, Builder.getInt64Ty());
|
||||
Type *Tys[] = {AlignedAddr->getType()};
|
||||
Function *MaskedCmpXchg =
|
||||
Intrinsic::getDeclaration(CI->getModule(), CmpXchgIntrID, Tys);
|
||||
Intrinsic::getOrInsertDeclaration(CI->getModule(), CmpXchgIntrID, Tys);
|
||||
Value *Result = Builder.CreateCall(
|
||||
MaskedCmpXchg, {AlignedAddr, CmpVal, NewVal, Mask, FailureOrdering});
|
||||
Result = Builder.CreateTrunc(Result, Builder.getInt32Ty());
|
||||
@ -5838,7 +5838,7 @@ Value *LoongArchTargetLowering::emitMaskedAtomicRMWIntrinsic(
|
||||
Value *Ordering =
|
||||
Builder.getIntN(GRLen, static_cast<uint64_t>(AI->getOrdering()));
|
||||
Type *Tys[] = {AlignedAddr->getType()};
|
||||
Function *LlwOpScwLoop = Intrinsic::getDeclaration(
|
||||
Function *LlwOpScwLoop = Intrinsic::getOrInsertDeclaration(
|
||||
AI->getModule(),
|
||||
getIntrinsicForMaskedAtomicRMWBinOp(GRLen, AI->getOperation()), Tys);
|
||||
|
||||
|
@ -282,7 +282,7 @@ static void convertToParamAS(Use *OldUse, Value *Param, bool HasCvtaParam,
|
||||
[](Value *Addr, Instruction *OriginalUser) -> Value * {
|
||||
PointerType *ReturnTy =
|
||||
PointerType::get(OriginalUser->getContext(), ADDRESS_SPACE_GENERIC);
|
||||
Function *CvtToGen = Intrinsic::getDeclaration(
|
||||
Function *CvtToGen = Intrinsic::getOrInsertDeclaration(
|
||||
OriginalUser->getModule(), Intrinsic::nvvm_ptr_param_to_gen,
|
||||
{ReturnTy, PointerType::get(OriginalUser->getContext(),
|
||||
ADDRESS_SPACE_PARAM)});
|
||||
|
@ -360,7 +360,8 @@ static Instruction *simplifyNvvmIntrinsic(IntrinsicInst *II, InstCombiner &IC) {
|
||||
// type argument, equal to that of the nvvm intrinsic's argument.
|
||||
Type *Tys[] = {II->getArgOperand(0)->getType()};
|
||||
return CallInst::Create(
|
||||
Intrinsic::getDeclaration(II->getModule(), *Action.IID, Tys), Args);
|
||||
Intrinsic::getOrInsertDeclaration(II->getModule(), *Action.IID, Tys),
|
||||
Args);
|
||||
}
|
||||
|
||||
// Simplify to target-generic binary op.
|
||||
|
@ -12181,7 +12181,7 @@ void PPCTargetLowering::ReplaceNodeResults(SDNode *N,
|
||||
|
||||
static Instruction *callIntrinsic(IRBuilderBase &Builder, Intrinsic::ID Id) {
|
||||
Module *M = Builder.GetInsertBlock()->getParent()->getParent();
|
||||
Function *Func = Intrinsic::getDeclaration(M, Id);
|
||||
Function *Func = Intrinsic::getOrInsertDeclaration(M, Id);
|
||||
return Builder.CreateCall(Func, {});
|
||||
}
|
||||
|
||||
@ -12206,7 +12206,7 @@ Instruction *PPCTargetLowering::emitTrailingFence(IRBuilderBase &Builder,
|
||||
// and http://www.cl.cam.ac.uk/~pes20/cppppc/ for justification.
|
||||
if (isa<LoadInst>(Inst))
|
||||
return Builder.CreateCall(
|
||||
Intrinsic::getDeclaration(
|
||||
Intrinsic::getOrInsertDeclaration(
|
||||
Builder.GetInsertBlock()->getParent()->getParent(),
|
||||
Intrinsic::ppc_cfence, {Inst->getType()}),
|
||||
{Inst});
|
||||
@ -19005,7 +19005,7 @@ Value *PPCTargetLowering::emitMaskedAtomicRMWIntrinsic(
|
||||
Module *M = Builder.GetInsertBlock()->getParent()->getParent();
|
||||
Type *ValTy = Incr->getType();
|
||||
assert(ValTy->getPrimitiveSizeInBits() == 128);
|
||||
Function *RMW = Intrinsic::getDeclaration(
|
||||
Function *RMW = Intrinsic::getOrInsertDeclaration(
|
||||
M, getIntrinsicForAtomicRMWBinOp128(AI->getOperation()));
|
||||
Type *Int64Ty = Type::getInt64Ty(M->getContext());
|
||||
Value *IncrLo = Builder.CreateTrunc(Incr, Int64Ty, "incr_lo");
|
||||
@ -19028,7 +19028,7 @@ Value *PPCTargetLowering::emitMaskedAtomicCmpXchgIntrinsic(
|
||||
Type *ValTy = CmpVal->getType();
|
||||
assert(ValTy->getPrimitiveSizeInBits() == 128);
|
||||
Function *IntCmpXchg =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::ppc_cmpxchg_i128);
|
||||
Intrinsic::getOrInsertDeclaration(M, Intrinsic::ppc_cmpxchg_i128);
|
||||
Type *Int64Ty = Type::getInt64Ty(M->getContext());
|
||||
Value *CmpLo = Builder.CreateTrunc(CmpVal, Int64Ty, "cmp_lo");
|
||||
Value *CmpHi =
|
||||
|
@ -123,7 +123,7 @@ bool PPCLowerMASSVEntries::handlePowSpecialCases(CallInst *CI, Function &Func,
|
||||
return false;
|
||||
|
||||
CI->setCalledFunction(
|
||||
Intrinsic::getDeclaration(&M, Intrinsic::pow, CI->getType()));
|
||||
Intrinsic::getOrInsertDeclaration(&M, Intrinsic::pow, CI->getType()));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -20608,7 +20608,7 @@ Value *RISCVTargetLowering::emitMaskedAtomicRMWIntrinsic(
|
||||
Value *Ordering =
|
||||
Builder.getIntN(XLen, static_cast<uint64_t>(AI->getOrdering()));
|
||||
Type *Tys[] = {AlignedAddr->getType()};
|
||||
Function *LrwOpScwLoop = Intrinsic::getDeclaration(
|
||||
Function *LrwOpScwLoop = Intrinsic::getOrInsertDeclaration(
|
||||
AI->getModule(),
|
||||
getIntrinsicForMaskedAtomicRMWBinOp(XLen, AI->getOperation()), Tys);
|
||||
|
||||
@ -20672,7 +20672,7 @@ Value *RISCVTargetLowering::emitMaskedAtomicCmpXchgIntrinsic(
|
||||
}
|
||||
Type *Tys[] = {AlignedAddr->getType()};
|
||||
Function *MaskedCmpXchg =
|
||||
Intrinsic::getDeclaration(CI->getModule(), CmpXchgIntrID, Tys);
|
||||
Intrinsic::getOrInsertDeclaration(CI->getModule(), CmpXchgIntrID, Tys);
|
||||
Value *Result = Builder.CreateCall(
|
||||
MaskedCmpXchg, {AlignedAddr, CmpVal, NewVal, Mask, Ordering});
|
||||
if (XLen == 64)
|
||||
@ -21170,7 +21170,7 @@ bool RISCVTargetLowering::preferScalarizeSplat(SDNode *N) const {
|
||||
static Value *useTpOffset(IRBuilderBase &IRB, unsigned Offset) {
|
||||
Module *M = IRB.GetInsertBlock()->getModule();
|
||||
Function *ThreadPointerFunc =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::thread_pointer);
|
||||
Intrinsic::getOrInsertDeclaration(M, Intrinsic::thread_pointer);
|
||||
return IRB.CreateConstGEP1_32(IRB.getInt8Ty(),
|
||||
IRB.CreateCall(ThreadPointerFunc), Offset);
|
||||
}
|
||||
@ -21287,9 +21287,9 @@ bool RISCVTargetLowering::lowerInterleavedLoad(
|
||||
|
||||
auto *XLenTy = Type::getIntNTy(LI->getContext(), Subtarget.getXLen());
|
||||
|
||||
Function *VlsegNFunc =
|
||||
Intrinsic::getDeclaration(LI->getModule(), FixedVlsegIntrIds[Factor - 2],
|
||||
{VTy, LI->getPointerOperandType(), XLenTy});
|
||||
Function *VlsegNFunc = Intrinsic::getOrInsertDeclaration(
|
||||
LI->getModule(), FixedVlsegIntrIds[Factor - 2],
|
||||
{VTy, LI->getPointerOperandType(), XLenTy});
|
||||
|
||||
Value *VL = ConstantInt::get(XLenTy, VTy->getNumElements());
|
||||
|
||||
@ -21341,9 +21341,9 @@ bool RISCVTargetLowering::lowerInterleavedStore(StoreInst *SI,
|
||||
|
||||
auto *XLenTy = Type::getIntNTy(SI->getContext(), Subtarget.getXLen());
|
||||
|
||||
Function *VssegNFunc =
|
||||
Intrinsic::getDeclaration(SI->getModule(), FixedVssegIntrIds[Factor - 2],
|
||||
{VTy, SI->getPointerOperandType(), XLenTy});
|
||||
Function *VssegNFunc = Intrinsic::getOrInsertDeclaration(
|
||||
SI->getModule(), FixedVssegIntrIds[Factor - 2],
|
||||
{VTy, SI->getPointerOperandType(), XLenTy});
|
||||
|
||||
auto Mask = SVI->getShuffleMask();
|
||||
SmallVector<Value *, 10> Ops;
|
||||
@ -21388,7 +21388,7 @@ bool RISCVTargetLowering::lowerDeinterleaveIntrinsicToLoad(
|
||||
Type *XLenTy = Type::getIntNTy(LI->getContext(), Subtarget.getXLen());
|
||||
|
||||
if (auto *FVTy = dyn_cast<FixedVectorType>(ResVTy)) {
|
||||
Function *VlsegNFunc = Intrinsic::getDeclaration(
|
||||
Function *VlsegNFunc = Intrinsic::getOrInsertDeclaration(
|
||||
LI->getModule(), FixedVlsegIntrIds[Factor - 2],
|
||||
{ResVTy, LI->getPointerOperandType(), XLenTy});
|
||||
Value *VL = ConstantInt::get(XLenTy, FVTy->getNumElements());
|
||||
@ -21408,7 +21408,7 @@ bool RISCVTargetLowering::lowerDeinterleaveIntrinsicToLoad(
|
||||
NumElts * SEW / 8),
|
||||
Factor);
|
||||
|
||||
Function *VlsegNFunc = Intrinsic::getDeclaration(
|
||||
Function *VlsegNFunc = Intrinsic::getOrInsertDeclaration(
|
||||
LI->getModule(), IntrIds[Factor - 2], {VecTupTy, XLenTy});
|
||||
Value *VL = Constant::getAllOnesValue(XLenTy);
|
||||
|
||||
@ -21418,7 +21418,7 @@ bool RISCVTargetLowering::lowerDeinterleaveIntrinsicToLoad(
|
||||
|
||||
SmallVector<Type *, 2> AggrTypes{Factor, ResVTy};
|
||||
Return = PoisonValue::get(StructType::get(LI->getContext(), AggrTypes));
|
||||
Function *VecExtractFunc = Intrinsic::getDeclaration(
|
||||
Function *VecExtractFunc = Intrinsic::getOrInsertDeclaration(
|
||||
LI->getModule(), Intrinsic::riscv_tuple_extract, {ResVTy, VecTupTy});
|
||||
for (unsigned i = 0; i < Factor; ++i) {
|
||||
Value *VecExtract =
|
||||
@ -21454,7 +21454,7 @@ bool RISCVTargetLowering::lowerInterleaveIntrinsicToStore(
|
||||
Type *XLenTy = Type::getIntNTy(SI->getContext(), Subtarget.getXLen());
|
||||
|
||||
if (auto *FVTy = dyn_cast<FixedVectorType>(InVTy)) {
|
||||
Function *VssegNFunc = Intrinsic::getDeclaration(
|
||||
Function *VssegNFunc = Intrinsic::getOrInsertDeclaration(
|
||||
SI->getModule(), FixedVssegIntrIds[Factor - 2],
|
||||
{InVTy, SI->getPointerOperandType(), XLenTy});
|
||||
Value *VL = ConstantInt::get(XLenTy, FVTy->getNumElements());
|
||||
@ -21475,12 +21475,12 @@ bool RISCVTargetLowering::lowerInterleaveIntrinsicToStore(
|
||||
NumElts * SEW / 8),
|
||||
Factor);
|
||||
|
||||
Function *VssegNFunc = Intrinsic::getDeclaration(
|
||||
Function *VssegNFunc = Intrinsic::getOrInsertDeclaration(
|
||||
SI->getModule(), IntrIds[Factor - 2], {VecTupTy, XLenTy});
|
||||
|
||||
Value *VL = Constant::getAllOnesValue(XLenTy);
|
||||
|
||||
Function *VecInsertFunc = Intrinsic::getDeclaration(
|
||||
Function *VecInsertFunc = Intrinsic::getOrInsertDeclaration(
|
||||
SI->getModule(), Intrinsic::riscv_tuple_insert, {VecTupTy, InVTy});
|
||||
Value *StoredVal = PoisonValue::get(VecTupTy);
|
||||
for (unsigned i = 0; i < Factor; ++i)
|
||||
|
@ -353,11 +353,11 @@ static void lowerExpectAssume(IntrinsicInst *II) {
|
||||
// We need to lower this into a builtin and then the builtin into a SPIR-V
|
||||
// instruction.
|
||||
if (II->getIntrinsicID() == Intrinsic::assume) {
|
||||
Function *F = Intrinsic::getDeclaration(
|
||||
Function *F = Intrinsic::getOrInsertDeclaration(
|
||||
II->getModule(), Intrinsic::SPVIntrinsics::spv_assume);
|
||||
II->setCalledFunction(F);
|
||||
} else if (II->getIntrinsicID() == Intrinsic::expect) {
|
||||
Function *F = Intrinsic::getDeclaration(
|
||||
Function *F = Intrinsic::getOrInsertDeclaration(
|
||||
II->getModule(), Intrinsic::SPVIntrinsics::spv_expect,
|
||||
{II->getOperand(0)->getType()});
|
||||
II->setCalledFunction(F);
|
||||
@ -372,12 +372,12 @@ static bool toSpvOverloadedIntrinsic(IntrinsicInst *II, Intrinsic::ID NewID,
|
||||
ArrayRef<unsigned> OpNos) {
|
||||
Function *F = nullptr;
|
||||
if (OpNos.empty()) {
|
||||
F = Intrinsic::getDeclaration(II->getModule(), NewID);
|
||||
F = Intrinsic::getOrInsertDeclaration(II->getModule(), NewID);
|
||||
} else {
|
||||
SmallVector<Type *, 4> Tys;
|
||||
for (unsigned OpNo : OpNos)
|
||||
Tys.push_back(II->getOperand(OpNo)->getType());
|
||||
F = Intrinsic::getDeclaration(II->getModule(), NewID, Tys);
|
||||
F = Intrinsic::getOrInsertDeclaration(II->getModule(), NewID, Tys);
|
||||
}
|
||||
II->setCalledFunction(F);
|
||||
return true;
|
||||
|
@ -366,8 +366,8 @@ bool SystemZTDCPass::runOnFunction(Function &F) {
|
||||
if (!Worthy)
|
||||
continue;
|
||||
// Call the intrinsic, compare result with 0.
|
||||
Function *TDCFunc =
|
||||
Intrinsic::getDeclaration(&M, Intrinsic::s390_tdc, V->getType());
|
||||
Function *TDCFunc = Intrinsic::getOrInsertDeclaration(
|
||||
&M, Intrinsic::s390_tdc, V->getType());
|
||||
IRBuilder<> IRB(I);
|
||||
Value *MaskVal = ConstantInt::get(Type::getInt64Ty(Ctx), Mask);
|
||||
Instruction *TDC = IRB.CreateCall(TDCFunc, {V, MaskVal});
|
||||
|
@ -1016,7 +1016,7 @@ bool WebAssemblyLowerEmscriptenEHSjLj::runOnModule(Module &M) {
|
||||
|
||||
// wasm.catch() will be lowered down to wasm 'catch' instruction in
|
||||
// instruction selection.
|
||||
CatchF = Intrinsic::getDeclaration(&M, Intrinsic::wasm_catch);
|
||||
CatchF = Intrinsic::getOrInsertDeclaration(&M, Intrinsic::wasm_catch);
|
||||
// Type for struct __WasmLongjmpArgs
|
||||
LongjmpArgsTy = StructType::get(Int8PtrTy, // env
|
||||
Int32Ty // val
|
||||
|
@ -72,7 +72,7 @@ bool WebAssemblyLowerRefTypesIntPtrConv::runOnFunction(Function &F) {
|
||||
I->replaceAllUsesWith(U);
|
||||
|
||||
Function *TrapIntrin =
|
||||
Intrinsic::getDeclaration(F.getParent(), Intrinsic::debugtrap);
|
||||
Intrinsic::getOrInsertDeclaration(F.getParent(), Intrinsic::debugtrap);
|
||||
CallInst::Create(TrapIntrin, {}, "", I->getIterator());
|
||||
|
||||
worklist.insert(&*I);
|
||||
|
@ -31163,12 +31163,14 @@ void X86TargetLowering::emitBitTestAtomicRMWIntrinsic(AtomicRMWInst *AI) const {
|
||||
if (BitTested.second == ConstantBit || BitTested.second == NotConstantBit) {
|
||||
auto *C = cast<ConstantInt>(I->getOperand(I->getOperand(0) == AI ? 1 : 0));
|
||||
|
||||
BitTest = Intrinsic::getDeclaration(AI->getModule(), IID_C, AI->getType());
|
||||
BitTest = Intrinsic::getOrInsertDeclaration(AI->getModule(), IID_C,
|
||||
AI->getType());
|
||||
|
||||
unsigned Imm = llvm::countr_zero(C->getZExtValue());
|
||||
Result = Builder.CreateCall(BitTest, {Addr, Builder.getInt8(Imm)});
|
||||
} else {
|
||||
BitTest = Intrinsic::getDeclaration(AI->getModule(), IID_I, AI->getType());
|
||||
BitTest = Intrinsic::getOrInsertDeclaration(AI->getModule(), IID_I,
|
||||
AI->getType());
|
||||
|
||||
assert(BitTested.second == ShiftBit || BitTested.second == NotShiftBit);
|
||||
|
||||
@ -31328,7 +31330,7 @@ void X86TargetLowering::emitCmpArithAtomicRMWIntrinsic(
|
||||
break;
|
||||
}
|
||||
Function *CmpArith =
|
||||
Intrinsic::getDeclaration(AI->getModule(), IID, AI->getType());
|
||||
Intrinsic::getOrInsertDeclaration(AI->getModule(), IID, AI->getType());
|
||||
Value *Addr = Builder.CreatePointerCast(AI->getPointerOperand(),
|
||||
PointerType::getUnqual(Ctx));
|
||||
Value *Call = Builder.CreateCall(
|
||||
@ -31444,7 +31446,7 @@ X86TargetLowering::lowerIdempotentRMWIntoFencedLoad(AtomicRMWInst *AI) const {
|
||||
return nullptr;
|
||||
|
||||
Function *MFence =
|
||||
llvm::Intrinsic::getDeclaration(M, Intrinsic::x86_sse2_mfence);
|
||||
llvm::Intrinsic::getOrInsertDeclaration(M, Intrinsic::x86_sse2_mfence);
|
||||
Builder.CreateCall(MFence, {});
|
||||
|
||||
// Finally we can emit the atomic load.
|
||||
|
@ -1876,7 +1876,8 @@ static Value *simplifyX86extrq(IntrinsicInst &II, Value *Op0,
|
||||
if (II.getIntrinsicID() == Intrinsic::x86_sse4a_extrq) {
|
||||
Value *Args[] = {Op0, CILength, CIIndex};
|
||||
Module *M = II.getModule();
|
||||
Function *F = Intrinsic::getDeclaration(M, Intrinsic::x86_sse4a_extrqi);
|
||||
Function *F =
|
||||
Intrinsic::getOrInsertDeclaration(M, Intrinsic::x86_sse4a_extrqi);
|
||||
return Builder.CreateCall(F, Args);
|
||||
}
|
||||
}
|
||||
@ -1975,7 +1976,8 @@ static Value *simplifyX86insertq(IntrinsicInst &II, Value *Op0, Value *Op1,
|
||||
|
||||
Value *Args[] = {Op0, Op1, CILength, CIIndex};
|
||||
Module *M = II.getModule();
|
||||
Function *F = Intrinsic::getDeclaration(M, Intrinsic::x86_sse4a_insertqi);
|
||||
Function *F =
|
||||
Intrinsic::getOrInsertDeclaration(M, Intrinsic::x86_sse4a_insertqi);
|
||||
return Builder.CreateCall(F, Args);
|
||||
}
|
||||
|
||||
|
@ -278,7 +278,7 @@ bool X86PartialReduction::trySADReplacement(Instruction *Op) {
|
||||
IntrinsicNumElts = 16;
|
||||
}
|
||||
|
||||
Function *PSADBWFn = Intrinsic::getDeclaration(Op->getModule(), IID);
|
||||
Function *PSADBWFn = Intrinsic::getOrInsertDeclaration(Op->getModule(), IID);
|
||||
|
||||
if (NumElts < 16) {
|
||||
// Pad input with zeroes.
|
||||
|
@ -334,7 +334,7 @@ void WinEHStatePass::emitExceptionRegistrationRecord(Function *F) {
|
||||
if (UseStackGuard) {
|
||||
Value *Val = Builder.CreateLoad(Int32Ty, Cookie);
|
||||
Value *FrameAddr = Builder.CreateCall(
|
||||
Intrinsic::getDeclaration(
|
||||
Intrinsic::getOrInsertDeclaration(
|
||||
TheModule, Intrinsic::frameaddress,
|
||||
Builder.getPtrTy(
|
||||
TheModule->getDataLayout().getAllocaAddrSpace())),
|
||||
@ -370,7 +370,7 @@ void WinEHStatePass::emitExceptionRegistrationRecord(Function *F) {
|
||||
|
||||
Value *WinEHStatePass::emitEHLSDA(IRBuilder<> &Builder, Function *F) {
|
||||
return Builder.CreateCall(
|
||||
Intrinsic::getDeclaration(TheModule, Intrinsic::x86_seh_lsda), F);
|
||||
Intrinsic::getOrInsertDeclaration(TheModule, Intrinsic::x86_seh_lsda), F);
|
||||
}
|
||||
|
||||
/// Generate a thunk that puts the LSDA of ParentFunc in EAX and then calls
|
||||
@ -624,17 +624,17 @@ void WinEHStatePass::addStateStores(Function &F, WinEHFuncInfo &FuncInfo) {
|
||||
// that it can recover the original frame pointer.
|
||||
IRBuilder<> Builder(RegNode->getNextNode());
|
||||
Value *RegNodeI8 = Builder.CreateBitCast(RegNode, Builder.getPtrTy());
|
||||
Builder.CreateCall(
|
||||
Intrinsic::getDeclaration(TheModule, Intrinsic::x86_seh_ehregnode),
|
||||
{RegNodeI8});
|
||||
Builder.CreateCall(Intrinsic::getOrInsertDeclaration(
|
||||
TheModule, Intrinsic::x86_seh_ehregnode),
|
||||
{RegNodeI8});
|
||||
|
||||
if (EHGuardNode) {
|
||||
IRBuilder<> Builder(EHGuardNode->getNextNode());
|
||||
Value *EHGuardNodeI8 =
|
||||
Builder.CreateBitCast(EHGuardNode, Builder.getPtrTy());
|
||||
Builder.CreateCall(
|
||||
Intrinsic::getDeclaration(TheModule, Intrinsic::x86_seh_ehguard),
|
||||
{EHGuardNodeI8});
|
||||
Builder.CreateCall(Intrinsic::getOrInsertDeclaration(
|
||||
TheModule, Intrinsic::x86_seh_ehguard),
|
||||
{EHGuardNodeI8});
|
||||
}
|
||||
|
||||
// Calculate state numbers.
|
||||
|
@ -157,8 +157,8 @@ bool XCoreLowerThreadLocal::lowerGlobal(GlobalVariable *GV) {
|
||||
for (User *U : Users) {
|
||||
Instruction *Inst = cast<Instruction>(U);
|
||||
IRBuilder<> Builder(Inst);
|
||||
Function *GetID = Intrinsic::getDeclaration(GV->getParent(),
|
||||
Intrinsic::xcore_getid);
|
||||
Function *GetID = Intrinsic::getOrInsertDeclaration(GV->getParent(),
|
||||
Intrinsic::xcore_getid);
|
||||
Value *ThreadID = Builder.CreateCall(GetID, {});
|
||||
Value *Addr = Builder.CreateInBoundsGEP(NewGV->getValueType(), NewGV,
|
||||
{Builder.getInt64(0), ThreadID});
|
||||
|
@ -172,7 +172,8 @@ static bool foldGuardedFunnelShift(Instruction &I, const DominatorTree &DT) {
|
||||
// %cond = phi i32 [ %fsh, %FunnelBB ], [ %ShVal0, %GuardBB ]
|
||||
// -->
|
||||
// llvm.fshl.i32(i32 %ShVal0, i32 %ShVal1, i32 %ShAmt)
|
||||
Function *F = Intrinsic::getDeclaration(Phi.getModule(), IID, Phi.getType());
|
||||
Function *F =
|
||||
Intrinsic::getOrInsertDeclaration(Phi.getModule(), IID, Phi.getType());
|
||||
Phi.replaceAllUsesWith(Builder.CreateCall(F, {ShVal0, ShVal1, ShAmt}));
|
||||
return true;
|
||||
}
|
||||
@ -331,7 +332,7 @@ static bool tryToRecognizePopCount(Instruction &I) {
|
||||
m_SpecificInt(Mask55)))) {
|
||||
LLVM_DEBUG(dbgs() << "Recognized popcount intrinsic\n");
|
||||
IRBuilder<> Builder(&I);
|
||||
Function *Func = Intrinsic::getDeclaration(
|
||||
Function *Func = Intrinsic::getOrInsertDeclaration(
|
||||
I.getModule(), Intrinsic::ctpop, I.getType());
|
||||
I.replaceAllUsesWith(Builder.CreateCall(Func, {Root}));
|
||||
++NumPopCountRecognized;
|
||||
@ -398,8 +399,8 @@ static bool tryToFPToSat(Instruction &I, TargetTransformInfo &TTI) {
|
||||
return false;
|
||||
|
||||
IRBuilder<> Builder(&I);
|
||||
Function *Fn = Intrinsic::getDeclaration(I.getModule(), Intrinsic::fptosi_sat,
|
||||
{SatTy, FpTy});
|
||||
Function *Fn = Intrinsic::getOrInsertDeclaration(
|
||||
I.getModule(), Intrinsic::fptosi_sat, {SatTy, FpTy});
|
||||
Value *Sat = Builder.CreateCall(Fn, In);
|
||||
I.replaceAllUsesWith(Builder.CreateSExt(Sat, IntTy));
|
||||
return true;
|
||||
@ -431,7 +432,7 @@ static bool foldSqrt(CallInst *Call, LibFunc Func, TargetTransformInfo &TTI,
|
||||
IRBuilderBase::FastMathFlagGuard Guard(Builder);
|
||||
Builder.setFastMathFlags(Call->getFastMathFlags());
|
||||
|
||||
Function *Sqrt = Intrinsic::getDeclaration(M, Intrinsic::sqrt, Ty);
|
||||
Function *Sqrt = Intrinsic::getOrInsertDeclaration(M, Intrinsic::sqrt, Ty);
|
||||
Value *NewSqrt = Builder.CreateCall(Sqrt, Arg, "sqrt");
|
||||
Call->replaceAllUsesWith(NewSqrt);
|
||||
|
||||
|
@ -52,7 +52,8 @@ coro::LowererBase::LowererBase(Module &M)
|
||||
CallInst *coro::LowererBase::makeSubFnCall(Value *Arg, int Index,
|
||||
Instruction *InsertPt) {
|
||||
auto *IndexVal = ConstantInt::get(Type::getInt8Ty(Context), Index);
|
||||
auto *Fn = Intrinsic::getDeclaration(&TheModule, Intrinsic::coro_subfn_addr);
|
||||
auto *Fn =
|
||||
Intrinsic::getOrInsertDeclaration(&TheModule, Intrinsic::coro_subfn_addr);
|
||||
|
||||
assert(Index >= CoroSubFnInst::IndexFirst &&
|
||||
Index < CoroSubFnInst::IndexLast &&
|
||||
@ -183,7 +184,7 @@ void coro::suppressCoroAllocs(LLVMContext &Context,
|
||||
static CoroSaveInst *createCoroSave(CoroBeginInst *CoroBegin,
|
||||
CoroSuspendInst *SuspendInst) {
|
||||
Module *M = SuspendInst->getModule();
|
||||
auto *Fn = Intrinsic::getDeclaration(M, Intrinsic::coro_save);
|
||||
auto *Fn = Intrinsic::getOrInsertDeclaration(M, Intrinsic::coro_save);
|
||||
auto *SaveInst = cast<CoroSaveInst>(
|
||||
CallInst::Create(Fn, CoroBegin, "", SuspendInst->getIterator()));
|
||||
assert(!SuspendInst->getCoroSave());
|
||||
|
@ -125,7 +125,8 @@ void CrossDSOCFI::buildCFICheck(Module &M) {
|
||||
ConstantInt *CaseTypeId = ConstantInt::get(Type::getInt64Ty(Ctx), TypeId);
|
||||
BasicBlock *TestBB = BasicBlock::Create(Ctx, "test", F);
|
||||
IRBuilder<> IRBTest(TestBB);
|
||||
Function *BitsetTestFn = Intrinsic::getDeclaration(&M, Intrinsic::type_test);
|
||||
Function *BitsetTestFn =
|
||||
Intrinsic::getOrInsertDeclaration(&M, Intrinsic::type_test);
|
||||
|
||||
Value *Test = IRBTest.CreateCall(
|
||||
BitsetTestFn, {&Addr, MetadataAsValue::get(
|
||||
|
@ -401,7 +401,7 @@ void SampleProfileProber::instrumentOneFunc(Function &F, TargetMachine *TM) {
|
||||
assert(Builder.GetInsertPoint() != BB->end() &&
|
||||
"Cannot get the probing point");
|
||||
Function *ProbeFn =
|
||||
llvm::Intrinsic::getDeclaration(M, Intrinsic::pseudoprobe);
|
||||
llvm::Intrinsic::getOrInsertDeclaration(M, Intrinsic::pseudoprobe);
|
||||
Value *Args[] = {Builder.getInt64(Guid), Builder.getInt64(Index),
|
||||
Builder.getInt32(0),
|
||||
Builder.getInt64(PseudoProbeFullDistributionFactor)};
|
||||
|
@ -856,7 +856,7 @@ void llvm::updatePublicTypeTestCalls(Module &M,
|
||||
return;
|
||||
if (hasWholeProgramVisibility(WholeProgramVisibilityEnabledInLTO)) {
|
||||
Function *TypeTestFunc =
|
||||
Intrinsic::getDeclaration(&M, Intrinsic::type_test);
|
||||
Intrinsic::getOrInsertDeclaration(&M, Intrinsic::type_test);
|
||||
for (Use &U : make_early_inc_range(PublicTypeTestFunc->uses())) {
|
||||
auto *CI = cast<CallInst>(U.getUser());
|
||||
auto *NewCI = CallInst::Create(
|
||||
@ -1187,7 +1187,8 @@ void DevirtModule::applySingleImplDevirt(VTableSlotInfo &SlotInfo,
|
||||
Instruction *ThenTerm =
|
||||
SplitBlockAndInsertIfThen(Cond, &CB, /*Unreachable=*/false);
|
||||
Builder.SetInsertPoint(ThenTerm);
|
||||
Function *TrapFn = Intrinsic::getDeclaration(&M, Intrinsic::debugtrap);
|
||||
Function *TrapFn =
|
||||
Intrinsic::getOrInsertDeclaration(&M, Intrinsic::debugtrap);
|
||||
auto *CallTrap = Builder.CreateCall(TrapFn);
|
||||
CallTrap->setDebugLoc(CB.getDebugLoc());
|
||||
}
|
||||
@ -1434,8 +1435,8 @@ void DevirtModule::tryICallBranchFunnel(
|
||||
}
|
||||
|
||||
BasicBlock *BB = BasicBlock::Create(M.getContext(), "", JT, nullptr);
|
||||
Function *Intr =
|
||||
Intrinsic::getDeclaration(&M, llvm::Intrinsic::icall_branch_funnel, {});
|
||||
Function *Intr = Intrinsic::getOrInsertDeclaration(
|
||||
&M, llvm::Intrinsic::icall_branch_funnel, {});
|
||||
|
||||
auto *CI = CallInst::Create(Intr, JTArgs, "", BB);
|
||||
CI->setTailCallKind(CallInst::TCK_MustTail);
|
||||
@ -2026,7 +2027,8 @@ void DevirtModule::scanTypeTestUsers(
|
||||
}
|
||||
|
||||
void DevirtModule::scanTypeCheckedLoadUsers(Function *TypeCheckedLoadFunc) {
|
||||
Function *TypeTestFunc = Intrinsic::getDeclaration(&M, Intrinsic::type_test);
|
||||
Function *TypeTestFunc =
|
||||
Intrinsic::getOrInsertDeclaration(&M, Intrinsic::type_test);
|
||||
|
||||
for (Use &U : llvm::make_early_inc_range(TypeCheckedLoadFunc->uses())) {
|
||||
auto *CI = dyn_cast<CallInst>(U.getUser());
|
||||
|
@ -1232,7 +1232,8 @@ static Instruction *foldToUnsignedSaturatedAdd(BinaryOperator &I) {
|
||||
assert(I.getOpcode() == Instruction::Add && "Expecting add instruction");
|
||||
Type *Ty = I.getType();
|
||||
auto getUAddSat = [&]() {
|
||||
return Intrinsic::getDeclaration(I.getModule(), Intrinsic::uadd_sat, Ty);
|
||||
return Intrinsic::getOrInsertDeclaration(I.getModule(), Intrinsic::uadd_sat,
|
||||
Ty);
|
||||
};
|
||||
|
||||
// add (umin X, ~Y), Y --> uaddsat X, Y
|
||||
@ -2127,7 +2128,7 @@ static Instruction *foldSubOfMinMax(BinaryOperator &I,
|
||||
if (match(Op0, m_c_Add(m_Specific(X), m_Specific(Y))) &&
|
||||
(Op0->hasOneUse() || Op1->hasOneUse())) {
|
||||
Intrinsic::ID InvID = getInverseMinMaxIntrinsic(MinMax->getIntrinsicID());
|
||||
Function *F = Intrinsic::getDeclaration(I.getModule(), InvID, Ty);
|
||||
Function *F = Intrinsic::getOrInsertDeclaration(I.getModule(), InvID, Ty);
|
||||
return CallInst::Create(F, {X, Y});
|
||||
}
|
||||
|
||||
@ -2150,7 +2151,7 @@ static Instruction *foldSubOfMinMax(BinaryOperator &I,
|
||||
if (MinMax->isSigned() && match(Y, m_ZeroInt()) &&
|
||||
match(X, m_NSWSub(m_Specific(Op0), m_Value(Z)))) {
|
||||
Intrinsic::ID InvID = getInverseMinMaxIntrinsic(MinMax->getIntrinsicID());
|
||||
Function *F = Intrinsic::getDeclaration(I.getModule(), InvID, Ty);
|
||||
Function *F = Intrinsic::getOrInsertDeclaration(I.getModule(), InvID, Ty);
|
||||
return CallInst::Create(F, {Op0, Z});
|
||||
}
|
||||
|
||||
|
@ -2269,7 +2269,8 @@ foldBitwiseLogicWithIntrinsics(BinaryOperator &I,
|
||||
Builder.CreateBinOp(I.getOpcode(), X->getOperand(0), Y->getOperand(0));
|
||||
Value *NewOp1 =
|
||||
Builder.CreateBinOp(I.getOpcode(), X->getOperand(1), Y->getOperand(1));
|
||||
Function *F = Intrinsic::getDeclaration(I.getModule(), IID, I.getType());
|
||||
Function *F =
|
||||
Intrinsic::getOrInsertDeclaration(I.getModule(), IID, I.getType());
|
||||
return CallInst::Create(F, {NewOp0, NewOp1, X->getOperand(2)});
|
||||
}
|
||||
case Intrinsic::bswap:
|
||||
@ -2280,7 +2281,8 @@ foldBitwiseLogicWithIntrinsics(BinaryOperator &I,
|
||||
: ConstantInt::get(I.getType(), IID == Intrinsic::bswap
|
||||
? RHSC->byteSwap()
|
||||
: RHSC->reverseBits()));
|
||||
Function *F = Intrinsic::getDeclaration(I.getModule(), IID, I.getType());
|
||||
Function *F =
|
||||
Intrinsic::getOrInsertDeclaration(I.getModule(), IID, I.getType());
|
||||
return CallInst::Create(F, {NewOp0});
|
||||
}
|
||||
default:
|
||||
@ -3056,7 +3058,8 @@ InstCombinerImpl::convertOrOfShiftsToFunnelShift(Instruction &Or) {
|
||||
static Instruction *matchFunnelShift(Instruction &Or, InstCombinerImpl &IC) {
|
||||
if (auto Opt = IC.convertOrOfShiftsToFunnelShift(Or)) {
|
||||
auto [IID, FShiftArgs] = *Opt;
|
||||
Function *F = Intrinsic::getDeclaration(Or.getModule(), IID, Or.getType());
|
||||
Function *F =
|
||||
Intrinsic::getOrInsertDeclaration(Or.getModule(), IID, Or.getType());
|
||||
return CallInst::Create(F, FShiftArgs);
|
||||
}
|
||||
|
||||
@ -3095,7 +3098,7 @@ static Instruction *matchOrConcat(Instruction &Or,
|
||||
Value *NewUpper = Builder.CreateZExt(Hi, Ty);
|
||||
NewUpper = Builder.CreateShl(NewUpper, HalfWidth);
|
||||
Value *BinOp = Builder.CreateOr(NewLower, NewUpper);
|
||||
Function *F = Intrinsic::getDeclaration(Or.getModule(), id, Ty);
|
||||
Function *F = Intrinsic::getOrInsertDeclaration(Or.getModule(), id, Ty);
|
||||
return Builder.CreateCall(F, BinOp);
|
||||
};
|
||||
|
||||
@ -4803,7 +4806,8 @@ Instruction *InstCombinerImpl::visitXor(BinaryOperator &I) {
|
||||
match(II->getArgOperand(1), m_One()) &&
|
||||
isKnownToBeAPowerOfTwo(II->getArgOperand(0), /*OrZero */ true)) {
|
||||
IID = (IID == Intrinsic::ctlz) ? Intrinsic::cttz : Intrinsic::ctlz;
|
||||
Function *F = Intrinsic::getDeclaration(II->getModule(), IID, Ty);
|
||||
Function *F =
|
||||
Intrinsic::getOrInsertDeclaration(II->getModule(), IID, Ty);
|
||||
return CallInst::Create(F, {II->getArgOperand(0), Builder.getTrue()});
|
||||
}
|
||||
}
|
||||
|
@ -488,7 +488,8 @@ static Instruction *foldCttzCtlz(IntrinsicInst &II, InstCombinerImpl &IC) {
|
||||
// cttz(bitreverse(x)) -> ctlz(x)
|
||||
if (match(Op0, m_BitReverse(m_Value(X)))) {
|
||||
Intrinsic::ID ID = IsTZ ? Intrinsic::ctlz : Intrinsic::cttz;
|
||||
Function *F = Intrinsic::getDeclaration(II.getModule(), ID, II.getType());
|
||||
Function *F =
|
||||
Intrinsic::getOrInsertDeclaration(II.getModule(), ID, II.getType());
|
||||
return CallInst::Create(F, {X, II.getArgOperand(1)});
|
||||
}
|
||||
|
||||
@ -647,7 +648,7 @@ static Instruction *foldCtpop(IntrinsicInst &II, InstCombinerImpl &IC) {
|
||||
if (Op0->hasOneUse() &&
|
||||
match(Op0, m_c_Or(m_Value(X), m_Neg(m_Deferred(X))))) {
|
||||
Function *F =
|
||||
Intrinsic::getDeclaration(II.getModule(), Intrinsic::cttz, Ty);
|
||||
Intrinsic::getOrInsertDeclaration(II.getModule(), Intrinsic::cttz, Ty);
|
||||
auto *Cttz = IC.Builder.CreateCall(F, {X, IC.Builder.getFalse()});
|
||||
auto *Bw = ConstantInt::get(Ty, APInt(BitWidth, BitWidth));
|
||||
return IC.replaceInstUsesWith(II, IC.Builder.CreateSub(Bw, Cttz));
|
||||
@ -657,7 +658,7 @@ static Instruction *foldCtpop(IntrinsicInst &II, InstCombinerImpl &IC) {
|
||||
if (match(Op0,
|
||||
m_c_And(m_Not(m_Value(X)), m_Add(m_Deferred(X), m_AllOnes())))) {
|
||||
Function *F =
|
||||
Intrinsic::getDeclaration(II.getModule(), Intrinsic::cttz, Ty);
|
||||
Intrinsic::getOrInsertDeclaration(II.getModule(), Intrinsic::cttz, Ty);
|
||||
return CallInst::Create(F, {X, IC.Builder.getFalse()});
|
||||
}
|
||||
|
||||
@ -1181,7 +1182,8 @@ Instruction *InstCombinerImpl::matchSAddSubSat(IntrinsicInst &MinMax1) {
|
||||
return nullptr;
|
||||
|
||||
// Finally create and return the sat intrinsic, truncated to the new type
|
||||
Function *F = Intrinsic::getDeclaration(MinMax1.getModule(), IntrinsicID, NewTy);
|
||||
Function *F = Intrinsic::getOrInsertDeclaration(MinMax1.getModule(),
|
||||
IntrinsicID, NewTy);
|
||||
Value *AT = Builder.CreateTrunc(AddSub->getOperand(0), NewTy);
|
||||
Value *BT = Builder.CreateTrunc(AddSub->getOperand(1), NewTy);
|
||||
Value *Sat = Builder.CreateCall(F, {AT, BT});
|
||||
@ -1286,8 +1288,8 @@ reassociateMinMaxWithConstantInOperand(IntrinsicInst *II,
|
||||
return nullptr;
|
||||
|
||||
// max (max X, C), Y --> max (max X, Y), C
|
||||
Function *MinMax =
|
||||
Intrinsic::getDeclaration(II->getModule(), MinMaxID, II->getType());
|
||||
Function *MinMax = Intrinsic::getOrInsertDeclaration(II->getModule(),
|
||||
MinMaxID, II->getType());
|
||||
Value *NewInner = Builder.CreateBinaryIntrinsic(MinMaxID, X, Y);
|
||||
NewInner->takeName(Inner);
|
||||
return CallInst::Create(MinMax, {NewInner, C});
|
||||
@ -1346,7 +1348,8 @@ static Instruction *factorizeMinMaxTree(IntrinsicInst *II) {
|
||||
return nullptr;
|
||||
|
||||
Module *Mod = II->getModule();
|
||||
Function *MinMax = Intrinsic::getDeclaration(Mod, MinMaxID, II->getType());
|
||||
Function *MinMax =
|
||||
Intrinsic::getOrInsertDeclaration(Mod, MinMaxID, II->getType());
|
||||
return CallInst::Create(MinMax, { MinMaxOp, ThirdOp });
|
||||
}
|
||||
|
||||
@ -1571,7 +1574,8 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
|
||||
Type *Tys[3] = { CI.getArgOperand(0)->getType(),
|
||||
CI.getArgOperand(1)->getType(),
|
||||
CI.getArgOperand(2)->getType() };
|
||||
CI.setCalledFunction(Intrinsic::getDeclaration(M, MemCpyID, Tys));
|
||||
CI.setCalledFunction(
|
||||
Intrinsic::getOrInsertDeclaration(M, MemCpyID, Tys));
|
||||
Changed = true;
|
||||
}
|
||||
}
|
||||
@ -2095,7 +2099,8 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
|
||||
|
||||
Constant *LeftShiftC = ConstantExpr::getSub(WidthC, ShAmtC);
|
||||
Module *Mod = II->getModule();
|
||||
Function *Fshl = Intrinsic::getDeclaration(Mod, Intrinsic::fshl, Ty);
|
||||
Function *Fshl =
|
||||
Intrinsic::getOrInsertDeclaration(Mod, Intrinsic::fshl, Ty);
|
||||
return CallInst::Create(Fshl, { Op0, Op1, LeftShiftC });
|
||||
}
|
||||
assert(IID == Intrinsic::fshl &&
|
||||
@ -2115,7 +2120,8 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
|
||||
// fshl i16 X, X, 8 --> bswap i16 X (reduce to more-specific form)
|
||||
if (Op0 == Op1 && BitWidth == 16 && match(ShAmtC, m_SpecificInt(8))) {
|
||||
Module *Mod = II->getModule();
|
||||
Function *Bswap = Intrinsic::getDeclaration(Mod, Intrinsic::bswap, Ty);
|
||||
Function *Bswap =
|
||||
Intrinsic::getOrInsertDeclaration(Mod, Intrinsic::bswap, Ty);
|
||||
return CallInst::Create(Bswap, { Op0 });
|
||||
}
|
||||
if (Instruction *BitOp =
|
||||
@ -2824,7 +2830,8 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
|
||||
CallArgs.push_back(II->getArgOperand(4));
|
||||
}
|
||||
|
||||
Function *NewFn = Intrinsic::getDeclaration(II->getModule(), NewIntrin);
|
||||
Function *NewFn =
|
||||
Intrinsic::getOrInsertDeclaration(II->getModule(), NewIntrin);
|
||||
return CallInst::Create(NewFn, CallArgs);
|
||||
}
|
||||
case Intrinsic::arm_neon_vtbl1:
|
||||
|
@ -95,8 +95,8 @@ Value *InstCombinerImpl::EvaluateInDifferentType(Value *V, Type *Ty,
|
||||
default:
|
||||
llvm_unreachable("Unsupported call!");
|
||||
case Intrinsic::vscale: {
|
||||
Function *Fn =
|
||||
Intrinsic::getDeclaration(I->getModule(), Intrinsic::vscale, {Ty});
|
||||
Function *Fn = Intrinsic::getOrInsertDeclaration(
|
||||
I->getModule(), Intrinsic::vscale, {Ty});
|
||||
Res = CallInst::Create(Fn->getFunctionType(), Fn);
|
||||
break;
|
||||
}
|
||||
@ -600,7 +600,8 @@ Instruction *InstCombinerImpl::narrowFunnelShift(TruncInst &Trunc) {
|
||||
if (ShVal0 != ShVal1)
|
||||
Y = Builder.CreateTrunc(ShVal1, DestTy);
|
||||
Intrinsic::ID IID = IsFshl ? Intrinsic::fshl : Intrinsic::fshr;
|
||||
Function *F = Intrinsic::getDeclaration(Trunc.getModule(), IID, DestTy);
|
||||
Function *F =
|
||||
Intrinsic::getOrInsertDeclaration(Trunc.getModule(), IID, DestTy);
|
||||
return CallInst::Create(F, {X, Y, NarrowShAmt});
|
||||
}
|
||||
|
||||
@ -1912,8 +1913,8 @@ Instruction *InstCombinerImpl::visitFPTrunc(FPTruncInst &FPT) {
|
||||
// Do unary FP operation on smaller type.
|
||||
// (fptrunc (fabs x)) -> (fabs (fptrunc x))
|
||||
Value *InnerTrunc = Builder.CreateFPTrunc(Src, Ty);
|
||||
Function *Overload = Intrinsic::getDeclaration(FPT.getModule(),
|
||||
II->getIntrinsicID(), Ty);
|
||||
Function *Overload = Intrinsic::getOrInsertDeclaration(
|
||||
FPT.getModule(), II->getIntrinsicID(), Ty);
|
||||
SmallVector<OperandBundleDef, 1> OpBundles;
|
||||
II->getOperandBundlesAsDefs(OpBundles);
|
||||
CallInst *NewCI =
|
||||
@ -2855,8 +2856,8 @@ Instruction *InstCombinerImpl::visitBitCast(BitCastInst &CI) {
|
||||
if (IntrinsicNum != 0) {
|
||||
assert(ShufOp0->getType() == SrcTy && "Unexpected shuffle mask");
|
||||
assert(match(ShufOp1, m_Undef()) && "Unexpected shuffle op");
|
||||
Function *BswapOrBitreverse =
|
||||
Intrinsic::getDeclaration(CI.getModule(), IntrinsicNum, DestTy);
|
||||
Function *BswapOrBitreverse = Intrinsic::getOrInsertDeclaration(
|
||||
CI.getModule(), IntrinsicNum, DestTy);
|
||||
Value *ScalarX = Builder.CreateBitCast(ShufOp0, DestTy);
|
||||
return CallInst::Create(BswapOrBitreverse, {ScalarX});
|
||||
}
|
||||
|
@ -1125,7 +1125,7 @@ static Instruction *processUGT_ADDCST_ADD(ICmpInst &I, Value *A, Value *B,
|
||||
// use the sadd_with_overflow intrinsic to efficiently compute both the
|
||||
// result and the overflow bit.
|
||||
Type *NewType = IntegerType::get(OrigAdd->getContext(), NewWidth);
|
||||
Function *F = Intrinsic::getDeclaration(
|
||||
Function *F = Intrinsic::getOrInsertDeclaration(
|
||||
I.getModule(), Intrinsic::sadd_with_overflow, NewType);
|
||||
|
||||
InstCombiner::BuilderTy &Builder = IC.Builder;
|
||||
@ -4790,11 +4790,11 @@ Value *InstCombinerImpl::foldMultiplicationOverflowCheck(ICmpInst &I) {
|
||||
if (MulHadOtherUses)
|
||||
Builder.SetInsertPoint(Mul);
|
||||
|
||||
Function *F = Intrinsic::getDeclaration(I.getModule(),
|
||||
Div->getOpcode() == Instruction::UDiv
|
||||
? Intrinsic::umul_with_overflow
|
||||
: Intrinsic::smul_with_overflow,
|
||||
X->getType());
|
||||
Function *F = Intrinsic::getOrInsertDeclaration(
|
||||
I.getModule(),
|
||||
Div->getOpcode() == Instruction::UDiv ? Intrinsic::umul_with_overflow
|
||||
: Intrinsic::smul_with_overflow,
|
||||
X->getType());
|
||||
CallInst *Call = Builder.CreateCall(F, {X, Y}, "mul");
|
||||
|
||||
// If the multiplication was used elsewhere, to ensure that we don't leave
|
||||
@ -6334,7 +6334,7 @@ static Instruction *processUMulZExtIdiom(ICmpInst &I, Value *MulVal,
|
||||
MulA = Builder.CreateZExt(A, MulType);
|
||||
if (WidthB < MulWidth)
|
||||
MulB = Builder.CreateZExt(B, MulType);
|
||||
Function *F = Intrinsic::getDeclaration(
|
||||
Function *F = Intrinsic::getOrInsertDeclaration(
|
||||
I.getModule(), Intrinsic::umul_with_overflow, MulType);
|
||||
CallInst *Call = Builder.CreateCall(F, {MulA, MulB}, "umul");
|
||||
IC.addToWorklist(MulInstr);
|
||||
@ -7121,8 +7121,8 @@ static Instruction *foldVectorCmp(CmpInst &Cmp,
|
||||
if (auto *I = dyn_cast<Instruction>(V))
|
||||
I->copyIRFlags(&Cmp);
|
||||
Module *M = Cmp.getModule();
|
||||
Function *F =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::vector_reverse, V->getType());
|
||||
Function *F = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::vector_reverse, V->getType());
|
||||
return CallInst::Create(F, V);
|
||||
};
|
||||
|
||||
|
@ -1148,8 +1148,8 @@ static Instruction *foldSelectCtlzToCttz(ICmpInst *ICI, Value *TrueVal,
|
||||
if (!match(II->getOperand(0), m_c_And(m_Specific(X), m_Neg(m_Specific(X)))))
|
||||
return nullptr;
|
||||
|
||||
Function *F = Intrinsic::getDeclaration(II->getModule(), Intrinsic::cttz,
|
||||
II->getType());
|
||||
Function *F = Intrinsic::getOrInsertDeclaration(
|
||||
II->getModule(), Intrinsic::cttz, II->getType());
|
||||
return CallInst::Create(F, {X, II->getArgOperand(1)});
|
||||
}
|
||||
|
||||
@ -2242,8 +2242,8 @@ foldOverflowingAddSubSelect(SelectInst &SI, InstCombiner::BuilderTy &Builder) {
|
||||
else
|
||||
return nullptr;
|
||||
|
||||
Function *F =
|
||||
Intrinsic::getDeclaration(SI.getModule(), NewIntrinsicID, SI.getType());
|
||||
Function *F = Intrinsic::getOrInsertDeclaration(SI.getModule(),
|
||||
NewIntrinsicID, SI.getType());
|
||||
return CallInst::Create(F, {X, Y});
|
||||
}
|
||||
|
||||
@ -2537,7 +2537,8 @@ static Instruction *foldSelectFunnelShift(SelectInst &Sel,
|
||||
// This is a funnel/rotate that avoids shift-by-bitwidth UB in a suboptimal way.
|
||||
// Convert to funnel shift intrinsic.
|
||||
Intrinsic::ID IID = IsFshl ? Intrinsic::fshl : Intrinsic::fshr;
|
||||
Function *F = Intrinsic::getDeclaration(Sel.getModule(), IID, Sel.getType());
|
||||
Function *F =
|
||||
Intrinsic::getOrInsertDeclaration(Sel.getModule(), IID, Sel.getType());
|
||||
ShAmt = Builder.CreateZExt(ShAmt, Sel.getType());
|
||||
return CallInst::Create(F, { SV0, SV1, ShAmt });
|
||||
}
|
||||
@ -2580,8 +2581,8 @@ static Instruction *foldSelectToCopysign(SelectInst &Sel,
|
||||
// Canonicalize the magnitude argument as the positive constant since we do
|
||||
// not care about its sign.
|
||||
Value *MagArg = ConstantFP::get(SelType, abs(*TC));
|
||||
Function *F = Intrinsic::getDeclaration(Sel.getModule(), Intrinsic::copysign,
|
||||
Sel.getType());
|
||||
Function *F = Intrinsic::getOrInsertDeclaration(
|
||||
Sel.getModule(), Intrinsic::copysign, Sel.getType());
|
||||
return CallInst::Create(F, { MagArg, X });
|
||||
}
|
||||
|
||||
@ -2600,8 +2601,8 @@ Instruction *InstCombinerImpl::foldVectorSelect(SelectInst &Sel) {
|
||||
if (auto *I = dyn_cast<Instruction>(V))
|
||||
I->copyIRFlags(&Sel);
|
||||
Module *M = Sel.getModule();
|
||||
Function *F =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::vector_reverse, V->getType());
|
||||
Function *F = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::vector_reverse, V->getType());
|
||||
return CallInst::Create(F, V);
|
||||
};
|
||||
|
||||
|
@ -898,7 +898,7 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Instruction *I,
|
||||
Value *X;
|
||||
if (DemandedMask == 1 && VTy->getScalarSizeInBits() % 2 == 0 &&
|
||||
match(II->getArgOperand(0), m_Not(m_Value(X)))) {
|
||||
Function *Ctpop = Intrinsic::getDeclaration(
|
||||
Function *Ctpop = Intrinsic::getOrInsertDeclaration(
|
||||
II->getModule(), Intrinsic::ctpop, VTy);
|
||||
return InsertNewInstWith(CallInst::Create(Ctpop, {X}), I->getIterator());
|
||||
}
|
||||
|
@ -2474,8 +2474,8 @@ static Instruction *foldShuffleOfUnaryOps(ShuffleVectorInst &Shuf,
|
||||
if (IsFNeg)
|
||||
return UnaryOperator::CreateFNegFMF(NewShuf, S0);
|
||||
|
||||
Function *FAbs = Intrinsic::getDeclaration(Shuf.getModule(),
|
||||
Intrinsic::fabs, Shuf.getType());
|
||||
Function *FAbs = Intrinsic::getOrInsertDeclaration(
|
||||
Shuf.getModule(), Intrinsic::fabs, Shuf.getType());
|
||||
CallInst *NewF = CallInst::Create(FAbs, {NewShuf});
|
||||
NewF->setFastMathFlags(S0->getFastMathFlags());
|
||||
return NewF;
|
||||
@ -2495,8 +2495,8 @@ static Instruction *foldShuffleOfUnaryOps(ShuffleVectorInst &Shuf,
|
||||
if (IsFNeg) {
|
||||
NewF = UnaryOperator::CreateFNeg(NewShuf);
|
||||
} else {
|
||||
Function *FAbs = Intrinsic::getDeclaration(Shuf.getModule(),
|
||||
Intrinsic::fabs, Shuf.getType());
|
||||
Function *FAbs = Intrinsic::getOrInsertDeclaration(
|
||||
Shuf.getModule(), Intrinsic::fabs, Shuf.getType());
|
||||
NewF = CallInst::Create(FAbs, {NewShuf});
|
||||
}
|
||||
NewF->copyIRFlags(S0);
|
||||
|
@ -2084,8 +2084,8 @@ Instruction *InstCombinerImpl::foldVectorBinop(BinaryOperator &Inst) {
|
||||
if (auto *BO = dyn_cast<BinaryOperator>(V))
|
||||
BO->copyIRFlags(&Inst);
|
||||
Module *M = Inst.getModule();
|
||||
Function *F =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::vector_reverse, V->getType());
|
||||
Function *F = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::vector_reverse, V->getType());
|
||||
return CallInst::Create(F, V);
|
||||
};
|
||||
|
||||
@ -3355,7 +3355,7 @@ Instruction *InstCombinerImpl::visitAllocSite(Instruction &MI) {
|
||||
if (InvokeInst *II = dyn_cast<InvokeInst>(&MI)) {
|
||||
// Replace invoke with a NOP intrinsic to maintain the original CFG
|
||||
Module *M = II->getModule();
|
||||
Function *F = Intrinsic::getDeclaration(M, Intrinsic::donothing);
|
||||
Function *F = Intrinsic::getOrInsertDeclaration(M, Intrinsic::donothing);
|
||||
InvokeInst::Create(F, II->getNormalDest(), II->getUnwindDest(), {}, "",
|
||||
II->getParent());
|
||||
}
|
||||
|
@ -1109,7 +1109,7 @@ struct FunctionStackPoisoner : public InstVisitor<FunctionStackPoisoner> {
|
||||
// alloca. We have a special @llvm.get.dynamic.area.offset intrinsic for
|
||||
// this purpose.
|
||||
if (!isa<ReturnInst>(InstBefore)) {
|
||||
Function *DynamicAreaOffsetFunc = Intrinsic::getDeclaration(
|
||||
Function *DynamicAreaOffsetFunc = Intrinsic::getOrInsertDeclaration(
|
||||
InstBefore->getModule(), Intrinsic::get_dynamic_area_offset,
|
||||
{IntptrTy});
|
||||
|
||||
@ -1867,7 +1867,7 @@ void AddressSanitizer::instrumentAddress(Instruction *OrigIns,
|
||||
const ASanAccessInfo AccessInfo(IsWrite, CompileKernel, AccessSizeIndex);
|
||||
Module *M = IRB.GetInsertBlock()->getParent()->getParent();
|
||||
IRB.CreateCall(
|
||||
Intrinsic::getDeclaration(M, Intrinsic::asan_check_memaccess),
|
||||
Intrinsic::getOrInsertDeclaration(M, Intrinsic::asan_check_memaccess),
|
||||
{IRB.CreatePointerCast(Addr, PtrTy),
|
||||
ConstantInt::get(Int32Ty, AccessInfo.Packed)});
|
||||
return;
|
||||
|
@ -194,7 +194,7 @@ static bool addBoundsChecking(Function &F, TargetLibraryInfo &TLI,
|
||||
IRB.SetInsertPoint(TrapBB);
|
||||
|
||||
Intrinsic::ID IntrID = DebugTrapBB ? Intrinsic::ubsantrap : Intrinsic::trap;
|
||||
auto *F = Intrinsic::getDeclaration(Fn->getParent(), IntrID);
|
||||
auto *F = Intrinsic::getOrInsertDeclaration(Fn->getParent(), IntrID);
|
||||
|
||||
CallInst *TrapCall;
|
||||
if (DebugTrapBB) {
|
||||
|
@ -1042,14 +1042,14 @@ void HWAddressSanitizer::instrumentMemAccessOutline(Value *Ptr, bool IsWrite,
|
||||
|
||||
if (UseFixedShadowIntrinsic) {
|
||||
IRB.CreateCall(
|
||||
Intrinsic::getDeclaration(
|
||||
Intrinsic::getOrInsertDeclaration(
|
||||
M, UseShortGranules
|
||||
? Intrinsic::hwasan_check_memaccess_shortgranules_fixedshadow
|
||||
: Intrinsic::hwasan_check_memaccess_fixedshadow),
|
||||
{Ptr, ConstantInt::get(Int32Ty, AccessInfo),
|
||||
ConstantInt::get(Int64Ty, Mapping.offset())});
|
||||
} else {
|
||||
IRB.CreateCall(Intrinsic::getDeclaration(
|
||||
IRB.CreateCall(Intrinsic::getOrInsertDeclaration(
|
||||
M, UseShortGranules
|
||||
? Intrinsic::hwasan_check_memaccess_shortgranules
|
||||
: Intrinsic::hwasan_check_memaccess),
|
||||
|
@ -110,7 +110,8 @@ PreservedAnalyses KCFIPass::run(Function &F, FunctionAnalysisManager &AM) {
|
||||
Instruction *ThenTerm =
|
||||
SplitBlockAndInsertIfThen(Test, Call, false, VeryUnlikelyWeights);
|
||||
Builder.SetInsertPoint(ThenTerm);
|
||||
Builder.CreateCall(Intrinsic::getDeclaration(&M, Intrinsic::debugtrap));
|
||||
Builder.CreateCall(
|
||||
Intrinsic::getOrInsertDeclaration(&M, Intrinsic::debugtrap));
|
||||
++NumKCFIChecks;
|
||||
}
|
||||
|
||||
|
@ -2853,7 +2853,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
|
||||
Value *S2Conv =
|
||||
IRB.CreateSExt(IRB.CreateICmpNE(S2, getCleanShadow(S2)), S2->getType());
|
||||
Value *V2 = I.getOperand(2);
|
||||
Function *Intrin = Intrinsic::getDeclaration(
|
||||
Function *Intrin = Intrinsic::getOrInsertDeclaration(
|
||||
I.getModule(), I.getIntrinsicID(), S2Conv->getType());
|
||||
Value *Shift = IRB.CreateCall(Intrin, {S0, S1, V2});
|
||||
setShadow(&I, IRB.CreateOr(Shift, S2Conv));
|
||||
@ -3057,7 +3057,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
|
||||
IRBuilder<> IRB(&I);
|
||||
Value *Op = I.getArgOperand(0);
|
||||
Type *OpType = Op->getType();
|
||||
Function *BswapFunc = Intrinsic::getDeclaration(
|
||||
Function *BswapFunc = Intrinsic::getOrInsertDeclaration(
|
||||
F.getParent(), Intrinsic::bswap, ArrayRef(&OpType, 1));
|
||||
setShadow(&I, IRB.CreateCall(BswapFunc, getShadow(Op)));
|
||||
setOrigin(&I, getOrigin(Op));
|
||||
@ -3287,7 +3287,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
|
||||
S2_ext = IRB.CreateBitCast(S2_ext, getMMXVectorTy(64));
|
||||
}
|
||||
|
||||
Function *ShadowFn = Intrinsic::getDeclaration(
|
||||
Function *ShadowFn = Intrinsic::getOrInsertDeclaration(
|
||||
F.getParent(), getSignedPackIntrinsic(I.getIntrinsicID()));
|
||||
|
||||
Value *S =
|
||||
|
@ -919,7 +919,7 @@ void FunctionInstrumenter::instrument() {
|
||||
// llvm.instrprof.cover(i8* <name>, i64 <hash>, i32 <num-counters>,
|
||||
// i32 <index>)
|
||||
Builder.CreateCall(
|
||||
Intrinsic::getDeclaration(&M, Intrinsic::instrprof_cover),
|
||||
Intrinsic::getOrInsertDeclaration(&M, Intrinsic::instrprof_cover),
|
||||
{NormalizedNamePtr, CFGHash, Builder.getInt32(1), Builder.getInt32(0)});
|
||||
return;
|
||||
}
|
||||
@ -931,7 +931,7 @@ void FunctionInstrumenter::instrument() {
|
||||
|
||||
if (IsCtxProf) {
|
||||
auto *CSIntrinsic =
|
||||
Intrinsic::getDeclaration(&M, Intrinsic::instrprof_callsite);
|
||||
Intrinsic::getOrInsertDeclaration(&M, Intrinsic::instrprof_callsite);
|
||||
// We want to count the instrumentable callsites, then instrument them. This
|
||||
// is because the llvm.instrprof.callsite intrinsic has an argument (like
|
||||
// the other instrprof intrinsics) capturing the total number of
|
||||
@ -972,7 +972,7 @@ void FunctionInstrumenter::instrument() {
|
||||
// llvm.instrprof.timestamp(i8* <name>, i64 <hash>, i32 <num-counters>,
|
||||
// i32 <index>)
|
||||
Builder.CreateCall(
|
||||
Intrinsic::getDeclaration(&M, Intrinsic::instrprof_timestamp),
|
||||
Intrinsic::getOrInsertDeclaration(&M, Intrinsic::instrprof_timestamp),
|
||||
{NormalizedNamePtr, CFGHash, Builder.getInt32(NumCounters),
|
||||
Builder.getInt32(I)});
|
||||
I += PGOBlockCoverage ? 8 : 1;
|
||||
@ -984,12 +984,12 @@ void FunctionInstrumenter::instrument() {
|
||||
"Cannot get the Instrumentation point");
|
||||
// llvm.instrprof.increment(i8* <name>, i64 <hash>, i32 <num-counters>,
|
||||
// i32 <index>)
|
||||
Builder.CreateCall(
|
||||
Intrinsic::getDeclaration(&M, PGOBlockCoverage
|
||||
? Intrinsic::instrprof_cover
|
||||
: Intrinsic::instrprof_increment),
|
||||
{NormalizedNamePtr, CFGHash, Builder.getInt32(NumCounters),
|
||||
Builder.getInt32(I++)});
|
||||
Builder.CreateCall(Intrinsic::getOrInsertDeclaration(
|
||||
&M, PGOBlockCoverage
|
||||
? Intrinsic::instrprof_cover
|
||||
: Intrinsic::instrprof_increment),
|
||||
{NormalizedNamePtr, CFGHash,
|
||||
Builder.getInt32(NumCounters), Builder.getInt32(I++)});
|
||||
}
|
||||
|
||||
// Now instrument select instructions:
|
||||
@ -1038,7 +1038,8 @@ void FunctionInstrumenter::instrument() {
|
||||
SmallVector<OperandBundleDef, 1> OpBundles;
|
||||
populateEHOperandBundle(Cand, BlockColors, OpBundles);
|
||||
Builder.CreateCall(
|
||||
Intrinsic::getDeclaration(&M, Intrinsic::instrprof_value_profile),
|
||||
Intrinsic::getOrInsertDeclaration(&M,
|
||||
Intrinsic::instrprof_value_profile),
|
||||
{NormalizedNamePtr, Builder.getInt64(FuncInfo.FunctionHash),
|
||||
ToProfile, Builder.getInt32(Kind), Builder.getInt32(SiteIndex++)},
|
||||
OpBundles);
|
||||
@ -1726,7 +1727,7 @@ void SelectInstVisitor::instrumentOneSelectInst(SelectInst &SI) {
|
||||
ConstantExpr::getPointerBitCastOrAddrSpaceCast(
|
||||
FuncNameVar, PointerType::get(M->getContext(), 0));
|
||||
Builder.CreateCall(
|
||||
Intrinsic::getDeclaration(M, Intrinsic::instrprof_increment_step),
|
||||
Intrinsic::getOrInsertDeclaration(M, Intrinsic::instrprof_increment_step),
|
||||
{NormalizedFuncNameVarPtr, Builder.getInt64(FuncHash),
|
||||
Builder.getInt32(TotalNumCtrs), Builder.getInt32(*CurCtrIdx), Step});
|
||||
++(*CurCtrIdx);
|
||||
|
@ -999,7 +999,7 @@ void ModuleSanitizerCoverage::InjectCoverageAtBlock(Function &F, BasicBlock &BB,
|
||||
if (Options.StackDepth && IsEntryBB && !IsLeafFunc) {
|
||||
// Check stack depth. If it's the deepest so far, record it.
|
||||
Module *M = F.getParent();
|
||||
Function *GetFrameAddr = Intrinsic::getDeclaration(
|
||||
Function *GetFrameAddr = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::frameaddress,
|
||||
IRB.getPtrTy(M->getDataLayout().getAllocaAddrSpace()));
|
||||
auto FrameAddrPtr =
|
||||
|
@ -571,9 +571,10 @@ bool ThreadSanitizer::sanitizeFunction(Function &F,
|
||||
// Instrument function entry/exit points if there were instrumented accesses.
|
||||
if ((Res || HasCalls) && ClInstrumentFuncEntryExit) {
|
||||
InstrumentationIRBuilder IRB(F.getEntryBlock().getFirstNonPHI());
|
||||
Value *ReturnAddress = IRB.CreateCall(
|
||||
Intrinsic::getDeclaration(F.getParent(), Intrinsic::returnaddress),
|
||||
IRB.getInt32(0));
|
||||
Value *ReturnAddress =
|
||||
IRB.CreateCall(Intrinsic::getOrInsertDeclaration(
|
||||
F.getParent(), Intrinsic::returnaddress),
|
||||
IRB.getInt32(0));
|
||||
IRB.CreateCall(TsanFuncEntry, ReturnAddress);
|
||||
|
||||
EscapeEnumerator EE(F, "tsan_cleanup", ClHandleCxxExceptions);
|
||||
|
@ -139,7 +139,7 @@ private:
|
||||
if (Decl)
|
||||
return Decl;
|
||||
|
||||
return Decl = Intrinsic::getDeclaration(TheModule, IntID);
|
||||
return Decl = Intrinsic::getOrInsertDeclaration(TheModule, IntID);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -380,7 +380,8 @@ bool InferAddressSpacesImpl::rewriteIntrinsicOperands(IntrinsicInst *II,
|
||||
case Intrinsic::masked_load: {
|
||||
Type *DestTy = II->getType();
|
||||
Type *SrcTy = NewV->getType();
|
||||
Function *NewDecl = Intrinsic::getDeclaration(M, IID, {DestTy, SrcTy});
|
||||
Function *NewDecl =
|
||||
Intrinsic::getOrInsertDeclaration(M, IID, {DestTy, SrcTy});
|
||||
II->setArgOperand(0, NewV);
|
||||
II->setCalledFunction(NewDecl);
|
||||
return true;
|
||||
@ -391,7 +392,8 @@ bool InferAddressSpacesImpl::rewriteIntrinsicOperands(IntrinsicInst *II,
|
||||
case Intrinsic::masked_gather: {
|
||||
Type *RetTy = II->getType();
|
||||
Type *NewPtrTy = NewV->getType();
|
||||
Function *NewDecl = Intrinsic::getDeclaration(M, IID, {RetTy, NewPtrTy});
|
||||
Function *NewDecl =
|
||||
Intrinsic::getOrInsertDeclaration(M, IID, {RetTy, NewPtrTy});
|
||||
II->setArgOperand(0, NewV);
|
||||
II->setCalledFunction(NewDecl);
|
||||
return true;
|
||||
@ -400,16 +402,16 @@ bool InferAddressSpacesImpl::rewriteIntrinsicOperands(IntrinsicInst *II,
|
||||
case Intrinsic::masked_scatter: {
|
||||
Type *ValueTy = II->getOperand(0)->getType();
|
||||
Type *NewPtrTy = NewV->getType();
|
||||
Function *NewDecl =
|
||||
Intrinsic::getDeclaration(M, II->getIntrinsicID(), {ValueTy, NewPtrTy});
|
||||
Function *NewDecl = Intrinsic::getOrInsertDeclaration(
|
||||
M, II->getIntrinsicID(), {ValueTy, NewPtrTy});
|
||||
II->setArgOperand(1, NewV);
|
||||
II->setCalledFunction(NewDecl);
|
||||
return true;
|
||||
}
|
||||
case Intrinsic::prefetch:
|
||||
case Intrinsic::is_constant: {
|
||||
Function *NewDecl =
|
||||
Intrinsic::getDeclaration(M, II->getIntrinsicID(), {NewV->getType()});
|
||||
Function *NewDecl = Intrinsic::getOrInsertDeclaration(
|
||||
M, II->getIntrinsicID(), {NewV->getType()});
|
||||
II->setArgOperand(0, NewV);
|
||||
II->setCalledFunction(NewDecl);
|
||||
return true;
|
||||
|
@ -405,7 +405,7 @@ bool LoopDataPrefetch::runOnLoop(Loop *L) {
|
||||
IRBuilder<> Builder(P.InsertPt);
|
||||
Module *M = BB->getParent()->getParent();
|
||||
Type *I32 = Type::getInt32Ty(BB->getContext());
|
||||
Function *PrefetchFunc = Intrinsic::getDeclaration(
|
||||
Function *PrefetchFunc = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::prefetch, PrefPtrValue->getType());
|
||||
Builder.CreateCall(
|
||||
PrefetchFunc,
|
||||
|
@ -978,8 +978,8 @@ static bool FlattenLoopPair(FlattenInfo &FI, DominatorTree *DT, LoopInfo *LI,
|
||||
assert(match(Br->getCondition(), m_Zero()) &&
|
||||
"Expected branch condition to be false");
|
||||
IRBuilder<> Builder(Br);
|
||||
Function *F = Intrinsic::getDeclaration(M, Intrinsic::umul_with_overflow,
|
||||
FI.OuterTripCount->getType());
|
||||
Function *F = Intrinsic::getOrInsertDeclaration(
|
||||
M, Intrinsic::umul_with_overflow, FI.OuterTripCount->getType());
|
||||
Value *Call = Builder.CreateCall(F, {FI.OuterTripCount, FI.InnerTripCount},
|
||||
"flatten.mul");
|
||||
FI.NewTripCount = Builder.CreateExtractValue(Call, 0, "flatten.tripcount");
|
||||
|
@ -2122,7 +2122,7 @@ static CallInst *createPopcntIntrinsic(IRBuilder<> &IRBuilder, Value *Val,
|
||||
Type *Tys[] = {Val->getType()};
|
||||
|
||||
Module *M = IRBuilder.GetInsertBlock()->getParent()->getParent();
|
||||
Function *Func = Intrinsic::getDeclaration(M, Intrinsic::ctpop, Tys);
|
||||
Function *Func = Intrinsic::getOrInsertDeclaration(M, Intrinsic::ctpop, Tys);
|
||||
CallInst *CI = IRBuilder.CreateCall(Func, Ops);
|
||||
CI->setDebugLoc(DL);
|
||||
|
||||
@ -2136,7 +2136,7 @@ static CallInst *createFFSIntrinsic(IRBuilder<> &IRBuilder, Value *Val,
|
||||
Type *Tys[] = {Val->getType()};
|
||||
|
||||
Module *M = IRBuilder.GetInsertBlock()->getParent()->getParent();
|
||||
Function *Func = Intrinsic::getDeclaration(M, IID, Tys);
|
||||
Function *Func = Intrinsic::getOrInsertDeclaration(M, IID, Tys);
|
||||
CallInst *CI = IRBuilder.CreateCall(Func, Ops);
|
||||
CI->setDebugLoc(DL);
|
||||
|
||||
|
@ -44,7 +44,7 @@ static bool lowerGuardIntrinsic(Function &F) {
|
||||
if (ToLower.empty())
|
||||
return false;
|
||||
|
||||
auto *DeoptIntrinsic = Intrinsic::getDeclaration(
|
||||
auto *DeoptIntrinsic = Intrinsic::getOrInsertDeclaration(
|
||||
F.getParent(), Intrinsic::experimental_deoptimize, {F.getReturnType()});
|
||||
DeoptIntrinsic->setCallingConv(GuardDecl->getCallingConv());
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user