Chris Lattner | 17079fc | 2009-12-28 21:28:46 +0000 | [diff] [blame] | 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 | |
Chandler Carruth | 9fb823b | 2013-01-02 11:36:10 +0000 | [diff] [blame] | 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" |
Chris Lattner | 17079fc | 2009-12-28 21:28:46 +0000 | [diff] [blame] | 20 | using namespace llvm; |
| 21 | |
| 22 | /// CreateGlobalString - Make a new global variable with an initializer that |
Dan Gohman | 97c5902 | 2010-02-10 20:04:19 +0000 | [diff] [blame] | 23 | /// has array of i8 type filled in with the nul terminated string value |
Chris Lattner | 17079fc | 2009-12-28 21:28:46 +0000 | [diff] [blame] | 24 | /// specified. If Name is specified, it is the name of the global variable |
| 25 | /// created. |
David Blaikie | aa41cd5 | 2015-04-03 21:33:42 +0000 | [diff] [blame^] | 26 | GlobalVariable *IRBuilderBase::CreateGlobalString(StringRef Str, |
| 27 | const Twine &Name) { |
Chris Lattner | cf9e8f6 | 2012-02-05 02:29:43 +0000 | [diff] [blame] | 28 | Constant *StrConstant = ConstantDataArray::getString(Context, Str); |
Chris Lattner | 17079fc | 2009-12-28 21:28:46 +0000 | [diff] [blame] | 29 | Module &M = *BB->getParent()->getParent(); |
| 30 | GlobalVariable *GV = new GlobalVariable(M, StrConstant->getType(), |
Benjamin Kramer | f1fd6e3 | 2011-12-22 14:22:14 +0000 | [diff] [blame] | 31 | true, GlobalValue::PrivateLinkage, |
Hans Wennborg | cbe34b4 | 2012-06-23 11:37:03 +0000 | [diff] [blame] | 32 | StrConstant); |
Chris Lattner | 17079fc | 2009-12-28 21:28:46 +0000 | [diff] [blame] | 33 | GV->setName(Name); |
Nick Lewycky | 561f175 | 2011-04-07 00:14:29 +0000 | [diff] [blame] | 34 | GV->setUnnamedAddr(true); |
Chris Lattner | 17079fc | 2009-12-28 21:28:46 +0000 | [diff] [blame] | 35 | return GV; |
| 36 | } |
Chris Lattner | 7ef1cac | 2009-12-28 21:45:40 +0000 | [diff] [blame] | 37 | |
Chris Lattner | b1907b2 | 2011-07-12 04:14:22 +0000 | [diff] [blame] | 38 | Type *IRBuilderBase::getCurrentFunctionReturnType() const { |
Chris Lattner | 49f9f76 | 2009-12-28 21:50:56 +0000 | [diff] [blame] | 39 | assert(BB && BB->getParent() && "No current function!"); |
| 40 | return BB->getParent()->getReturnType(); |
| 41 | } |
Chris Lattner | 143a07c | 2010-12-26 22:49:25 +0000 | [diff] [blame] | 42 | |
| 43 | Value *IRBuilderBase::getCastedInt8PtrValue(Value *Ptr) { |
Chris Lattner | 229907c | 2011-07-18 04:54:35 +0000 | [diff] [blame] | 44 | PointerType *PT = cast<PointerType>(Ptr->getType()); |
Chris Lattner | 143a07c | 2010-12-26 22:49:25 +0000 | [diff] [blame] | 45 | if (PT->getElementType()->isIntegerTy(8)) |
| 46 | return Ptr; |
| 47 | |
| 48 | // Otherwise, we need to insert a bitcast. |
| 49 | PT = getInt8PtrTy(PT->getAddressSpace()); |
| 50 | BitCastInst *BCI = new BitCastInst(Ptr, PT, ""); |
| 51 | BB->getInstList().insert(InsertPt, BCI); |
| 52 | SetInstDebugLocation(BCI); |
| 53 | return BCI; |
| 54 | } |
| 55 | |
Jay Foad | 5bd375a | 2011-07-15 08:37:34 +0000 | [diff] [blame] | 56 | static CallInst *createCallHelper(Value *Callee, ArrayRef<Value *> Ops, |
Philip Reames | 4750dd1 | 2014-12-30 05:55:58 +0000 | [diff] [blame] | 57 | IRBuilderBase *Builder, |
| 58 | const Twine& Name="") { |
| 59 | CallInst *CI = CallInst::Create(Callee, Ops, Name); |
Chris Lattner | 143a07c | 2010-12-26 22:49:25 +0000 | [diff] [blame] | 60 | Builder->GetInsertBlock()->getInstList().insert(Builder->GetInsertPoint(),CI); |
| 61 | Builder->SetInstDebugLocation(CI); |
| 62 | return CI; |
| 63 | } |
| 64 | |
Chris Lattner | 143a07c | 2010-12-26 22:49:25 +0000 | [diff] [blame] | 65 | CallInst *IRBuilderBase:: |
| 66 | CreateMemSet(Value *Ptr, Value *Val, Value *Size, unsigned Align, |
Hal Finkel | 9414665 | 2014-07-24 14:25:39 +0000 | [diff] [blame] | 67 | bool isVolatile, MDNode *TBAATag, MDNode *ScopeTag, |
| 68 | MDNode *NoAliasTag) { |
Chris Lattner | 143a07c | 2010-12-26 22:49:25 +0000 | [diff] [blame] | 69 | Ptr = getCastedInt8PtrValue(Ptr); |
| 70 | Value *Ops[] = { Ptr, Val, Size, getInt32(Align), getInt1(isVolatile) }; |
Jay Foad | b804a2b | 2011-07-12 14:06:48 +0000 | [diff] [blame] | 71 | Type *Tys[] = { Ptr->getType(), Size->getType() }; |
Chris Lattner | 143a07c | 2010-12-26 22:49:25 +0000 | [diff] [blame] | 72 | Module *M = BB->getParent()->getParent(); |
Benjamin Kramer | e6e1933 | 2011-07-14 17:45:39 +0000 | [diff] [blame] | 73 | Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys); |
Chris Lattner | 143a07c | 2010-12-26 22:49:25 +0000 | [diff] [blame] | 74 | |
Jay Foad | 5bd375a | 2011-07-15 08:37:34 +0000 | [diff] [blame] | 75 | CallInst *CI = createCallHelper(TheFn, Ops, this); |
Chris Lattner | 143a07c | 2010-12-26 22:49:25 +0000 | [diff] [blame] | 76 | |
| 77 | // Set the TBAA info if present. |
| 78 | if (TBAATag) |
| 79 | CI->setMetadata(LLVMContext::MD_tbaa, TBAATag); |
Hal Finkel | 9414665 | 2014-07-24 14:25:39 +0000 | [diff] [blame] | 80 | |
| 81 | if (ScopeTag) |
| 82 | CI->setMetadata(LLVMContext::MD_alias_scope, ScopeTag); |
| 83 | |
| 84 | if (NoAliasTag) |
| 85 | CI->setMetadata(LLVMContext::MD_noalias, NoAliasTag); |
| 86 | |
Chris Lattner | 143a07c | 2010-12-26 22:49:25 +0000 | [diff] [blame] | 87 | return CI; |
| 88 | } |
| 89 | |
| 90 | CallInst *IRBuilderBase:: |
| 91 | CreateMemCpy(Value *Dst, Value *Src, Value *Size, unsigned Align, |
Hal Finkel | 9414665 | 2014-07-24 14:25:39 +0000 | [diff] [blame] | 92 | bool isVolatile, MDNode *TBAATag, MDNode *TBAAStructTag, |
| 93 | MDNode *ScopeTag, MDNode *NoAliasTag) { |
Chris Lattner | 143a07c | 2010-12-26 22:49:25 +0000 | [diff] [blame] | 94 | Dst = getCastedInt8PtrValue(Dst); |
| 95 | Src = getCastedInt8PtrValue(Src); |
| 96 | |
| 97 | Value *Ops[] = { Dst, Src, Size, getInt32(Align), getInt1(isVolatile) }; |
Jay Foad | b804a2b | 2011-07-12 14:06:48 +0000 | [diff] [blame] | 98 | Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; |
Chris Lattner | 143a07c | 2010-12-26 22:49:25 +0000 | [diff] [blame] | 99 | Module *M = BB->getParent()->getParent(); |
Benjamin Kramer | e6e1933 | 2011-07-14 17:45:39 +0000 | [diff] [blame] | 100 | Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memcpy, Tys); |
Chris Lattner | 143a07c | 2010-12-26 22:49:25 +0000 | [diff] [blame] | 101 | |
Jay Foad | 5bd375a | 2011-07-15 08:37:34 +0000 | [diff] [blame] | 102 | CallInst *CI = createCallHelper(TheFn, Ops, this); |
Chris Lattner | 143a07c | 2010-12-26 22:49:25 +0000 | [diff] [blame] | 103 | |
| 104 | // Set the TBAA info if present. |
| 105 | if (TBAATag) |
| 106 | CI->setMetadata(LLVMContext::MD_tbaa, TBAATag); |
Dan Gohman | 099727f | 2012-09-26 22:17:14 +0000 | [diff] [blame] | 107 | |
| 108 | // Set the TBAA Struct info if present. |
| 109 | if (TBAAStructTag) |
| 110 | CI->setMetadata(LLVMContext::MD_tbaa_struct, TBAAStructTag); |
Hal Finkel | 9414665 | 2014-07-24 14:25:39 +0000 | [diff] [blame] | 111 | |
| 112 | if (ScopeTag) |
| 113 | CI->setMetadata(LLVMContext::MD_alias_scope, ScopeTag); |
| 114 | |
| 115 | if (NoAliasTag) |
| 116 | CI->setMetadata(LLVMContext::MD_noalias, NoAliasTag); |
| 117 | |
Chris Lattner | 143a07c | 2010-12-26 22:49:25 +0000 | [diff] [blame] | 118 | return CI; |
| 119 | } |
| 120 | |
| 121 | CallInst *IRBuilderBase:: |
| 122 | CreateMemMove(Value *Dst, Value *Src, Value *Size, unsigned Align, |
Hal Finkel | 9414665 | 2014-07-24 14:25:39 +0000 | [diff] [blame] | 123 | bool isVolatile, MDNode *TBAATag, MDNode *ScopeTag, |
| 124 | MDNode *NoAliasTag) { |
Chris Lattner | 143a07c | 2010-12-26 22:49:25 +0000 | [diff] [blame] | 125 | Dst = getCastedInt8PtrValue(Dst); |
| 126 | Src = getCastedInt8PtrValue(Src); |
| 127 | |
| 128 | Value *Ops[] = { Dst, Src, Size, getInt32(Align), getInt1(isVolatile) }; |
Jay Foad | b804a2b | 2011-07-12 14:06:48 +0000 | [diff] [blame] | 129 | Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; |
Chris Lattner | 143a07c | 2010-12-26 22:49:25 +0000 | [diff] [blame] | 130 | Module *M = BB->getParent()->getParent(); |
Benjamin Kramer | e6e1933 | 2011-07-14 17:45:39 +0000 | [diff] [blame] | 131 | Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memmove, Tys); |
Chris Lattner | 143a07c | 2010-12-26 22:49:25 +0000 | [diff] [blame] | 132 | |
Jay Foad | 5bd375a | 2011-07-15 08:37:34 +0000 | [diff] [blame] | 133 | CallInst *CI = createCallHelper(TheFn, Ops, this); |
Chris Lattner | 143a07c | 2010-12-26 22:49:25 +0000 | [diff] [blame] | 134 | |
| 135 | // Set the TBAA info if present. |
| 136 | if (TBAATag) |
| 137 | CI->setMetadata(LLVMContext::MD_tbaa, TBAATag); |
Hal Finkel | 9414665 | 2014-07-24 14:25:39 +0000 | [diff] [blame] | 138 | |
| 139 | if (ScopeTag) |
| 140 | CI->setMetadata(LLVMContext::MD_alias_scope, ScopeTag); |
| 141 | |
| 142 | if (NoAliasTag) |
| 143 | CI->setMetadata(LLVMContext::MD_noalias, NoAliasTag); |
| 144 | |
Chris Lattner | 143a07c | 2010-12-26 22:49:25 +0000 | [diff] [blame] | 145 | return CI; |
| 146 | } |
Nick Lewycky | babca9a | 2011-05-21 23:14:36 +0000 | [diff] [blame] | 147 | |
| 148 | CallInst *IRBuilderBase::CreateLifetimeStart(Value *Ptr, ConstantInt *Size) { |
| 149 | assert(isa<PointerType>(Ptr->getType()) && |
Bill Wendling | ea6397f | 2012-07-19 00:11:40 +0000 | [diff] [blame] | 150 | "lifetime.start only applies to pointers."); |
Nick Lewycky | babca9a | 2011-05-21 23:14:36 +0000 | [diff] [blame] | 151 | Ptr = getCastedInt8PtrValue(Ptr); |
| 152 | if (!Size) |
| 153 | Size = getInt64(-1); |
| 154 | else |
| 155 | assert(Size->getType() == getInt64Ty() && |
Bill Wendling | ea6397f | 2012-07-19 00:11:40 +0000 | [diff] [blame] | 156 | "lifetime.start requires the size to be an i64"); |
Nick Lewycky | babca9a | 2011-05-21 23:14:36 +0000 | [diff] [blame] | 157 | Value *Ops[] = { Size, Ptr }; |
| 158 | Module *M = BB->getParent()->getParent(); |
| 159 | Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::lifetime_start); |
Jay Foad | 5bd375a | 2011-07-15 08:37:34 +0000 | [diff] [blame] | 160 | return createCallHelper(TheFn, Ops, this); |
Nick Lewycky | babca9a | 2011-05-21 23:14:36 +0000 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | CallInst *IRBuilderBase::CreateLifetimeEnd(Value *Ptr, ConstantInt *Size) { |
| 164 | assert(isa<PointerType>(Ptr->getType()) && |
Bill Wendling | ea6397f | 2012-07-19 00:11:40 +0000 | [diff] [blame] | 165 | "lifetime.end only applies to pointers."); |
Nick Lewycky | babca9a | 2011-05-21 23:14:36 +0000 | [diff] [blame] | 166 | Ptr = getCastedInt8PtrValue(Ptr); |
| 167 | if (!Size) |
| 168 | Size = getInt64(-1); |
| 169 | else |
| 170 | assert(Size->getType() == getInt64Ty() && |
Bill Wendling | ea6397f | 2012-07-19 00:11:40 +0000 | [diff] [blame] | 171 | "lifetime.end requires the size to be an i64"); |
Nick Lewycky | babca9a | 2011-05-21 23:14:36 +0000 | [diff] [blame] | 172 | Value *Ops[] = { Size, Ptr }; |
| 173 | Module *M = BB->getParent()->getParent(); |
| 174 | Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::lifetime_end); |
Jay Foad | 5bd375a | 2011-07-15 08:37:34 +0000 | [diff] [blame] | 175 | return createCallHelper(TheFn, Ops, this); |
Nick Lewycky | babca9a | 2011-05-21 23:14:36 +0000 | [diff] [blame] | 176 | } |
Hal Finkel | 6f814db | 2014-10-15 23:44:22 +0000 | [diff] [blame] | 177 | |
| 178 | CallInst *IRBuilderBase::CreateAssumption(Value *Cond) { |
| 179 | assert(Cond->getType() == getInt1Ty() && |
| 180 | "an assumption condition must be of type i1"); |
| 181 | |
| 182 | Value *Ops[] = { Cond }; |
| 183 | Module *M = BB->getParent()->getParent(); |
| 184 | Value *FnAssume = Intrinsic::getDeclaration(M, Intrinsic::assume); |
| 185 | return createCallHelper(FnAssume, Ops, this); |
| 186 | } |
| 187 | |
Elena Demikhovsky | f1de34b | 2014-12-04 09:40:44 +0000 | [diff] [blame] | 188 | /// Create a call to a Masked Load intrinsic. |
Elena Demikhovsky | 84d1997 | 2014-12-30 14:28:14 +0000 | [diff] [blame] | 189 | /// Ptr - the base pointer for the load |
| 190 | /// Align - alignment of the source location |
| 191 | /// Mask - an vector of booleans which indicates what vector lanes should |
| 192 | /// be accessed in memory |
| 193 | /// PassThru - a pass-through value that is used to fill the masked-off lanes |
| 194 | /// of the result |
| 195 | /// Name - name of the result variable |
| 196 | CallInst *IRBuilderBase::CreateMaskedLoad(Value *Ptr, unsigned Align, |
| 197 | Value *Mask, Value *PassThru, |
| 198 | const Twine &Name) { |
| 199 | assert(Ptr->getType()->isPointerTy() && "Ptr must be of pointer type"); |
| 200 | // DataTy is the overloaded type |
| 201 | Type *DataTy = cast<PointerType>(Ptr->getType())->getElementType(); |
| 202 | assert(DataTy->isVectorTy() && "Ptr should point to a vector"); |
| 203 | if (!PassThru) |
| 204 | PassThru = UndefValue::get(DataTy); |
| 205 | Value *Ops[] = { Ptr, getInt32(Align), Mask, PassThru}; |
| 206 | return CreateMaskedIntrinsic(Intrinsic::masked_load, Ops, DataTy, Name); |
Elena Demikhovsky | f1de34b | 2014-12-04 09:40:44 +0000 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | /// Create a call to a Masked Store intrinsic. |
Elena Demikhovsky | 84d1997 | 2014-12-30 14:28:14 +0000 | [diff] [blame] | 210 | /// Val - the data to be stored, |
| 211 | /// Ptr - the base pointer for the store |
| 212 | /// Align - alignment of the destination location |
| 213 | /// Mask - an vector of booleans which indicates what vector lanes should |
| 214 | /// be accessed in memory |
| 215 | CallInst *IRBuilderBase::CreateMaskedStore(Value *Val, Value *Ptr, |
| 216 | unsigned Align, Value *Mask) { |
| 217 | Value *Ops[] = { Val, Ptr, getInt32(Align), Mask }; |
| 218 | // Type of the data to be stored - the only one overloaded type |
| 219 | return CreateMaskedIntrinsic(Intrinsic::masked_store, Ops, Val->getType()); |
Elena Demikhovsky | f1de34b | 2014-12-04 09:40:44 +0000 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | /// Create a call to a Masked intrinsic, with given intrinsic Id, |
| 223 | /// an array of operands - Ops, and one overloaded type - DataTy |
| 224 | CallInst *IRBuilderBase::CreateMaskedIntrinsic(unsigned Id, |
| 225 | ArrayRef<Value *> Ops, |
Elena Demikhovsky | 84d1997 | 2014-12-30 14:28:14 +0000 | [diff] [blame] | 226 | Type *DataTy, |
| 227 | const Twine &Name) { |
Elena Demikhovsky | f1de34b | 2014-12-04 09:40:44 +0000 | [diff] [blame] | 228 | Module *M = BB->getParent()->getParent(); |
| 229 | Type *OverloadedTypes[] = { DataTy }; |
| 230 | Value *TheFn = Intrinsic::getDeclaration(M, (Intrinsic::ID)Id, OverloadedTypes); |
Elena Demikhovsky | 84d1997 | 2014-12-30 14:28:14 +0000 | [diff] [blame] | 231 | return createCallHelper(TheFn, Ops, this, Name); |
Elena Demikhovsky | f1de34b | 2014-12-04 09:40:44 +0000 | [diff] [blame] | 232 | } |
Philip Reames | 4750dd1 | 2014-12-30 05:55:58 +0000 | [diff] [blame] | 233 | |
| 234 | CallInst *IRBuilderBase::CreateGCStatepoint(Value *ActualCallee, |
Ramkumar Ramachandra | 3edf74f | 2015-02-09 23:02:10 +0000 | [diff] [blame] | 235 | ArrayRef<Value *> CallArgs, |
| 236 | ArrayRef<Value *> DeoptArgs, |
| 237 | ArrayRef<Value *> GCArgs, |
| 238 | const Twine &Name) { |
Philip Reames | 4750dd1 | 2014-12-30 05:55:58 +0000 | [diff] [blame] | 239 | // Extract out the type of the callee. |
| 240 | PointerType *FuncPtrType = cast<PointerType>(ActualCallee->getType()); |
| 241 | assert(isa<FunctionType>(FuncPtrType->getElementType()) && |
| 242 | "actual callee must be a callable value"); |
| 243 | |
| 244 | |
| 245 | Module *M = BB->getParent()->getParent(); |
| 246 | // Fill in the one generic type'd argument (the function is also vararg) |
| 247 | Type *ArgTypes[] = { FuncPtrType }; |
| 248 | Function *FnStatepoint = |
| 249 | Intrinsic::getDeclaration(M, Intrinsic::experimental_gc_statepoint, |
| 250 | ArgTypes); |
| 251 | |
| 252 | std::vector<llvm::Value *> args; |
| 253 | args.push_back(ActualCallee); |
| 254 | args.push_back(getInt32(CallArgs.size())); |
| 255 | args.push_back(getInt32(0 /*unused*/)); |
| 256 | args.insert(args.end(), CallArgs.begin(), CallArgs.end()); |
| 257 | args.push_back(getInt32(DeoptArgs.size())); |
| 258 | args.insert(args.end(), DeoptArgs.begin(), DeoptArgs.end()); |
| 259 | args.insert(args.end(), GCArgs.begin(), GCArgs.end()); |
| 260 | |
| 261 | return createCallHelper(FnStatepoint, args, this, Name); |
| 262 | } |
| 263 | |
Ramkumar Ramachandra | 3408f3e | 2015-02-26 00:35:56 +0000 | [diff] [blame] | 264 | CallInst *IRBuilderBase::CreateGCStatepoint(Value *ActualCallee, |
| 265 | ArrayRef<Use> CallArgs, |
| 266 | ArrayRef<Value *> DeoptArgs, |
| 267 | ArrayRef<Value *> GCArgs, |
| 268 | const Twine &Name) { |
| 269 | std::vector<Value *> VCallArgs; |
| 270 | for (auto &U : CallArgs) |
| 271 | VCallArgs.push_back(U.get()); |
| 272 | return CreateGCStatepoint(ActualCallee, VCallArgs, DeoptArgs, GCArgs, Name); |
| 273 | } |
| 274 | |
Philip Reames | 4750dd1 | 2014-12-30 05:55:58 +0000 | [diff] [blame] | 275 | CallInst *IRBuilderBase::CreateGCResult(Instruction *Statepoint, |
| 276 | Type *ResultType, |
| 277 | const Twine &Name) { |
Ramkumar Ramachandra | 75a4f35 | 2015-01-22 20:14:38 +0000 | [diff] [blame] | 278 | Intrinsic::ID ID = Intrinsic::experimental_gc_result; |
Philip Reames | 4750dd1 | 2014-12-30 05:55:58 +0000 | [diff] [blame] | 279 | Module *M = BB->getParent()->getParent(); |
| 280 | Type *Types[] = {ResultType}; |
| 281 | Value *FnGCResult = Intrinsic::getDeclaration(M, ID, Types); |
| 282 | |
| 283 | Value *Args[] = {Statepoint}; |
| 284 | return createCallHelper(FnGCResult, Args, this, Name); |
| 285 | } |
| 286 | |
| 287 | CallInst *IRBuilderBase::CreateGCRelocate(Instruction *Statepoint, |
| 288 | int BaseOffset, |
| 289 | int DerivedOffset, |
| 290 | Type *ResultType, |
| 291 | const Twine &Name) { |
| 292 | Module *M = BB->getParent()->getParent(); |
| 293 | Type *Types[] = {ResultType}; |
| 294 | Value *FnGCRelocate = |
| 295 | Intrinsic::getDeclaration(M, Intrinsic::experimental_gc_relocate, Types); |
| 296 | |
| 297 | Value *Args[] = {Statepoint, |
| 298 | getInt32(BaseOffset), |
| 299 | getInt32(DerivedOffset)}; |
| 300 | return createCallHelper(FnGCRelocate, Args, this, Name); |
| 301 | } |