blob: 491d088080ce6aed25c154ce260a4f46c336e7cc [file] [log] [blame]
Tobias Grosserf74a4cd2012-03-23 10:35:18 +00001//===------ LoopGenerators.cpp - IR helper to create loops ---------------===//
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//
Johannes Doerfert12b355a2014-10-03 19:10:13 +000010// This file contains functions to create scalar and parallel loops as LLVM-IR.
Tobias Grosserf74a4cd2012-03-23 10:35:18 +000011//
12//===----------------------------------------------------------------------===//
13
Tobias Grosserf74a4cd2012-03-23 10:35:18 +000014#include "polly/ScopDetection.h"
Hongbin Zheng8a846612012-04-25 13:18:28 +000015#include "polly/CodeGen/LoopGenerators.h"
Tobias Grosser3081b0f2013-05-16 06:40:24 +000016#include "llvm/Analysis/LoopInfo.h"
Chandler Carruth535d52c2013-01-02 11:47:44 +000017#include "llvm/IR/DataLayout.h"
Chandler Carruthe87c6a82014-01-13 09:56:11 +000018#include "llvm/IR/Dominators.h"
Tobias Grosser83628182013-05-07 08:11:54 +000019#include "llvm/IR/Module.h"
Tobias Grosserf74a4cd2012-03-23 10:35:18 +000020#include "llvm/Transforms/Utils/BasicBlockUtils.h"
21
22using namespace llvm;
Hongbin Zheng4ac4e152012-04-23 13:03:56 +000023using namespace polly;
Tobias Grosserf74a4cd2012-03-23 10:35:18 +000024
Johannes Doerfertdd5c1442014-09-10 17:33:32 +000025// We generate a loop of either of the following structures:
Tobias Grosser5db6ffd2013-05-16 06:40:06 +000026//
Johannes Doerfertdd5c1442014-09-10 17:33:32 +000027// BeforeBB BeforeBB
28// | |
29// v v
30// GuardBB PreHeaderBB
31// / | | _____
32// __ PreHeaderBB | v \/ |
33// / \ / | HeaderBB latch
34// latch HeaderBB | |\ |
35// \ / \ / | \------/
36// < \ / |
37// \ / v
38// ExitBB ExitBB
Tobias Grosser5db6ffd2013-05-16 06:40:06 +000039//
Johannes Doerfertdd5c1442014-09-10 17:33:32 +000040// depending on whether or not we know that it is executed at least once. If
41// not, GuardBB checks if the loop is executed at least once. If this is the
42// case we branch to PreHeaderBB and subsequently to the HeaderBB, which
43// contains the loop iv 'polly.indvar', the incremented loop iv
44// 'polly.indvar_next' as well as the condition to check if we execute another
45// iteration of the loop. After the loop has finished, we branch to ExitBB.
Hongbin Zheng4ac4e152012-04-23 13:03:56 +000046Value *polly::createLoop(Value *LB, Value *UB, Value *Stride,
Johannes Doerfert2ef3f4f2014-08-07 17:14:54 +000047 PollyIRBuilder &Builder, Pass *P, LoopInfo &LI,
48 DominatorTree &DT, BasicBlock *&ExitBB,
Tobias Grosser37c9b8e2014-03-04 14:59:00 +000049 ICmpInst::Predicate Predicate,
Johannes Doerfert51d1c742014-10-02 15:32:17 +000050 ScopAnnotator *Annotator, bool Parallel,
Johannes Doerfertdd5c1442014-09-10 17:33:32 +000051 bool UseGuard) {
Hongbin Zheng4ac4e152012-04-23 13:03:56 +000052 Function *F = Builder.GetInsertBlock()->getParent();
Tobias Grosserf74a4cd2012-03-23 10:35:18 +000053 LLVMContext &Context = F->getContext();
54
Tobias Grosser5db6ffd2013-05-16 06:40:06 +000055 assert(LB->getType() == UB->getType() && "Types of loop bounds do not match");
Tobias Grosserf74a4cd2012-03-23 10:35:18 +000056 IntegerType *LoopIVType = dyn_cast<IntegerType>(UB->getType());
57 assert(LoopIVType && "UB is not integer?");
58
Tobias Grosser5db6ffd2013-05-16 06:40:06 +000059 BasicBlock *BeforeBB = Builder.GetInsertBlock();
Johannes Doerfertdd5c1442014-09-10 17:33:32 +000060 BasicBlock *GuardBB =
61 UseGuard ? BasicBlock::Create(Context, "polly.loop_if", F) : nullptr;
Tobias Grosser5db6ffd2013-05-16 06:40:06 +000062 BasicBlock *HeaderBB = BasicBlock::Create(Context, "polly.loop_header", F);
63 BasicBlock *PreHeaderBB =
64 BasicBlock::Create(Context, "polly.loop_preheader", F);
Tobias Grosserf74a4cd2012-03-23 10:35:18 +000065
Tobias Grosser3081b0f2013-05-16 06:40:24 +000066 // Update LoopInfo
67 Loop *OuterLoop = LI.getLoopFor(BeforeBB);
68 Loop *NewLoop = new Loop();
69
Johannes Doerfertdd5c1442014-09-10 17:33:32 +000070 if (OuterLoop)
Tobias Grosser3081b0f2013-05-16 06:40:24 +000071 OuterLoop->addChildLoop(NewLoop);
Johannes Doerfertdd5c1442014-09-10 17:33:32 +000072 else
Tobias Grosser3081b0f2013-05-16 06:40:24 +000073 LI.addTopLevelLoop(NewLoop);
Tobias Grosser3081b0f2013-05-16 06:40:24 +000074
Johannes Doerfertdd5c1442014-09-10 17:33:32 +000075 if (OuterLoop && GuardBB)
Tobias Grosser3081b0f2013-05-16 06:40:24 +000076 OuterLoop->addBasicBlockToLoop(GuardBB, LI.getBase());
Johannes Doerfertdd5c1442014-09-10 17:33:32 +000077 else if (OuterLoop)
Tobias Grosser3081b0f2013-05-16 06:40:24 +000078 OuterLoop->addBasicBlockToLoop(PreHeaderBB, LI.getBase());
Tobias Grosser3081b0f2013-05-16 06:40:24 +000079
80 NewLoop->addBasicBlockToLoop(HeaderBB, LI.getBase());
81
Johannes Doerfertc7b719f2014-10-01 20:10:44 +000082 // Notify the annotator (if present) that we have a new loop, but only
83 // after the header block is set.
84 if (Annotator)
85 Annotator->pushLoop(NewLoop, Parallel);
86
Tobias Grosser5db6ffd2013-05-16 06:40:06 +000087 // ExitBB
88 ExitBB = SplitBlock(BeforeBB, Builder.GetInsertPoint()++, P);
89 ExitBB->setName("polly.loop_exit");
Tobias Grosserf74a4cd2012-03-23 10:35:18 +000090
Tobias Grosser5db6ffd2013-05-16 06:40:06 +000091 // BeforeBB
Johannes Doerfertdd5c1442014-09-10 17:33:32 +000092 if (GuardBB) {
93 BeforeBB->getTerminator()->setSuccessor(0, GuardBB);
94 DT.addNewBlock(GuardBB, BeforeBB);
Tobias Grosserf74a4cd2012-03-23 10:35:18 +000095
Johannes Doerfertdd5c1442014-09-10 17:33:32 +000096 // GuardBB
97 Builder.SetInsertPoint(GuardBB);
98 Value *LoopGuard;
99 LoopGuard = Builder.CreateICmp(Predicate, LB, UB);
100 LoopGuard->setName("polly.loop_guard");
101 Builder.CreateCondBr(LoopGuard, PreHeaderBB, ExitBB);
102 DT.addNewBlock(PreHeaderBB, GuardBB);
103 } else {
104 BeforeBB->getTerminator()->setSuccessor(0, PreHeaderBB);
105 DT.addNewBlock(PreHeaderBB, BeforeBB);
106 }
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000107
Tobias Grosser5db6ffd2013-05-16 06:40:06 +0000108 // PreHeaderBB
Tobias Grosser5db6ffd2013-05-16 06:40:06 +0000109 Builder.SetInsertPoint(PreHeaderBB);
Hongbin Zheng4ac4e152012-04-23 13:03:56 +0000110 Builder.CreateBr(HeaderBB);
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000111
Tobias Grosser5db6ffd2013-05-16 06:40:06 +0000112 // HeaderBB
113 DT.addNewBlock(HeaderBB, PreHeaderBB);
114 Builder.SetInsertPoint(HeaderBB);
115 PHINode *IV = Builder.CreatePHI(LoopIVType, 2, "polly.indvar");
116 IV->addIncoming(LB, PreHeaderBB);
117 Stride = Builder.CreateZExtOrBitCast(Stride, LoopIVType);
118 Value *IncrementedIV = Builder.CreateNSWAdd(IV, Stride, "polly.indvar_next");
119 Value *LoopCondition;
120 UB = Builder.CreateSub(UB, Stride, "polly.adjust_ub");
121 LoopCondition = Builder.CreateICmp(Predicate, IV, UB);
122 LoopCondition->setName("polly.loop_cond");
Johannes Doerfertc7b719f2014-10-01 20:10:44 +0000123
124 // Create the loop latch and annotate it as such.
125 BranchInst *B = Builder.CreateCondBr(LoopCondition, HeaderBB, ExitBB);
126 if (Annotator)
127 Annotator->annotateLoopLatch(B, NewLoop, Parallel);
128
Tobias Grosser5db6ffd2013-05-16 06:40:06 +0000129 IV->addIncoming(IncrementedIV, HeaderBB);
Johannes Doerfertdd5c1442014-09-10 17:33:32 +0000130 if (GuardBB)
131 DT.changeImmediateDominator(ExitBB, GuardBB);
132 else
Tobias Grosserf8a678d2014-09-28 22:40:36 +0000133 DT.changeImmediateDominator(ExitBB, HeaderBB);
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000134
Tobias Grosser5db6ffd2013-05-16 06:40:06 +0000135 // The loop body should be added here.
136 Builder.SetInsertPoint(HeaderBB->getFirstNonPHI());
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000137 return IV;
138}
139
Johannes Doerfert12b355a2014-10-03 19:10:13 +0000140Value *ParallelLoopGenerator::createParallelLoop(
141 Value *LB, Value *UB, Value *Stride, SetVector<Value *> &UsedValues,
142 ValueToValueMapTy &Map, BasicBlock::iterator *LoopBody) {
143 Value *Struct, *IV, *SubFnParam;
144 Function *SubFn;
145
146 Struct = storeValuesIntoStruct(UsedValues);
147
148 BasicBlock::iterator BeforeLoop = Builder.GetInsertPoint();
149 IV = createSubFn(Stride, Struct, UsedValues, Map, &SubFn);
150 *LoopBody = Builder.GetInsertPoint();
151 Builder.SetInsertPoint(BeforeLoop);
152
153 SubFnParam = Builder.CreateBitCast(Struct, Builder.getInt8PtrTy(),
154 "polly.par.userContext");
155
156 // Add one as the upper bound provided by openmp is a < comparison
157 // whereas the codegenForSequential function creates a <= comparison.
158 UB = Builder.CreateAdd(UB, ConstantInt::get(LongType, 1));
159
160 // Tell the runtime we start a parallel loop
161 createCallSpawnThreads(SubFn, SubFnParam, LB, UB, Stride);
162 Builder.CreateCall(SubFn, SubFnParam);
163 createCallJoinThreads();
164
165 return IV;
166}
167
168void ParallelLoopGenerator::createCallSpawnThreads(Value *SubFn,
169 Value *SubFnParam, Value *LB,
170 Value *UB, Value *Stride) {
171 const std::string Name = "GOMP_parallel_loop_runtime_start";
172
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000173 Function *F = M->getFunction(Name);
174
175 // If F is not available, declare it.
176 if (!F) {
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000177 GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
178
Tobias Grosser45bac0d2014-03-02 17:05:21 +0000179 Type *Params[] = {PointerType::getUnqual(FunctionType::get(
180 Builder.getVoidTy(), Builder.getInt8PtrTy(), false)),
Johannes Doerfert12b355a2014-10-03 19:10:13 +0000181 Builder.getInt8PtrTy(), LongType, LongType, LongType,
182 LongType};
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000183
184 FunctionType *Ty = FunctionType::get(Builder.getVoidTy(), Params, false);
185 F = Function::Create(Ty, Linkage, Name, M);
186 }
187
Johannes Doerfert12b355a2014-10-03 19:10:13 +0000188 Value *NumberOfThreads = ConstantInt::get(LongType, 0);
189 Value *Args[] = {SubFn, SubFnParam, NumberOfThreads, LB, UB, Stride};
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000190
191 Builder.CreateCall(F, Args);
192}
193
Johannes Doerfert12b355a2014-10-03 19:10:13 +0000194Value *ParallelLoopGenerator::createCallGetWorkItem(Value *LBPtr,
195 Value *UBPtr) {
196 const std::string Name = "GOMP_loop_runtime_next";
197
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000198 Function *F = M->getFunction(Name);
199
200 // If F is not available, declare it.
201 if (!F) {
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000202 GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
Johannes Doerfert12b355a2014-10-03 19:10:13 +0000203 Type *Params[] = {LongType->getPointerTo(), LongType->getPointerTo()};
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000204 FunctionType *Ty = FunctionType::get(Builder.getInt8Ty(), Params, false);
205 F = Function::Create(Ty, Linkage, Name, M);
206 }
207
Johannes Doerfert12b355a2014-10-03 19:10:13 +0000208 Value *Args[] = {LBPtr, UBPtr};
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000209 Value *Return = Builder.CreateCall(F, Args);
Tobias Grosserc14582f2013-02-05 18:01:29 +0000210 Return = Builder.CreateICmpNE(
211 Return, Builder.CreateZExt(Builder.getFalse(), Return->getType()));
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000212 return Return;
213}
214
Johannes Doerfert12b355a2014-10-03 19:10:13 +0000215void ParallelLoopGenerator::createCallJoinThreads() {
216 const std::string Name = "GOMP_parallel_end";
217
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000218 Function *F = M->getFunction(Name);
219
220 // If F is not available, declare it.
221 if (!F) {
222 GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
223
224 FunctionType *Ty = FunctionType::get(Builder.getVoidTy(), false);
225 F = Function::Create(Ty, Linkage, Name, M);
226 }
227
228 Builder.CreateCall(F);
229}
230
Johannes Doerfert12b355a2014-10-03 19:10:13 +0000231void ParallelLoopGenerator::createCallCleanupThread() {
232 const std::string Name = "GOMP_loop_end_nowait";
233
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000234 Function *F = M->getFunction(Name);
235
236 // If F is not available, declare it.
237 if (!F) {
238 GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
239
240 FunctionType *Ty = FunctionType::get(Builder.getVoidTy(), false);
241 F = Function::Create(Ty, Linkage, Name, M);
242 }
243
244 Builder.CreateCall(F);
245}
246
Johannes Doerfert12b355a2014-10-03 19:10:13 +0000247Function *ParallelLoopGenerator::createSubFnDefinition() {
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000248 Function *F = Builder.GetInsertBlock()->getParent();
Tobias Grosserc14582f2013-02-05 18:01:29 +0000249 std::vector<Type *> Arguments(1, Builder.getInt8PtrTy());
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000250 FunctionType *FT = FunctionType::get(Builder.getVoidTy(), Arguments, false);
Johannes Doerfert12b355a2014-10-03 19:10:13 +0000251 Function *SubFn = Function::Create(FT, Function::InternalLinkage,
252 F->getName() + ".polly.subfn", M);
253
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000254 // Do not run any polly pass on the new function.
Johannes Doerfert12b355a2014-10-03 19:10:13 +0000255 SubFn->addFnAttr(PollySkipFnAttr);
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000256
Johannes Doerfert12b355a2014-10-03 19:10:13 +0000257 Function::arg_iterator AI = SubFn->arg_begin();
258 AI->setName("polly.par.userContext");
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000259
Johannes Doerfert12b355a2014-10-03 19:10:13 +0000260 return SubFn;
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000261}
262
Johannes Doerfert12b355a2014-10-03 19:10:13 +0000263Value *
264ParallelLoopGenerator::storeValuesIntoStruct(SetVector<Value *> &Values) {
265 SmallVector<Type *, 8> Members;
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000266
Tobias Grosser91f5b262014-06-04 08:06:40 +0000267 for (Value *V : Values)
268 Members.push_back(V->getType());
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000269
270 StructType *Ty = StructType::get(Builder.getContext(), Members);
Johannes Doerfert12b355a2014-10-03 19:10:13 +0000271 Value *Struct =
272 new AllocaInst(Ty, 0, "polly.par.userContext", Builder.GetInsertPoint());
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000273
274 for (unsigned i = 0; i < Values.size(); i++) {
275 Value *Address = Builder.CreateStructGEP(Struct, i);
276 Builder.CreateStore(Values[i], Address);
277 }
278
279 return Struct;
280}
281
Johannes Doerfert12b355a2014-10-03 19:10:13 +0000282void ParallelLoopGenerator::extractValuesFromStruct(
283 SetVector<Value *> OldValues, Value *Struct, ValueToValueMapTy &Map) {
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000284 for (unsigned i = 0; i < OldValues.size(); i++) {
285 Value *Address = Builder.CreateStructGEP(Struct, i);
286 Value *NewValue = Builder.CreateLoad(Address);
Johannes Doerfert12b355a2014-10-03 19:10:13 +0000287 Map[OldValues[i]] = NewValue;
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000288 }
289}
290
Johannes Doerfert12b355a2014-10-03 19:10:13 +0000291Value *ParallelLoopGenerator::createSubFn(Value *Stride, Value *StructData,
292 SetVector<Value *> Data,
293 ValueToValueMapTy &Map,
294 Function **SubFnPtr) {
295 BasicBlock *PrevBB, *HeaderBB, *ExitBB, *CheckNextBB, *PreHeaderBB, *AfterBB;
296 Value *LBPtr, *UBPtr, *UserContext, *Ret1, *HasNextSchedule, *LB, *UB, *IV;
297 Function *SubFn = createSubFnDefinition();
298 LLVMContext &Context = SubFn->getContext();
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000299
300 // Store the previous basic block.
301 PrevBB = Builder.GetInsertBlock();
302
303 // Create basic blocks.
Johannes Doerfert12b355a2014-10-03 19:10:13 +0000304 HeaderBB = BasicBlock::Create(Context, "polly.par.setup", SubFn);
305 ExitBB = BasicBlock::Create(Context, "polly.par.exit", SubFn);
306 CheckNextBB = BasicBlock::Create(Context, "polly.par.checkNext", SubFn);
307 PreHeaderBB = BasicBlock::Create(Context, "polly.par.loadIVBounds", SubFn);
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000308
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000309 DT.addNewBlock(HeaderBB, PrevBB);
310 DT.addNewBlock(ExitBB, HeaderBB);
311 DT.addNewBlock(CheckNextBB, HeaderBB);
Johannes Doerfert12b355a2014-10-03 19:10:13 +0000312 DT.addNewBlock(PreHeaderBB, HeaderBB);
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000313
314 // Fill up basic block HeaderBB.
315 Builder.SetInsertPoint(HeaderBB);
Johannes Doerfert12b355a2014-10-03 19:10:13 +0000316 LBPtr = Builder.CreateAlloca(LongType, 0, "polly.par.LBPtr");
317 UBPtr = Builder.CreateAlloca(LongType, 0, "polly.par.UBPtr");
318 UserContext = Builder.CreateBitCast(SubFn->arg_begin(), StructData->getType(),
319 "polly.par.userContext");
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000320
321 extractValuesFromStruct(Data, UserContext, Map);
322 Builder.CreateBr(CheckNextBB);
323
324 // Add code to check if another set of iterations will be executed.
325 Builder.SetInsertPoint(CheckNextBB);
Johannes Doerfert12b355a2014-10-03 19:10:13 +0000326 Ret1 = createCallGetWorkItem(LBPtr, UBPtr);
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000327 HasNextSchedule = Builder.CreateTrunc(Ret1, Builder.getInt1Ty(),
Johannes Doerfert12b355a2014-10-03 19:10:13 +0000328 "polly.par.hasNextScheduleBlock");
329 Builder.CreateCondBr(HasNextSchedule, PreHeaderBB, ExitBB);
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000330
331 // Add code to to load the iv bounds for this set of iterations.
Johannes Doerfert12b355a2014-10-03 19:10:13 +0000332 Builder.SetInsertPoint(PreHeaderBB);
333 LB = Builder.CreateLoad(LBPtr, "polly.par.LB");
334 UB = Builder.CreateLoad(UBPtr, "polly.par.UB");
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000335
336 // Subtract one as the upper bound provided by openmp is a < comparison
337 // whereas the codegenForSequential function creates a <= comparison.
Johannes Doerfert12b355a2014-10-03 19:10:13 +0000338 UB = Builder.CreateSub(UB, ConstantInt::get(LongType, 1),
339 "polly.par.UBAdjusted");
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000340
341 Builder.CreateBr(CheckNextBB);
342 Builder.SetInsertPoint(--Builder.GetInsertPoint());
Johannes Doerfert12b355a2014-10-03 19:10:13 +0000343 IV = createLoop(LB, UB, Stride, Builder, P, LI, DT, AfterBB,
Johannes Doerfertdd5c1442014-09-10 17:33:32 +0000344 ICmpInst::ICMP_SLE, nullptr, true, /* UseGuard */ false);
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000345
346 BasicBlock::iterator LoopBody = Builder.GetInsertPoint();
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000347
Johannes Doerfert12b355a2014-10-03 19:10:13 +0000348 // Add code to terminate this subfunction.
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000349 Builder.SetInsertPoint(ExitBB);
Johannes Doerfert12b355a2014-10-03 19:10:13 +0000350 createCallCleanupThread();
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000351 Builder.CreateRetVoid();
352
353 Builder.SetInsertPoint(LoopBody);
Johannes Doerfert12b355a2014-10-03 19:10:13 +0000354 *SubFnPtr = SubFn;
Tobias Grosserf74a4cd2012-03-23 10:35:18 +0000355
356 return IV;
357}