LLVM  4.0.0
IRBuilder.cpp
Go to the documentation of this file.
1 //===---- IRBuilder.cpp - Builder for LLVM Instrs -------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
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.
12 //
13 //===----------------------------------------------------------------------===//
14 
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"
21 using namespace llvm;
22 
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
26 /// created.
28  const Twine &Name,
29  unsigned AddressSpace) {
30  Constant *StrConstant = ConstantDataArray::getString(Context, Str);
31  Module &M = *BB->getParent()->getParent();
32  GlobalVariable *GV = new GlobalVariable(M, StrConstant->getType(),
34  StrConstant, Name, nullptr,
36  AddressSpace);
38  return GV;
39 }
40 
42  assert(BB && BB->getParent() && "No current function!");
43  return BB->getParent()->getReturnType();
44 }
45 
46 Value *IRBuilderBase::getCastedInt8PtrValue(Value *Ptr) {
47  PointerType *PT = cast<PointerType>(Ptr->getType());
48  if (PT->getElementType()->isIntegerTy(8))
49  return Ptr;
50 
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);
56  return BCI;
57 }
58 
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);
65  return CI;
66 }
67 
68 static InvokeInst *createInvokeHelper(Value *Invokee, BasicBlock *NormalDest,
69  BasicBlock *UnwindDest,
71  IRBuilderBase *Builder,
72  const Twine &Name = "") {
73  InvokeInst *II =
74  InvokeInst::Create(Invokee, NormalDest, UnwindDest, Ops, Name);
75  Builder->GetInsertBlock()->getInstList().insert(Builder->GetInsertPoint(),
76  II);
77  Builder->SetInstDebugLocation(II);
78  return II;
79 }
80 
82 CreateMemSet(Value *Ptr, Value *Val, Value *Size, unsigned Align,
83  bool isVolatile, MDNode *TBAATag, MDNode *ScopeTag,
84  MDNode *NoAliasTag) {
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);
90 
91  CallInst *CI = createCallHelper(TheFn, Ops, this);
92 
93  // Set the TBAA info if present.
94  if (TBAATag)
95  CI->setMetadata(LLVMContext::MD_tbaa, TBAATag);
96 
97  if (ScopeTag)
99 
100  if (NoAliasTag)
101  CI->setMetadata(LLVMContext::MD_noalias, NoAliasTag);
102 
103  return CI;
104 }
105 
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);
112 
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);
117 
118  CallInst *CI = createCallHelper(TheFn, Ops, this);
119 
120  // Set the TBAA info if present.
121  if (TBAATag)
122  CI->setMetadata(LLVMContext::MD_tbaa, TBAATag);
123 
124  // Set the TBAA Struct info if present.
125  if (TBAAStructTag)
126  CI->setMetadata(LLVMContext::MD_tbaa_struct, TBAAStructTag);
127 
128  if (ScopeTag)
130 
131  if (NoAliasTag)
132  CI->setMetadata(LLVMContext::MD_noalias, NoAliasTag);
133 
134  return CI;
135 }
136 
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);
143 
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);
148 
149  CallInst *CI = createCallHelper(TheFn, Ops, this);
150 
151  // Set the TBAA info if present.
152  if (TBAATag)
153  CI->setMetadata(LLVMContext::MD_tbaa, TBAATag);
154 
155  if (ScopeTag)
157 
158  if (NoAliasTag)
159  CI->setMetadata(LLVMContext::MD_noalias, NoAliasTag);
160 
161  return CI;
162 }
163 
165  assert(isa<PointerType>(Ptr->getType()) &&
166  "lifetime.start only applies to pointers.");
167  Ptr = getCastedInt8PtrValue(Ptr);
168  if (!Size)
169  Size = getInt64(-1);
170  else
171  assert(Size->getType() == getInt64Ty() &&
172  "lifetime.start requires the size to be an i64");
173  Value *Ops[] = { Size, Ptr };
174  Module *M = BB->getParent()->getParent();
175  Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::lifetime_start);
176  return createCallHelper(TheFn, Ops, this);
177 }
178 
180  assert(isa<PointerType>(Ptr->getType()) &&
181  "lifetime.end only applies to pointers.");
182  Ptr = getCastedInt8PtrValue(Ptr);
183  if (!Size)
184  Size = getInt64(-1);
185  else
186  assert(Size->getType() == getInt64Ty() &&
187  "lifetime.end requires the size to be an i64");
188  Value *Ops[] = { Size, Ptr };
189  Module *M = BB->getParent()->getParent();
190  Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::lifetime_end);
191  return createCallHelper(TheFn, Ops, this);
192 }
193 
195 
196  assert(isa<PointerType>(Ptr->getType()) &&
197  "invariant.start only applies to pointers.");
198  Ptr = getCastedInt8PtrValue(Ptr);
199  if (!Size)
200  Size = getInt64(-1);
201  else
202  assert(Size->getType() == getInt64Ty() &&
203  "invariant.start requires the size to be an i64");
204 
205  Value *Ops[] = {Size, Ptr};
206  // Fill in the single overloaded type: memory object type.
207  Type *ObjectPtr[1] = {Ptr->getType()};
208  Module *M = BB->getParent()->getParent();
209  Value *TheFn =
210  Intrinsic::getDeclaration(M, Intrinsic::invariant_start, ObjectPtr);
211  return createCallHelper(TheFn, Ops, this);
212 }
213 
215  assert(Cond->getType() == getInt1Ty() &&
216  "an assumption condition must be of type i1");
217 
218  Value *Ops[] = { Cond };
219  Module *M = BB->getParent()->getParent();
220  Value *FnAssume = Intrinsic::getDeclaration(M, Intrinsic::assume);
221  return createCallHelper(FnAssume, Ops, this);
222 }
223 
224 /// \brief Create a call to a Masked Load intrinsic.
225 /// \p Ptr - base pointer for the load
226 /// \p Align - alignment of the source location
227 /// \p Mask - vector of booleans which indicates what vector lanes should
228 /// be accessed in memory
229 /// \p PassThru - pass-through value that is used to fill the masked-off lanes
230 /// of the result
231 /// \p Name - name of the result variable
233  Value *Mask, Value *PassThru,
234  const Twine &Name) {
235  PointerType *PtrTy = cast<PointerType>(Ptr->getType());
236  Type *DataTy = PtrTy->getElementType();
237  assert(DataTy->isVectorTy() && "Ptr should point to a vector");
238  if (!PassThru)
239  PassThru = UndefValue::get(DataTy);
240  Type *OverloadedTypes[] = { DataTy, PtrTy };
241  Value *Ops[] = { Ptr, getInt32(Align), Mask, PassThru};
242  return CreateMaskedIntrinsic(Intrinsic::masked_load, Ops,
243  OverloadedTypes, Name);
244 }
245 
246 /// \brief Create a call to a Masked Store intrinsic.
247 /// \p Val - data to be stored,
248 /// \p Ptr - base pointer for the store
249 /// \p Align - alignment of the destination location
250 /// \p Mask - vector of booleans which indicates what vector lanes should
251 /// be accessed in memory
253  unsigned Align, Value *Mask) {
254  PointerType *PtrTy = cast<PointerType>(Ptr->getType());
255  Type *DataTy = PtrTy->getElementType();
256  assert(DataTy->isVectorTy() && "Ptr should point to a vector");
257  Type *OverloadedTypes[] = { DataTy, PtrTy };
258  Value *Ops[] = { Val, Ptr, getInt32(Align), Mask };
259  return CreateMaskedIntrinsic(Intrinsic::masked_store, Ops, OverloadedTypes);
260 }
261 
262 /// Create a call to a Masked intrinsic, with given intrinsic Id,
263 /// an array of operands - Ops, and an array of overloaded types -
264 /// OverloadedTypes.
265 CallInst *IRBuilderBase::CreateMaskedIntrinsic(Intrinsic::ID Id,
266  ArrayRef<Value *> Ops,
267  ArrayRef<Type *> OverloadedTypes,
268  const Twine &Name) {
269  Module *M = BB->getParent()->getParent();
270  Value *TheFn = Intrinsic::getDeclaration(M, Id, OverloadedTypes);
271  return createCallHelper(TheFn, Ops, this, Name);
272 }
273 
274 /// \brief Create a call to a Masked Gather intrinsic.
275 /// \p Ptrs - vector of pointers for loading
276 /// \p Align - alignment for one element
277 /// \p Mask - vector of booleans which indicates what vector lanes should
278 /// be accessed in memory
279 /// \p PassThru - pass-through value that is used to fill the masked-off lanes
280 /// of the result
281 /// \p Name - name of the result variable
283  Value *Mask, Value *PassThru,
284  const Twine& Name) {
285  auto PtrsTy = cast<VectorType>(Ptrs->getType());
286  auto PtrTy = cast<PointerType>(PtrsTy->getElementType());
287  unsigned NumElts = PtrsTy->getVectorNumElements();
288  Type *DataTy = VectorType::get(PtrTy->getElementType(), NumElts);
289 
290  if (!Mask)
292  NumElts));
293 
294  Value * Ops[] = {Ptrs, getInt32(Align), Mask, UndefValue::get(DataTy)};
295 
296  // We specify only one type when we create this intrinsic. Types of other
297  // arguments are derived from this type.
298  return CreateMaskedIntrinsic(Intrinsic::masked_gather, Ops, { DataTy }, Name);
299 }
300 
301 /// \brief Create a call to a Masked Scatter intrinsic.
302 /// \p Data - data to be stored,
303 /// \p Ptrs - the vector of pointers, where the \p Data elements should be
304 /// stored
305 /// \p Align - alignment for one element
306 /// \p Mask - vector of booleans which indicates what vector lanes should
307 /// be accessed in memory
309  unsigned Align, Value *Mask) {
310  auto PtrsTy = cast<VectorType>(Ptrs->getType());
311  auto DataTy = cast<VectorType>(Data->getType());
312  unsigned NumElts = PtrsTy->getVectorNumElements();
313 
314 #ifndef NDEBUG
315  auto PtrTy = cast<PointerType>(PtrsTy->getElementType());
316  assert(NumElts == DataTy->getVectorNumElements() &&
317  PtrTy->getElementType() == DataTy->getElementType() &&
318  "Incompatible pointer and data types");
319 #endif
320 
321  if (!Mask)
323  NumElts));
324  Value * Ops[] = {Data, Ptrs, getInt32(Align), Mask};
325 
326  // We specify only one type when we create this intrinsic. Types of other
327  // arguments are derived from this type.
328  return CreateMaskedIntrinsic(Intrinsic::masked_scatter, Ops, { DataTy });
329 }
330 
331 template <typename T0, typename T1, typename T2, typename T3>
332 static std::vector<Value *>
333 getStatepointArgs(IRBuilderBase &B, uint64_t ID, uint32_t NumPatchBytes,
334  Value *ActualCallee, uint32_t Flags, ArrayRef<T0> CallArgs,
335  ArrayRef<T1> TransitionArgs, ArrayRef<T2> DeoptArgs,
336  ArrayRef<T3> GCArgs) {
337  std::vector<Value *> Args;
338  Args.push_back(B.getInt64(ID));
339  Args.push_back(B.getInt32(NumPatchBytes));
340  Args.push_back(ActualCallee);
341  Args.push_back(B.getInt32(CallArgs.size()));
342  Args.push_back(B.getInt32(Flags));
343  Args.insert(Args.end(), CallArgs.begin(), CallArgs.end());
344  Args.push_back(B.getInt32(TransitionArgs.size()));
345  Args.insert(Args.end(), TransitionArgs.begin(), TransitionArgs.end());
346  Args.push_back(B.getInt32(DeoptArgs.size()));
347  Args.insert(Args.end(), DeoptArgs.begin(), DeoptArgs.end());
348  Args.insert(Args.end(), GCArgs.begin(), GCArgs.end());
349 
350  return Args;
351 }
352 
353 template <typename T0, typename T1, typename T2, typename T3>
355  IRBuilderBase *Builder, uint64_t ID, uint32_t NumPatchBytes,
356  Value *ActualCallee, uint32_t Flags, ArrayRef<T0> CallArgs,
357  ArrayRef<T1> TransitionArgs, ArrayRef<T2> DeoptArgs, ArrayRef<T3> GCArgs,
358  const Twine &Name) {
359  // Extract out the type of the callee.
360  PointerType *FuncPtrType = cast<PointerType>(ActualCallee->getType());
361  assert(isa<FunctionType>(FuncPtrType->getElementType()) &&
362  "actual callee must be a callable value");
363 
364  Module *M = Builder->GetInsertBlock()->getParent()->getParent();
365  // Fill in the one generic type'd argument (the function is also vararg)
366  Type *ArgTypes[] = { FuncPtrType };
367  Function *FnStatepoint =
368  Intrinsic::getDeclaration(M, Intrinsic::experimental_gc_statepoint,
369  ArgTypes);
370 
371  std::vector<llvm::Value *> Args =
372  getStatepointArgs(*Builder, ID, NumPatchBytes, ActualCallee, Flags,
373  CallArgs, TransitionArgs, DeoptArgs, GCArgs);
374  return createCallHelper(FnStatepoint, Args, Builder, Name);
375 }
376 
378  uint64_t ID, uint32_t NumPatchBytes, Value *ActualCallee,
379  ArrayRef<Value *> CallArgs, ArrayRef<Value *> DeoptArgs,
380  ArrayRef<Value *> GCArgs, const Twine &Name) {
381  return CreateGCStatepointCallCommon<Value *, Value *, Value *, Value *>(
382  this, ID, NumPatchBytes, ActualCallee, uint32_t(StatepointFlags::None),
383  CallArgs, None /* No Transition Args */, DeoptArgs, GCArgs, Name);
384 }
385 
387  uint64_t ID, uint32_t NumPatchBytes, Value *ActualCallee, uint32_t Flags,
388  ArrayRef<Use> CallArgs, ArrayRef<Use> TransitionArgs,
389  ArrayRef<Use> DeoptArgs, ArrayRef<Value *> GCArgs, const Twine &Name) {
390  return CreateGCStatepointCallCommon<Use, Use, Use, Value *>(
391  this, ID, NumPatchBytes, ActualCallee, Flags, CallArgs, TransitionArgs,
392  DeoptArgs, GCArgs, Name);
393 }
394 
396  uint64_t ID, uint32_t NumPatchBytes, Value *ActualCallee,
397  ArrayRef<Use> CallArgs, ArrayRef<Value *> DeoptArgs,
398  ArrayRef<Value *> GCArgs, const Twine &Name) {
399  return CreateGCStatepointCallCommon<Use, Value *, Value *, Value *>(
400  this, ID, NumPatchBytes, ActualCallee, uint32_t(StatepointFlags::None),
401  CallArgs, None, DeoptArgs, GCArgs, Name);
402 }
403 
404 template <typename T0, typename T1, typename T2, typename T3>
406  IRBuilderBase *Builder, uint64_t ID, uint32_t NumPatchBytes,
407  Value *ActualInvokee, BasicBlock *NormalDest, BasicBlock *UnwindDest,
408  uint32_t Flags, ArrayRef<T0> InvokeArgs, ArrayRef<T1> TransitionArgs,
409  ArrayRef<T2> DeoptArgs, ArrayRef<T3> GCArgs, const Twine &Name) {
410  // Extract out the type of the callee.
411  PointerType *FuncPtrType = cast<PointerType>(ActualInvokee->getType());
412  assert(isa<FunctionType>(FuncPtrType->getElementType()) &&
413  "actual callee must be a callable value");
414 
415  Module *M = Builder->GetInsertBlock()->getParent()->getParent();
416  // Fill in the one generic type'd argument (the function is also vararg)
417  Function *FnStatepoint = Intrinsic::getDeclaration(
418  M, Intrinsic::experimental_gc_statepoint, {FuncPtrType});
419 
420  std::vector<llvm::Value *> Args =
421  getStatepointArgs(*Builder, ID, NumPatchBytes, ActualInvokee, Flags,
422  InvokeArgs, TransitionArgs, DeoptArgs, GCArgs);
423  return createInvokeHelper(FnStatepoint, NormalDest, UnwindDest, Args, Builder,
424  Name);
425 }
426 
428  uint64_t ID, uint32_t NumPatchBytes, Value *ActualInvokee,
429  BasicBlock *NormalDest, BasicBlock *UnwindDest,
430  ArrayRef<Value *> InvokeArgs, ArrayRef<Value *> DeoptArgs,
431  ArrayRef<Value *> GCArgs, const Twine &Name) {
432  return CreateGCStatepointInvokeCommon<Value *, Value *, Value *, Value *>(
433  this, ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest,
434  uint32_t(StatepointFlags::None), InvokeArgs, None /* No Transition Args*/,
435  DeoptArgs, GCArgs, Name);
436 }
437 
439  uint64_t ID, uint32_t NumPatchBytes, Value *ActualInvokee,
440  BasicBlock *NormalDest, BasicBlock *UnwindDest, uint32_t Flags,
441  ArrayRef<Use> InvokeArgs, ArrayRef<Use> TransitionArgs,
442  ArrayRef<Use> DeoptArgs, ArrayRef<Value *> GCArgs, const Twine &Name) {
443  return CreateGCStatepointInvokeCommon<Use, Use, Use, Value *>(
444  this, ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest, Flags,
445  InvokeArgs, TransitionArgs, DeoptArgs, GCArgs, Name);
446 }
447 
449  uint64_t ID, uint32_t NumPatchBytes, Value *ActualInvokee,
450  BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef<Use> InvokeArgs,
451  ArrayRef<Value *> DeoptArgs, ArrayRef<Value *> GCArgs, const Twine &Name) {
452  return CreateGCStatepointInvokeCommon<Use, Value *, Value *, Value *>(
453  this, ID, NumPatchBytes, ActualInvokee, NormalDest, UnwindDest,
454  uint32_t(StatepointFlags::None), InvokeArgs, None, DeoptArgs, GCArgs,
455  Name);
456 }
457 
459  Type *ResultType,
460  const Twine &Name) {
461  Intrinsic::ID ID = Intrinsic::experimental_gc_result;
462  Module *M = BB->getParent()->getParent();
463  Type *Types[] = {ResultType};
464  Value *FnGCResult = Intrinsic::getDeclaration(M, ID, Types);
465 
466  Value *Args[] = {Statepoint};
467  return createCallHelper(FnGCResult, Args, this, Name);
468 }
469 
471  int BaseOffset,
472  int DerivedOffset,
473  Type *ResultType,
474  const Twine &Name) {
475  Module *M = BB->getParent()->getParent();
476  Type *Types[] = {ResultType};
477  Value *FnGCRelocate =
478  Intrinsic::getDeclaration(M, Intrinsic::experimental_gc_relocate, Types);
479 
480  Value *Args[] = {Statepoint,
481  getInt32(BaseOffset),
482  getInt32(DerivedOffset)};
483  return createCallHelper(FnGCRelocate, Args, this, Name);
484 }
Common base class shared among various IRBuilders.
Definition: IRBuilder.h:89
IntegerType * getType() const
getType - Specialize the getType() method to always return an IntegerType, which reduces the amount o...
Definition: Constants.h:177
static Constant * getString(LLVMContext &Context, StringRef Initializer, bool AddNull=true)
This method constructs a CDS and initializes it with a text string.
Definition: Constants.cpp:2471
static IntegerType * getInt1Ty(LLVMContext &C)
Definition: Type.cpp:166
BasicBlock::iterator GetInsertPoint() const
Definition: IRBuilder.h:122
CallInst * CreateInvariantStart(Value *Ptr, ConstantInt *Size=nullptr)
Create a call to invariant.start intrinsic.
Definition: IRBuilder.cpp:194
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:52
iterator end() const
Definition: ArrayRef.h:130
CallInst * CreateGCRelocate(Instruction *Statepoint, int BaseOffset, int DerivedOffset, Type *ResultType, const Twine &Name="")
Create a call to the experimental.gc.relocate intrinsics to project the relocated value of one pointe...
Definition: IRBuilder.cpp:470
This class represents a function call, abstracting a target machine's calling convention.
Like Internal, but omit from symbol table.
Definition: GlobalValue.h:57
InvokeInst * CreateGCStatepointInvoke(uint64_t ID, uint32_t NumPatchBytes, Value *ActualInvokee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value * > InvokeArgs, ArrayRef< Value * > DeoptArgs, ArrayRef< Value * > GCArgs, const Twine &Name="")
brief Create an invoke to the experimental.gc.statepoint intrinsic to start a new statepoint sequence...
Definition: IRBuilder.cpp:427
Type * getReturnType() const
Returns the type of the ret val.
Definition: Function.cpp:238
const Function * getParent() const
Return the enclosing method, or null if none.
Definition: BasicBlock.h:100
Metadata node.
Definition: Metadata.h:830
CallInst * CreateMemSet(Value *Ptr, Value *Val, uint64_t Size, unsigned Align, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert a memset to the specified pointer and the specified value.
Definition: IRBuilder.h:404
unsigned getAddressSpace() const
Return the address space of the Pointer type.
Definition: DerivedTypes.h:471
Type * getElementType() const
Definition: DerivedTypes.h:462
LLVMContext & Context
Definition: IRBuilder.h:95
struct fuzzer::@269 Flags
static CallInst * CreateGCStatepointCallCommon(IRBuilderBase *Builder, uint64_t ID, uint32_t NumPatchBytes, Value *ActualCallee, uint32_t Flags, ArrayRef< T0 > CallArgs, ArrayRef< T1 > TransitionArgs, ArrayRef< T2 > DeoptArgs, ArrayRef< T3 > GCArgs, const Twine &Name)
Definition: IRBuilder.cpp:354
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
IntegerType * getInt64Ty()
Fetch the type representing a 64-bit integer.
Definition: IRBuilder.h:352
CallInst * CreateMaskedGather(Value *Ptrs, unsigned Align, Value *Mask=nullptr, Value *PassThru=nullptr, const Twine &Name="")
Create a call to Masked Gather intrinsic.
Definition: IRBuilder.cpp:282
BasicBlock * BB
Definition: IRBuilder.h:93
CallInst * CreateMemMove(Value *Dst, Value *Src, uint64_t Size, unsigned Align, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert a memmove between the specified pointers.
Definition: IRBuilder.h:443
This class represents a no-op cast from one type to another.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
Function * getDeclaration(Module *M, ID id, ArrayRef< Type * > Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
Definition: Function.cpp:949
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:141
Class to represent pointers.
Definition: DerivedTypes.h:443
LLVM Basic Block Representation.
Definition: BasicBlock.h:51
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
ConstantInt * getInt1(bool V)
Get a constant value representing either true or false.
Definition: IRBuilder.h:282
Type * getCurrentFunctionReturnType() const
Get the return type of the current function that we're emitting into.
Definition: IRBuilder.cpp:41
This is an important base class in LLVM.
Definition: Constant.h:42
static InvokeInst * CreateGCStatepointInvokeCommon(IRBuilderBase *Builder, uint64_t ID, uint32_t NumPatchBytes, Value *ActualInvokee, BasicBlock *NormalDest, BasicBlock *UnwindDest, uint32_t Flags, ArrayRef< T0 > InvokeArgs, ArrayRef< T1 > TransitionArgs, ArrayRef< T2 > DeoptArgs, ArrayRef< T3 > GCArgs, const Twine &Name)
Definition: IRBuilder.cpp:405
CallInst * CreateGCStatepointCall(uint64_t ID, uint32_t NumPatchBytes, Value *ActualCallee, ArrayRef< Value * > CallArgs, ArrayRef< Value * > DeoptArgs, ArrayRef< Value * > GCArgs, const Twine &Name="")
Create a call to the experimental.gc.statepoint intrinsic to start a new statepoint sequence...
Definition: IRBuilder.cpp:377
const InstListType & getInstList() const
Return the underlying instruction list container.
Definition: BasicBlock.h:249
iterator begin() const
Definition: ArrayRef.h:129
A specialization of it's base class for read-write access to a gc.statepoint.
Definition: Statepoint.h:313
ConstantInt * getInt64(uint64_t C)
Get a constant 64-bit value.
Definition: IRBuilder.h:312
static Constant * getAllOnesValue(Type *Ty)
Get the all ones value.
Definition: Constants.cpp:249
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
Definition: Constants.cpp:1337
PointerType * getInt8PtrTy(unsigned AddrSpace=0)
Fetch the type representing a pointer to an 8-bit integer value.
Definition: IRBuilder.h:385
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
Definition: Metadata.cpp:1183
static InvokeInst * Create(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, const Twine &NameStr, Instruction *InsertBefore=nullptr)
CallInst * CreateLifetimeEnd(Value *Ptr, ConstantInt *Size=nullptr)
Create a lifetime.end intrinsic.
Definition: IRBuilder.cpp:179
This is the shared class of boolean and integer constants.
Definition: Constants.h:88
GlobalVariable * CreateGlobalString(StringRef Str, const Twine &Name="", unsigned AddressSpace=0)
Make a new global variable with initializer type i8*.
Definition: IRBuilder.cpp:27
CallInst * CreateAssumption(Value *Cond)
Create an assume intrinsic call that allows the optimizer to assume that the provided condition will ...
Definition: IRBuilder.cpp:214
static CallInst * Create(Value *Func, ArrayRef< Value * > Args, ArrayRef< OperandBundleDef > Bundles=None, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:230
AddressSpace
Definition: NVPTXBaseInfo.h:22
static InvokeInst * createInvokeHelper(Value *Invokee, BasicBlock *NormalDest, BasicBlock *UnwindDest, ArrayRef< Value * > Ops, IRBuilderBase *Builder, const Twine &Name="")
Definition: IRBuilder.cpp:68
CallInst * CreateMaskedStore(Value *Val, Value *Ptr, unsigned Align, Value *Mask)
Create a call to Masked Store intrinsic.
Definition: IRBuilder.cpp:252
ConstantInt * getInt32(uint32_t C)
Get a constant 32-bit value.
Definition: IRBuilder.h:307
BasicBlock * GetInsertBlock() const
Definition: IRBuilder.h:121
static std::vector< Value * > getStatepointArgs(IRBuilderBase &B, uint64_t ID, uint32_t NumPatchBytes, Value *ActualCallee, uint32_t Flags, ArrayRef< T0 > CallArgs, ArrayRef< T1 > TransitionArgs, ArrayRef< T2 > DeoptArgs, ArrayRef< T3 > GCArgs)
Definition: IRBuilder.cpp:333
CallInst * CreateMaskedLoad(Value *Ptr, unsigned Align, Value *Mask, Value *PassThru=nullptr, const Twine &Name="")
Create a call to Masked Load intrinsic.
Definition: IRBuilder.cpp:232
bool isIntegerTy() const
True if this is an instance of IntegerType.
Definition: Type.h:195
IntegerType * getInt1Ty()
Fetch the type representing a single bit.
Definition: IRBuilder.h:332
iterator insert(iterator where, pointer New)
Definition: ilist.h:241
CallInst * CreateMemCpy(Value *Dst, Value *Src, uint64_t Size, unsigned Align, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *TBAAStructTag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert a memcpy between the specified pointers.
Definition: IRBuilder.h:422
void setUnnamedAddr(UnnamedAddr Val)
Definition: GlobalValue.h:203
CallInst * CreateGCResult(Instruction *Statepoint, Type *ResultType, const Twine &Name="")
Create a call to the experimental.gc.result intrinsic to extract the result from a call wrapped in a ...
Definition: IRBuilder.cpp:458
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
CallInst * CreateMaskedScatter(Value *Val, Value *Ptrs, unsigned Align, Value *Mask=nullptr)
Create a call to Masked Scatter intrinsic.
Definition: IRBuilder.cpp:308
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:537
LLVM Value Representation.
Definition: Value.h:71
static VectorType * get(Type *ElementType, unsigned NumElements)
This static method is the primary way to construct an VectorType.
Definition: Type.cpp:631
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
Definition: BitmaskEnum.h:81
Invoke instruction.
static CallInst * createCallHelper(Value *Callee, ArrayRef< Value * > Ops, IRBuilderBase *Builder, const Twine &Name="")
Definition: IRBuilder.cpp:59
CallInst * CreateLifetimeStart(Value *Ptr, ConstantInt *Size=nullptr)
Create a lifetime.start intrinsic.
Definition: IRBuilder.cpp:164
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47
static bool isVolatile(Instruction *Inst)
int * Ptr
BasicBlock::iterator InsertPt
Definition: IRBuilder.h:94
void SetInstDebugLocation(Instruction *I) const
If this builder has a current debug location, set it on the specified instruction.
Definition: IRBuilder.h:158