1 //===---- IRBuilder.cpp - Builder for LLVM Instrs -------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the IRBuilder class, which is used as a convenient way
11 // to create LLVM instructions with a consistent and simplified interface.
13 //===----------------------------------------------------------------------===//
15 #include "llvm/IR/Function.h"
16 #include "llvm/IR/GlobalVariable.h"
17 #include "llvm/IR/IRBuilder.h"
18 #include "llvm/IR/Intrinsics.h"
19 #include "llvm/IR/LLVMContext.h"
20 #include "llvm/IR/Statepoint.h"
23 /// CreateGlobalString - Make a new global variable with an initializer that
24 /// has array of i8 type filled in with the nul terminated string value
25 /// specified. If Name is specified, it is the name of the global variable
27 GlobalVariable *IRBuilderBase::CreateGlobalString(StringRef Str,
29 unsigned AddressSpace) {
30 Constant *StrConstant = ConstantDataArray::getString(Context, Str);
31 Module &M = *BB->getParent()->getParent();
32 GlobalVariable *GV = new GlobalVariable(M, StrConstant->getType(),
33 true, GlobalValue::PrivateLinkage,
34 StrConstant, Name, nullptr,
35 GlobalVariable::NotThreadLocal,
37 GV->setUnnamedAddr(GlobalValue::UnnamedAddr::Global);
41 Type *IRBuilderBase::getCurrentFunctionReturnType() const {
42 assert(BB && BB->getParent() && "No current function!");
43 return BB->getParent()->getReturnType();
46 Value *IRBuilderBase::getCastedInt8PtrValue(Value *Ptr) {
47 PointerType *PT = cast<PointerType>(Ptr->getType());
48 if (PT->getElementType()->isIntegerTy(8))
51 // Otherwise, we need to insert a bitcast.
52 PT = getInt8PtrTy(PT->getAddressSpace());
53 BitCastInst *BCI = new BitCastInst(Ptr, PT, "");
54 BB->getInstList().insert(InsertPt, BCI);
55 SetInstDebugLocation(BCI);
59 static CallInst *createCallHelper(Value *Callee, ArrayRef<Value *> Ops,
60 IRBuilderBase *Builder,
61 const Twine& Name="") {
62 CallInst *CI = CallInst::Create(Callee, Ops, Name);
63 Builder->GetInsertBlock()->getInstList().insert(Builder->GetInsertPoint(),CI);
64 Builder->SetInstDebugLocation(CI);
68 static InvokeInst *createInvokeHelper(Value *Invokee, BasicBlock *NormalDest,
69 BasicBlock *UnwindDest,
70 ArrayRef<Value *> Ops,
71 IRBuilderBase *Builder,
72 const Twine &Name = "") {
74 InvokeInst::Create(Invokee, NormalDest, UnwindDest, Ops, Name);
75 Builder->GetInsertBlock()->getInstList().insert(Builder->GetInsertPoint(),
77 Builder->SetInstDebugLocation(II);
81 CallInst *IRBuilderBase::
82 CreateMemSet(Value *Ptr, Value *Val, Value *Size, unsigned Align,
83 bool isVolatile, MDNode *TBAATag, MDNode *ScopeTag,
85 Ptr = getCastedInt8PtrValue(Ptr);
86 Value *Ops[] = { Ptr, Val, Size, getInt32(Align), getInt1(isVolatile) };
87 Type *Tys[] = { Ptr->getType(), Size->getType() };
88 Module *M = BB->getParent()->getParent();
89 Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys);
91 CallInst *CI = createCallHelper(TheFn, Ops, this);
93 // Set the TBAA info if present.
95 CI->setMetadata(LLVMContext::MD_tbaa, TBAATag);
98 CI->setMetadata(LLVMContext::MD_alias_scope, ScopeTag);
101 CI->setMetadata(LLVMContext::MD_noalias, NoAliasTag);
106 CallInst *IRBuilderBase::
107 CreateMemCpy(Value *Dst, Value *Src, Value *Size, unsigned Align,
108 bool isVolatile, MDNode *TBAATag, MDNode *TBAAStructTag,
109 MDNode *ScopeTag, MDNode *NoAliasTag) {
110 Dst = getCastedInt8PtrValue(Dst);
111 Src = getCastedInt8PtrValue(Src);
113 Value *Ops[] = { Dst, Src, Size, getInt32(Align), getInt1(isVolatile) };
114 Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() };
115 Module *M = BB->getParent()->getParent();
116 Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memcpy, Tys);
118 CallInst *CI = createCallHelper(TheFn, Ops, this);
120 // Set the TBAA info if present.
122 CI->setMetadata(LLVMContext::MD_tbaa, TBAATag);
124 // Set the TBAA Struct info if present.
126 CI->setMetadata(LLVMContext::MD_tbaa_struct, TBAAStructTag);
129 CI->setMetadata(LLVMContext::MD_alias_scope, ScopeTag);
132 CI->setMetadata(LLVMContext::MD_noalias, NoAliasTag);
137 CallInst *IRBuilderBase::
138 CreateMemMove(Value *Dst, Value *Src, Value *Size, unsigned Align,
139 bool isVolatile, MDNode *TBAATag, MDNode *ScopeTag,
140 MDNode *NoAliasTag) {
141 Dst = getCastedInt8PtrValue(Dst);
142 Src = getCastedInt8PtrValue(Src);
144 Value *Ops[] = { Dst, Src, Size, getInt32(Align), getInt1(isVolatile) };
145 Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() };
146 Module *M = BB->getParent()->getParent();
147 Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memmove, Tys);
149 CallInst *CI = createCallHelper(TheFn, Ops, this);
151 // Set the TBAA info if present.
153 CI->setMetadata(LLVMContext::MD_tbaa, TBAATag);
156 CI->setMetadata(LLVMContext::MD_alias_scope, ScopeTag);
159 CI->setMetadata(LLVMContext::MD_noalias, NoAliasTag);
164 static CallInst *getReductionIntrinsic(IRBuilderBase *Builder, Intrinsic::ID ID,
166 Module *M = Builder->GetInsertBlock()->getParent()->getParent();
167 Value *Ops[] = {Src};
168 Type *Tys[] = { Src->getType()->getVectorElementType(), Src->getType() };
169 auto Decl = Intrinsic::getDeclaration(M, ID, Tys);
170 return createCallHelper(Decl, Ops, Builder);
173 CallInst *IRBuilderBase::CreateFAddReduce(Value *Acc, Value *Src) {
174 Module *M = GetInsertBlock()->getParent()->getParent();
175 Value *Ops[] = {Acc, Src};
176 Type *Tys[] = {Src->getType()->getVectorElementType(), Acc->getType(),
178 auto Decl = Intrinsic::getDeclaration(
179 M, Intrinsic::experimental_vector_reduce_fadd, Tys);
180 return createCallHelper(Decl, Ops, this);
183 CallInst *IRBuilderBase::CreateFMulReduce(Value *Acc, Value *Src) {
184 Module *M = GetInsertBlock()->getParent()->getParent();
185 Value *Ops[] = {Acc, Src};
186 Type *Tys[] = {Src->getType()->getVectorElementType(), Acc->getType(),
188 auto Decl = Intrinsic::getDeclaration(
189 M, Intrinsic::experimental_vector_reduce_fmul, Tys);
190 return createCallHelper(Decl, Ops, this);
193 CallInst *IRBuilderBase::CreateAddReduce(Value *Src) {
194 return getReductionIntrinsic(this, Intrinsic::experimental_vector_reduce_add,
198 CallInst *IRBuilderBase::CreateMulReduce(Value *Src) {
199 return getReductionIntrinsic(this, Intrinsic::experimental_vector_reduce_mul,
203 CallInst *IRBuilderBase::CreateAndReduce(Value *Src) {
204 return getReductionIntrinsic(this, Intrinsic::experimental_vector_reduce_and,
208 CallInst *IRBuilderBase::CreateOrReduce(Value *Src) {
209 return getReductionIntrinsic(this, Intrinsic::experimental_vector_reduce_or,
213 CallInst *IRBuilderBase::CreateXorReduce(Value *Src) {
214 return getReductionIntrinsic(this, Intrinsic::experimental_vector_reduce_xor,
218 CallInst *IRBuilderBase::CreateIntMaxReduce(Value *Src, bool IsSigned) {
219 auto ID = IsSigned ? Intrinsic::experimental_vector_reduce_smax
220 : Intrinsic::experimental_vector_reduce_umax;
221 return getReductionIntrinsic(this, ID, Src);
224 CallInst *IRBuilderBase::CreateIntMinReduce(Value *Src, bool IsSigned) {
225 auto ID = IsSigned ? Intrinsic::experimental_vector_reduce_smin
226 : Intrinsic::experimental_vector_reduce_umin;
227 return getReductionIntrinsic(this, ID, Src);
230 CallInst *IRBuilderBase::CreateFPMaxReduce(Value *Src, bool NoNaN) {
231 auto Rdx = getReductionIntrinsic(
232 this, Intrinsic::experimental_vector_reduce_fmax, Src);
236 Rdx->setFastMathFlags(FMF);
241 CallInst *IRBuilderBase::CreateFPMinReduce(Value *Src, bool NoNaN) {
242 auto Rdx = getReductionIntrinsic(
243 this, Intrinsic::experimental_vector_reduce_fmin, Src);
247 Rdx->setFastMathFlags(FMF);
252 CallInst *IRBuilderBase::CreateLifetimeStart(Value *Ptr, ConstantInt *Size) {
253 assert(isa<PointerType>(Ptr->getType()) &&
254 "lifetime.start only applies to pointers.");
255 Ptr = getCastedInt8PtrValue(Ptr);
259 assert(Size->getType() == getInt64Ty() &&
260 "lifetime.start requires the size to be an i64");
261 Value *Ops[] = { Size, Ptr };
262 Module *M = BB->getParent()->getParent();
263 Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::lifetime_start,
265 return createCallHelper(TheFn, Ops, this);
268 CallInst *IRBuilderBase::CreateLifetimeEnd(Value *Ptr, ConstantInt *Size) {
269 assert(isa<PointerType>(Ptr->getType()) &&
270 "lifetime.end only applies to pointers.");
271 Ptr = getCastedInt8PtrValue(Ptr);
275 assert(Size->getType() == getInt64Ty() &&
276 "lifetime.end requires the size to be an i64");
277 Value *Ops[] = { Size, Ptr };
278 Module *M = BB->getParent()->getParent();
279 Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::lifetime_end,
281 return createCallHelper(TheFn, Ops, this);
284 CallInst *IRBuilderBase::CreateInvariantStart(Value *Ptr, ConstantInt *Size) {
286 assert(isa<PointerType>(Ptr->getType()) &&
287 "invariant.start only applies to pointers.");
288 Ptr = getCastedInt8PtrValue(Ptr);
292 assert(Size->getType() == getInt64Ty() &&
293 "invariant.start requires the size to be an i64");
295 Value *Ops[] = {Size, Ptr};
296 // Fill in the single overloaded type: memory object type.
297 Type *ObjectPtr[1] = {Ptr->getType()};
298 Module *M = BB->getParent()->getParent();
300 Intrinsic::getDeclaration(M, Intrinsic::invariant_start, ObjectPtr);
301 return createCallHelper(TheFn, Ops, this);
304 CallInst *IRBuilderBase::CreateAssumption(Value *Cond) {
305 assert(Cond->getType() == getInt1Ty() &&
306 "an assumption condition must be of type i1");
308 Value *Ops[] = { Cond };
309 Module *M = BB->getParent()->getParent();
310 Value *FnAssume = Intrinsic::getDeclaration(M, Intrinsic::assume);
311 return createCallHelper(FnAssume, Ops, this);
314 /// \brief Create a call to a Masked Load intrinsic.
315 /// \p Ptr - base pointer for the load
316 /// \p Align - alignment of the source location
317 /// \p Mask - vector of booleans which indicates what vector lanes should
318 /// be accessed in memory
319 /// \p PassThru - pass-through value that is used to fill the masked-off lanes
321 /// \p Name - name of the result variable
322 CallInst *IRBuilderBase::CreateMaskedLoad(Value *Ptr, unsigned Align,
323 Value *Mask, Value *PassThru,
325 PointerType *PtrTy = cast<PointerType>(Ptr->getType());
326 Type *DataTy = PtrTy->getElementType();
327 assert(DataTy->isVectorTy() && "Ptr should point to a vector");
329 PassThru = UndefValue::get(DataTy);
330 Type *OverloadedTypes[] = { DataTy, PtrTy };
331 Value *Ops[] = { Ptr, getInt32(Align), Mask, PassThru};
332 return CreateMaskedIntrinsic(Intrinsic::masked_load, Ops,
333 OverloadedTypes, Name);
336 /// \brief Create a call to a Masked Store intrinsic.
337 /// \p Val - data to be stored,
338 /// \p Ptr - base pointer for the store
339 /// \p Align - alignment of the destination location
340 /// \p Mask - vector of booleans which indicates what vector lanes should
341 /// be accessed in memory
342 CallInst *IRBuilderBase::CreateMaskedStore(Value *Val, Value *Ptr,
343 unsigned Align, Value *Mask) {
344 PointerType *PtrTy = cast<PointerType>(Ptr->getType());
345 Type *DataTy = PtrTy->getElementType();
346 assert(DataTy->isVectorTy() && "Ptr should point to a vector");
347 Type *OverloadedTypes[] = { DataTy, PtrTy };
348 Value *Ops[] = { Val, Ptr, getInt32(Align), Mask };
349 return CreateMaskedIntrinsic(Intrinsic::masked_store, Ops, OverloadedTypes);
352 /// Create a call to a Masked intrinsic, with given intrinsic Id,
353 /// an array of operands - Ops, and an array of overloaded types -
355 CallInst *IRBuilderBase::CreateMaskedIntrinsic(Intrinsic::ID Id,
356 ArrayRef<Value *> Ops,
357 ArrayRef<Type *> OverloadedTypes,
359 Module *M = BB->getParent()->getParent();
360 Value *TheFn = Intrinsic::getDeclaration(M, Id, OverloadedTypes);
361 return createCallHelper(TheFn, Ops, this, Name);
364 /// \brief Create a call to a Masked Gather intrinsic.
365 /// \p Ptrs - vector of pointers for loading
366 /// \p Align - alignment for one element
367 /// \p Mask - vector of booleans which indicates what vector lanes should
368 /// be accessed in memory
369 /// \p PassThru - pass-through value that is used to fill the masked-off lanes
371 /// \p Name - name of the result variable
372 CallInst *IRBuilderBase::CreateMaskedGather(Value *Ptrs, unsigned Align,
373 Value *Mask, Value *PassThru,
375 auto PtrsTy = cast<VectorType>(Ptrs->getType());
376 auto PtrTy = cast<PointerType>(PtrsTy->getElementType());
377 unsigned NumElts = PtrsTy->getVectorNumElements();
378 Type *DataTy = VectorType::get(PtrTy->getElementType(), NumElts);
381 Mask = Constant::getAllOnesValue(VectorType::get(Type::getInt1Ty(Context),
385 PassThru = UndefValue::get(DataTy);
387 Type *OverloadedTypes[] = {DataTy, PtrsTy};
388 Value * Ops[] = {Ptrs, getInt32(Align), Mask, PassThru};
390 // We specify only one type when we create this intrinsic. Types of other
391 // arguments are derived from this type.
392 return CreateMaskedIntrinsic(Intrinsic::masked_gather, Ops, OverloadedTypes,
396 /// \brief Create a call to a Masked Scatter intrinsic.
397 /// \p Data - data to be stored,
398 /// \p Ptrs - the vector of pointers, where the \p Data elements should be
400 /// \p Align - alignment for one element
401 /// \p Mask - vector of booleans which indicates what vector lanes should
402 /// be accessed in memory
403 CallInst *IRBuilderBase::CreateMaskedScatter(Value *Data, Value *Ptrs,
404 unsigned Align, Value *Mask) {
405 auto PtrsTy = cast<VectorType>(Ptrs->getType());
406 auto DataTy = cast<VectorType>(Data->getType());
407 unsigned NumElts = PtrsTy->getVectorNumElements();
410 auto PtrTy = cast<PointerType>(PtrsTy->getElementType());
411 assert(NumElts == DataTy->getVectorNumElements() &&
412 PtrTy->getElementType() == DataTy->getElementType() &&
413 "Incompatible pointer and data types");
417 Mask = Constant::getAllOnesValue(VectorType::get(Type::getInt1Ty(Context),
420 Type *OverloadedTypes[] = {DataTy, PtrsTy};
421 Value * Ops[] = {Data, Ptrs, getInt32(Align), Mask};
423 // We specify only one type when we create this intrinsic. Types of other
424 // arguments are derived from this type.
425 return CreateMaskedIntrinsic(Intrinsic::masked_scatter, Ops, OverloadedTypes);
428 template <typename T0, typename T1, typename T2, typename T3>
429 static std::vector<Value *>
430 getStatepointArgs(IRBuilderBase &B, uint64_t ID, uint32_t NumPatchBytes,
431 Value *ActualCallee, uint32_t Flags, ArrayRef<T0> CallArgs,
432 ArrayRef<T1> TransitionArgs, ArrayRef<T2> DeoptArgs,
433 ArrayRef<T3> GCArgs) {
434 std::vector<Value *> Args;
435 Args.push_back(B.getInt64(ID));
436 Args.push_back(B.getInt32(NumPatchBytes));
437 Args.push_back(ActualCallee);
438 Args.push_back(B.getInt32(CallArgs.size()));
439 Args.push_back(B.getInt32(Flags));
440 Args.insert(Args.end(), CallArgs.begin(), CallArgs.end());
441 Args.push_back(B.getInt32(TransitionArgs.size()));
442 Args.insert(Args.end(), TransitionArgs.begin(), TransitionArgs.end());
443 Args.push_back(B.getInt32(DeoptArgs.size()));
444 Args.insert(Args.end(), DeoptArgs.begin(), DeoptArgs.end());
445 Args.insert(Args.end(), GCArgs.begin(), GCArgs.end());
450 template <typename T0, typename T1, typename T2, typename T3>
451 static CallInst *CreateGCStatepointCallCommon(
452 IRBuilderBase *Builder, uint64_t ID, uint32_t NumPatchBytes,
453 Value *ActualCallee, uint32_t Flags, ArrayRef<T0> CallArgs,
454 ArrayRef<T1> TransitionArgs, ArrayRef<T2> DeoptArgs, ArrayRef<T3> GCArgs,
456 // Extract out the type of the callee.
457 PointerType *FuncPtrType = cast<PointerType>(ActualCallee->getType());
458 assert(isa<FunctionType>(FuncPtrType->getElementType()) &&
459 "actual callee must be a callable value");
461 Module *M = Builder->GetInsertBlock()->getParent()->getParent();
462 // Fill in the one generic type'd argument (the function is also vararg)
463 Type *ArgTypes[] = { FuncPtrType };
464 Function *FnStatepoint =
465 Intrinsic::getDeclaration(M, Intrinsic::experimental_gc_statepoint,
468 std::vector<llvm::Value *> Args =
469 getStatepointArgs(*Builder, ID, NumPatchBytes, ActualCallee, Flags,
470 CallArgs, TransitionArgs, DeoptArgs, GCArgs);
471 return createCallHelper(FnStatepoint, Args, Builder, Name);
474 CallInst *IRBuilderBase::CreateGCStatepointCall(
475 uint64_t ID, uint32_t NumPatchBytes, Value *ActualCallee,
476 ArrayRef<Value *> CallArgs, ArrayRef<Value *> DeoptArgs,
477 ArrayRef<Value *> GCArgs, const Twine &Name) {
478 return CreateGCStatepointCallCommon<Value *, Value *, Value *, Value *>(
479 this, ID, NumPatchBytes, ActualCallee, uint32_t(StatepointFlags::None),
480 CallArgs, None /* No Transition Args */, DeoptArgs, GCArgs, Name);
483 CallInst *IRBuilderBase::CreateGCStatepointCall(
484 uint64_t ID, uint32_t NumPatchBytes, Value *ActualCallee, uint32_t Flags,
485 ArrayRef<Use> CallArgs, ArrayRef<Use> TransitionArgs,
486 ArrayRef<Use> DeoptArgs, ArrayRef<Value *> GCArgs, const Twine &Name) {
487 return CreateGCStatepointCallCommon<Use, Use, Use, Value *>(
488 this, ID, NumPatchBytes, ActualCallee, Flags, CallArgs, TransitionArgs,
489 DeoptArgs, GCArgs, Name);
492 CallInst *IRBuilderBase::CreateGCStatepointCall(
493 uint64_t ID, uint32_t NumPatchBytes, Value *ActualCallee,
494 ArrayRef<Use> CallArgs, ArrayRef<Value *> DeoptArgs,
495 ArrayRef<Value *> GCArgs, const Twine &Name) {
496 return CreateGCStatepointCallCommon<Use, Value *, Value *, Value *>(
497 this, ID, NumPatchBytes, ActualCallee, uint32_t(StatepointFlags::None),
498 CallArgs, None, DeoptArgs, GCArgs, Name);
501 template <typename T0, typename T1, typename T2, typename T3>
502 static InvokeInst *CreateGCStatepointInvokeCommon(
503 IRBuilderBase *Builder, uint64_t ID, uint32_t NumPatchBytes,
504 Value *ActualInvokee, BasicBlock *NormalDest, BasicBlock *UnwindDest,
505 uint32_t Flags, ArrayRef<T0> InvokeArgs, ArrayRef<T1> TransitionArgs,
506 ArrayRef<T2> DeoptArgs, ArrayRef<T3> GCArgs, const Twine &Name) {
507 // Extract out the type of the callee.
508 PointerType *FuncPtrType = cast<PointerType>(ActualInvokee->getType());
509 assert(isa<FunctionType>(FuncPtrType->getElementType()) &&
510 "actual callee must be a callable value");
512 Module *M = Builder->GetInsertBlock()->getParent()->getParent();
513 // Fill in the one generic type'd argument (the function is also vararg)
514 Function *FnStatepoint = Intrinsic::getDeclaration(
515 M, Intrinsic::experimental_gc_statepoint, {FuncPtrType});
517 std::vector<llvm::Value *> Args =
518 getStatepointArgs(*Builder, ID, NumPatchBytes, ActualInvokee, Flags,
519 InvokeArgs, TransitionArgs, DeoptArgs, GCArgs);
520 return createInvokeHelper(FnStatepoint, NormalDest, UnwindDest, Args, Builder,
524 InvokeInst *IRBuilderBase::CreateGCStatepointInvoke(
525 uint64_t ID, uint32_t NumPatchBytes, Value *ActualInvokee,
526 BasicBlock *NormalDest, BasicBlock *UnwindDest,
527 ArrayRef<Value *> InvokeArgs, ArrayRef<Value *> DeoptArgs,
528 ArrayRef<Value *> GCArgs, const Twine &Name) {
529 return CreateGCStatepointInvokeCommon<Value *, Value *, Value *, Value *>(
530 this, ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest,
531 uint32_t(StatepointFlags::None), InvokeArgs, None /* No Transition Args*/,
532 DeoptArgs, GCArgs, Name);
535 InvokeInst *IRBuilderBase::CreateGCStatepointInvoke(
536 uint64_t ID, uint32_t NumPatchBytes, Value *ActualInvokee,
537 BasicBlock *NormalDest, BasicBlock *UnwindDest, uint32_t Flags,
538 ArrayRef<Use> InvokeArgs, ArrayRef<Use> TransitionArgs,
539 ArrayRef<Use> DeoptArgs, ArrayRef<Value *> GCArgs, const Twine &Name) {
540 return CreateGCStatepointInvokeCommon<Use, Use, Use, Value *>(
541 this, ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest, Flags,
542 InvokeArgs, TransitionArgs, DeoptArgs, GCArgs, Name);
545 InvokeInst *IRBuilderBase::CreateGCStatepointInvoke(
546 uint64_t ID, uint32_t NumPatchBytes, Value *ActualInvokee,
547 BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef<Use> InvokeArgs,
548 ArrayRef<Value *> DeoptArgs, ArrayRef<Value *> GCArgs, const Twine &Name) {
549 return CreateGCStatepointInvokeCommon<Use, Value *, Value *, Value *>(
550 this, ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest,
551 uint32_t(StatepointFlags::None), InvokeArgs, None, DeoptArgs, GCArgs,
555 CallInst *IRBuilderBase::CreateGCResult(Instruction *Statepoint,
558 Intrinsic::ID ID = Intrinsic::experimental_gc_result;
559 Module *M = BB->getParent()->getParent();
560 Type *Types[] = {ResultType};
561 Value *FnGCResult = Intrinsic::getDeclaration(M, ID, Types);
563 Value *Args[] = {Statepoint};
564 return createCallHelper(FnGCResult, Args, this, Name);
567 CallInst *IRBuilderBase::CreateGCRelocate(Instruction *Statepoint,
572 Module *M = BB->getParent()->getParent();
573 Type *Types[] = {ResultType};
574 Value *FnGCRelocate =
575 Intrinsic::getDeclaration(M, Intrinsic::experimental_gc_relocate, Types);
577 Value *Args[] = {Statepoint,
578 getInt32(BaseOffset),
579 getInt32(DerivedOffset)};
580 return createCallHelper(FnGCRelocate, Args, this, Name);
583 CallInst *IRBuilderBase::CreateBinaryIntrinsic(Intrinsic::ID ID,
584 Value *LHS, Value *RHS,
586 Module *M = BB->getParent()->getParent();
587 Function *Fn = Intrinsic::getDeclaration(M, ID, { LHS->getType() });
588 return createCallHelper(Fn, { LHS, RHS }, this, Name);