Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NFC] Rename Intrinsic::getDeclaration to getOrInsertDeclaration #111752

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions clang/lib/CodeGen/CGBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand All @@ -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);
Expand Down Expand Up @@ -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});
Expand Down Expand Up @@ -18873,7 +18873,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: {
Value *Op0 = EmitScalarExpr(E->getArg(0));
Expand Down
8 changes: 4 additions & 4 deletions clang/lib/CodeGen/CGDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2509,17 +2509,17 @@ 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;
}

/// Lazily declare the @llvm.lifetime.end intrinsic.
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;
}

Expand Down
4 changes: 2 additions & 2 deletions clang/lib/CodeGen/CGException.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/CodeGen/CodeGenFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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().");
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/CodeGen/CodeGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 *> &
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/CodeGen/Targets/SystemZ.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ class SystemZTargetCodeGenInfo : public TargetCodeGenInfo {
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:
Expand Down
4 changes: 2 additions & 2 deletions llvm/examples/BrainF/BrainF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
4 changes: 2 additions & 2 deletions llvm/include/llvm-c/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions llvm/include/llvm/IR/IntrinsicInst.h
Original file line number Diff line number Diff line change
Expand Up @@ -568,9 +568,9 @@ class VPIntrinsic : public IntrinsicInst {
/// \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(
Expand Down
9 changes: 5 additions & 4 deletions llvm/include/llvm/IR/Intrinsics.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions llvm/include/llvm/IR/MatrixBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class MatrixBuilder {
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);
Expand All @@ -95,7 +95,7 @@ class MatrixBuilder {
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);
Expand All @@ -115,7 +115,7 @@ class MatrixBuilder {

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);
Expand All @@ -136,7 +136,7 @@ class MatrixBuilder {
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);
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/AsmParser/LLParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/ExpandLargeFpConvert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/ExpandMemCmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 7 additions & 7 deletions llvm/lib/CodeGen/ExpandVectorPredication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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))
Expand Down Expand Up @@ -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");
Expand Down
12 changes: 5 additions & 7 deletions llvm/lib/CodeGen/HardwareLoops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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();
Expand All @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/IntrinsicLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/CodeGen/SafeStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
22 changes: 12 additions & 10 deletions llvm/lib/CodeGen/SjLjEHPrepare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading
Loading