1609089f2SHongbin Zheng //===------ LoopGenerators.cpp -  IR helper to create loops ---------------===//
2609089f2SHongbin Zheng //
3609089f2SHongbin Zheng //                     The LLVM Compiler Infrastructure
4609089f2SHongbin Zheng //
5609089f2SHongbin Zheng // This file is distributed under the University of Illinois Open Source
6609089f2SHongbin Zheng // License. See LICENSE.TXT for details.
7609089f2SHongbin Zheng //
8609089f2SHongbin Zheng //===----------------------------------------------------------------------===//
9609089f2SHongbin Zheng //
10609089f2SHongbin Zheng // This file contains functions to create scalar and OpenMP parallel loops
11609089f2SHongbin Zheng // as LLVM-IR.
12609089f2SHongbin Zheng //
13609089f2SHongbin Zheng //===----------------------------------------------------------------------===//
14609089f2SHongbin Zheng 
15609089f2SHongbin Zheng #include "polly/ScopDetection.h"
168a846610SHongbin Zheng #include "polly/CodeGen/LoopGenerators.h"
17609089f2SHongbin Zheng 
18609089f2SHongbin Zheng #include "llvm/Module.h"
19609089f2SHongbin Zheng #include "llvm/Analysis/Dominators.h"
207a3d8209SMicah Villmow #include "llvm/DataLayout.h"
21609089f2SHongbin Zheng #include "llvm/Transforms/Utils/BasicBlockUtils.h"
22609089f2SHongbin Zheng 
23609089f2SHongbin Zheng using namespace llvm;
244ac4e155SHongbin Zheng using namespace polly;
25609089f2SHongbin Zheng 
264ac4e155SHongbin Zheng Value *polly::createLoop(Value *LB, Value *UB, Value *Stride,
274ac4e155SHongbin Zheng                          IRBuilder<> &Builder, Pass *P,
28c967d8e6STobias Grosser                          BasicBlock *&AfterBlock,
29c967d8e6STobias Grosser                          ICmpInst::Predicate Predicate) {
30609089f2SHongbin Zheng   DominatorTree &DT = P->getAnalysis<DominatorTree>();
314ac4e155SHongbin Zheng   Function *F = Builder.GetInsertBlock()->getParent();
32609089f2SHongbin Zheng   LLVMContext &Context = F->getContext();
33609089f2SHongbin Zheng 
344ac4e155SHongbin Zheng   BasicBlock *PreheaderBB = Builder.GetInsertBlock();
35609089f2SHongbin Zheng   BasicBlock *HeaderBB = BasicBlock::Create(Context, "polly.loop_header", F);
36609089f2SHongbin Zheng   BasicBlock *BodyBB = BasicBlock::Create(Context, "polly.loop_body", F);
374ac4e155SHongbin Zheng   BasicBlock *AfterBB = SplitBlock(PreheaderBB, Builder.GetInsertPoint()++, P);
38609089f2SHongbin Zheng   AfterBB->setName("polly.loop_after");
39609089f2SHongbin Zheng 
40609089f2SHongbin Zheng   PreheaderBB->getTerminator()->setSuccessor(0, HeaderBB);
41609089f2SHongbin Zheng   DT.addNewBlock(HeaderBB, PreheaderBB);
42609089f2SHongbin Zheng 
434ac4e155SHongbin Zheng   Builder.SetInsertPoint(HeaderBB);
44609089f2SHongbin Zheng 
45609089f2SHongbin Zheng   // Use the type of upper and lower bound.
46609089f2SHongbin Zheng   assert(LB->getType() == UB->getType()
47609089f2SHongbin Zheng          && "Different types for upper and lower bound.");
48609089f2SHongbin Zheng 
49609089f2SHongbin Zheng   IntegerType *LoopIVType = dyn_cast<IntegerType>(UB->getType());
50609089f2SHongbin Zheng   assert(LoopIVType && "UB is not integer?");
51609089f2SHongbin Zheng 
52609089f2SHongbin Zheng   // IV
534ac4e155SHongbin Zheng   PHINode *IV = Builder.CreatePHI(LoopIVType, 2, "polly.loopiv");
54609089f2SHongbin Zheng   IV->addIncoming(LB, PreheaderBB);
55609089f2SHongbin Zheng 
564ac4e155SHongbin Zheng   Stride = Builder.CreateZExtOrBitCast(Stride, LoopIVType);
57400a4ac6STobias Grosser   Value *IncrementedIV = Builder.CreateNSWAdd(IV, Stride, "polly.next_loopiv");
58609089f2SHongbin Zheng 
59609089f2SHongbin Zheng   // Exit condition.
60609089f2SHongbin Zheng   Value *CMP;
61c967d8e6STobias Grosser   CMP = Builder.CreateICmp(Predicate, IV, UB);
62609089f2SHongbin Zheng 
634ac4e155SHongbin Zheng   Builder.CreateCondBr(CMP, BodyBB, AfterBB);
64609089f2SHongbin Zheng   DT.addNewBlock(BodyBB, HeaderBB);
65609089f2SHongbin Zheng 
664ac4e155SHongbin Zheng   Builder.SetInsertPoint(BodyBB);
674ac4e155SHongbin Zheng   Builder.CreateBr(HeaderBB);
68609089f2SHongbin Zheng   IV->addIncoming(IncrementedIV, BodyBB);
69609089f2SHongbin Zheng   DT.changeImmediateDominator(AfterBB, HeaderBB);
70609089f2SHongbin Zheng 
714ac4e155SHongbin Zheng   Builder.SetInsertPoint(BodyBB->begin());
724ac4e155SHongbin Zheng   AfterBlock = AfterBB;
73609089f2SHongbin Zheng 
74609089f2SHongbin Zheng   return IV;
75609089f2SHongbin Zheng }
76609089f2SHongbin Zheng 
77609089f2SHongbin Zheng void OMPGenerator::createCallParallelLoopStart(Value *SubFunction,
78609089f2SHongbin Zheng                                                Value *SubfunctionParam,
79609089f2SHongbin Zheng                                                Value *NumberOfThreads,
80609089f2SHongbin Zheng                                                Value *LowerBound,
81609089f2SHongbin Zheng                                                Value *UpperBound,
82609089f2SHongbin Zheng                                                Value *Stride) {
83609089f2SHongbin Zheng   Module *M = getModule();
84609089f2SHongbin Zheng   const char *Name = "GOMP_parallel_loop_runtime_start";
85609089f2SHongbin Zheng   Function *F = M->getFunction(Name);
86609089f2SHongbin Zheng 
87609089f2SHongbin Zheng   // If F is not available, declare it.
88609089f2SHongbin Zheng   if (!F) {
89609089f2SHongbin Zheng     Type *LongTy = getIntPtrTy();
90609089f2SHongbin Zheng     GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
91609089f2SHongbin Zheng 
92609089f2SHongbin Zheng     Type *Params[] = {
93609089f2SHongbin Zheng       PointerType::getUnqual(FunctionType::get(Builder.getVoidTy(),
94609089f2SHongbin Zheng                                                Builder.getInt8PtrTy(),
95609089f2SHongbin Zheng                                                false)),
96609089f2SHongbin Zheng       Builder.getInt8PtrTy(),
97609089f2SHongbin Zheng       Builder.getInt32Ty(),
98609089f2SHongbin Zheng       LongTy,
99609089f2SHongbin Zheng       LongTy,
100609089f2SHongbin Zheng       LongTy,
101609089f2SHongbin Zheng     };
102609089f2SHongbin Zheng 
103609089f2SHongbin Zheng     FunctionType *Ty = FunctionType::get(Builder.getVoidTy(), Params, false);
104609089f2SHongbin Zheng     F = Function::Create(Ty, Linkage, Name, M);
105609089f2SHongbin Zheng   }
106609089f2SHongbin Zheng 
107609089f2SHongbin Zheng   Value *Args[] = {
108609089f2SHongbin Zheng     SubFunction,
109609089f2SHongbin Zheng     SubfunctionParam,
110609089f2SHongbin Zheng     NumberOfThreads,
111609089f2SHongbin Zheng     LowerBound,
112609089f2SHongbin Zheng     UpperBound,
113609089f2SHongbin Zheng     Stride,
114609089f2SHongbin Zheng   };
115609089f2SHongbin Zheng 
116609089f2SHongbin Zheng   Builder.CreateCall(F, Args);
117609089f2SHongbin Zheng }
118609089f2SHongbin Zheng 
119609089f2SHongbin Zheng Value *OMPGenerator::createCallLoopNext(Value *LowerBoundPtr,
120609089f2SHongbin Zheng                                         Value *UpperBoundPtr) {
121609089f2SHongbin Zheng   Module *M = getModule();
122609089f2SHongbin Zheng   const char *Name = "GOMP_loop_runtime_next";
123609089f2SHongbin Zheng   Function *F = M->getFunction(Name);
124609089f2SHongbin Zheng 
125609089f2SHongbin Zheng   // If F is not available, declare it.
126609089f2SHongbin Zheng   if (!F) {
127609089f2SHongbin Zheng     Type *LongPtrTy = PointerType::getUnqual(getIntPtrTy());
128609089f2SHongbin Zheng     GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
129609089f2SHongbin Zheng 
130609089f2SHongbin Zheng     Type *Params[] = {
131609089f2SHongbin Zheng       LongPtrTy,
132609089f2SHongbin Zheng       LongPtrTy,
133609089f2SHongbin Zheng     };
134609089f2SHongbin Zheng 
135609089f2SHongbin Zheng     FunctionType *Ty = FunctionType::get(Builder.getInt8Ty(), Params, false);
136609089f2SHongbin Zheng     F = Function::Create(Ty, Linkage, Name, M);
137609089f2SHongbin Zheng   }
138609089f2SHongbin Zheng 
139609089f2SHongbin Zheng   Value *Args[] = {
140609089f2SHongbin Zheng     LowerBoundPtr,
141609089f2SHongbin Zheng     UpperBoundPtr,
142609089f2SHongbin Zheng   };
143609089f2SHongbin Zheng 
144609089f2SHongbin Zheng   Value *Return = Builder.CreateCall(F, Args);
145609089f2SHongbin Zheng   Return = Builder.CreateICmpNE(Return, Builder.CreateZExt(Builder.getFalse(),
146609089f2SHongbin Zheng                                                            Return->getType()));
147609089f2SHongbin Zheng   return Return;
148609089f2SHongbin Zheng }
149609089f2SHongbin Zheng 
150609089f2SHongbin Zheng void OMPGenerator::createCallParallelEnd() {
151609089f2SHongbin Zheng   const char *Name = "GOMP_parallel_end";
152609089f2SHongbin Zheng   Module *M = getModule();
153609089f2SHongbin Zheng   Function *F = M->getFunction(Name);
154609089f2SHongbin Zheng 
155609089f2SHongbin Zheng   // If F is not available, declare it.
156609089f2SHongbin Zheng   if (!F) {
157609089f2SHongbin Zheng     GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
158609089f2SHongbin Zheng 
159609089f2SHongbin Zheng     FunctionType *Ty = FunctionType::get(Builder.getVoidTy(), false);
160609089f2SHongbin Zheng     F = Function::Create(Ty, Linkage, Name, M);
161609089f2SHongbin Zheng   }
162609089f2SHongbin Zheng 
163609089f2SHongbin Zheng   Builder.CreateCall(F);
164609089f2SHongbin Zheng }
165609089f2SHongbin Zheng 
166609089f2SHongbin Zheng void OMPGenerator::createCallLoopEndNowait() {
167609089f2SHongbin Zheng   const char *Name = "GOMP_loop_end_nowait";
168609089f2SHongbin Zheng   Module *M = getModule();
169609089f2SHongbin Zheng   Function *F = M->getFunction(Name);
170609089f2SHongbin Zheng 
171609089f2SHongbin Zheng   // If F is not available, declare it.
172609089f2SHongbin Zheng   if (!F) {
173609089f2SHongbin Zheng     GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
174609089f2SHongbin Zheng 
175609089f2SHongbin Zheng     FunctionType *Ty = FunctionType::get(Builder.getVoidTy(), false);
176609089f2SHongbin Zheng     F = Function::Create(Ty, Linkage, Name, M);
177609089f2SHongbin Zheng   }
178609089f2SHongbin Zheng 
179609089f2SHongbin Zheng   Builder.CreateCall(F);
180609089f2SHongbin Zheng }
181609089f2SHongbin Zheng 
182609089f2SHongbin Zheng IntegerType *OMPGenerator::getIntPtrTy() {
183*5d01691dSTobias Grosser   return P->getAnalysis<DataLayout>().getIntPtrType(Builder.getContext());
184609089f2SHongbin Zheng }
185609089f2SHongbin Zheng 
186609089f2SHongbin Zheng Module *OMPGenerator::getModule() {
187609089f2SHongbin Zheng   return Builder.GetInsertBlock()->getParent()->getParent();
188609089f2SHongbin Zheng }
189609089f2SHongbin Zheng 
190609089f2SHongbin Zheng Function *OMPGenerator::createSubfunctionDefinition() {
191609089f2SHongbin Zheng   Module *M = getModule();
192609089f2SHongbin Zheng   Function *F = Builder.GetInsertBlock()->getParent();
193609089f2SHongbin Zheng   std::vector<Type*> Arguments(1, Builder.getInt8PtrTy());
194609089f2SHongbin Zheng   FunctionType *FT = FunctionType::get(Builder.getVoidTy(), Arguments, false);
195609089f2SHongbin Zheng   Function *FN = Function::Create(FT, Function::InternalLinkage,
196609089f2SHongbin Zheng                                   F->getName() + ".omp_subfn", M);
197609089f2SHongbin Zheng   // Do not run any polly pass on the new function.
198609089f2SHongbin Zheng   P->getAnalysis<polly::ScopDetection>().markFunctionAsInvalid(FN);
199609089f2SHongbin Zheng 
200609089f2SHongbin Zheng   Function::arg_iterator AI = FN->arg_begin();
201609089f2SHongbin Zheng   AI->setName("omp.userContext");
202609089f2SHongbin Zheng 
203609089f2SHongbin Zheng   return FN;
204609089f2SHongbin Zheng }
205609089f2SHongbin Zheng 
206609089f2SHongbin Zheng Value *OMPGenerator::loadValuesIntoStruct(SetVector<Value*> &Values) {
207609089f2SHongbin Zheng   std::vector<Type*> Members;
208609089f2SHongbin Zheng 
209609089f2SHongbin Zheng   for (unsigned i = 0; i < Values.size(); i++)
210609089f2SHongbin Zheng     Members.push_back(Values[i]->getType());
211609089f2SHongbin Zheng 
212609089f2SHongbin Zheng   StructType *Ty = StructType::get(Builder.getContext(), Members);
213609089f2SHongbin Zheng   Value *Struct = Builder.CreateAlloca(Ty, 0, "omp.userContext");
214609089f2SHongbin Zheng 
215609089f2SHongbin Zheng   for (unsigned i = 0; i < Values.size(); i++) {
216609089f2SHongbin Zheng     Value *Address = Builder.CreateStructGEP(Struct, i);
217609089f2SHongbin Zheng     Builder.CreateStore(Values[i], Address);
218609089f2SHongbin Zheng   }
219609089f2SHongbin Zheng 
220609089f2SHongbin Zheng   return Struct;
221609089f2SHongbin Zheng }
222609089f2SHongbin Zheng 
223609089f2SHongbin Zheng void OMPGenerator::extractValuesFromStruct(SetVector<Value*> OldValues,
224609089f2SHongbin Zheng                                            Value *Struct,
225609089f2SHongbin Zheng                                            ValueToValueMapTy &Map) {
226609089f2SHongbin Zheng   for (unsigned i = 0; i < OldValues.size(); i++) {
227609089f2SHongbin Zheng     Value *Address = Builder.CreateStructGEP(Struct, i);
228609089f2SHongbin Zheng     Value *NewValue = Builder.CreateLoad(Address);
229609089f2SHongbin Zheng     Map.insert(std::make_pair<Value*, Value*>(OldValues[i], NewValue));
230609089f2SHongbin Zheng   }
231609089f2SHongbin Zheng }
232609089f2SHongbin Zheng 
233609089f2SHongbin Zheng Value *OMPGenerator::createSubfunction(Value *Stride, Value *StructData,
234609089f2SHongbin Zheng                                        SetVector<Value*> Data,
235609089f2SHongbin Zheng                                        ValueToValueMapTy &Map,
236609089f2SHongbin Zheng                                        Function **SubFunction) {
237609089f2SHongbin Zheng   Function *FN = createSubfunctionDefinition();
238609089f2SHongbin Zheng 
239609089f2SHongbin Zheng   BasicBlock *PrevBB, *HeaderBB, *ExitBB, *CheckNextBB, *LoadIVBoundsBB,
240609089f2SHongbin Zheng              *AfterBB;
241609089f2SHongbin Zheng   Value *LowerBoundPtr, *UpperBoundPtr, *UserContext, *Ret1, *HasNextSchedule,
242609089f2SHongbin Zheng         *LowerBound, *UpperBound, *IV;
243609089f2SHongbin Zheng   Type *IntPtrTy = getIntPtrTy();
244609089f2SHongbin Zheng   LLVMContext &Context = FN->getContext();
245609089f2SHongbin Zheng 
246609089f2SHongbin Zheng   // Store the previous basic block.
247609089f2SHongbin Zheng   PrevBB = Builder.GetInsertBlock();
248609089f2SHongbin Zheng 
249609089f2SHongbin Zheng   // Create basic blocks.
250609089f2SHongbin Zheng   HeaderBB = BasicBlock::Create(Context, "omp.setup", FN);
251609089f2SHongbin Zheng   ExitBB = BasicBlock::Create(Context, "omp.exit", FN);
252609089f2SHongbin Zheng   CheckNextBB = BasicBlock::Create(Context, "omp.checkNext", FN);
253609089f2SHongbin Zheng   LoadIVBoundsBB = BasicBlock::Create(Context, "omp.loadIVBounds", FN);
254609089f2SHongbin Zheng 
255609089f2SHongbin Zheng   DominatorTree &DT = P->getAnalysis<DominatorTree>();
256609089f2SHongbin Zheng   DT.addNewBlock(HeaderBB, PrevBB);
257609089f2SHongbin Zheng   DT.addNewBlock(ExitBB, HeaderBB);
258609089f2SHongbin Zheng   DT.addNewBlock(CheckNextBB, HeaderBB);
259609089f2SHongbin Zheng   DT.addNewBlock(LoadIVBoundsBB, HeaderBB);
260609089f2SHongbin Zheng 
261609089f2SHongbin Zheng   // Fill up basic block HeaderBB.
262609089f2SHongbin Zheng   Builder.SetInsertPoint(HeaderBB);
263609089f2SHongbin Zheng   LowerBoundPtr = Builder.CreateAlloca(IntPtrTy, 0, "omp.lowerBoundPtr");
264609089f2SHongbin Zheng   UpperBoundPtr = Builder.CreateAlloca(IntPtrTy, 0, "omp.upperBoundPtr");
265609089f2SHongbin Zheng   UserContext = Builder.CreateBitCast(FN->arg_begin(), StructData->getType(),
266609089f2SHongbin Zheng                                       "omp.userContext");
267609089f2SHongbin Zheng 
268609089f2SHongbin Zheng   extractValuesFromStruct(Data, UserContext, Map);
269609089f2SHongbin Zheng   Builder.CreateBr(CheckNextBB);
270609089f2SHongbin Zheng 
271609089f2SHongbin Zheng   // Add code to check if another set of iterations will be executed.
272609089f2SHongbin Zheng   Builder.SetInsertPoint(CheckNextBB);
273609089f2SHongbin Zheng   Ret1 = createCallLoopNext(LowerBoundPtr, UpperBoundPtr);
274609089f2SHongbin Zheng   HasNextSchedule = Builder.CreateTrunc(Ret1, Builder.getInt1Ty(),
275609089f2SHongbin Zheng                                         "omp.hasNextScheduleBlock");
276609089f2SHongbin Zheng   Builder.CreateCondBr(HasNextSchedule, LoadIVBoundsBB, ExitBB);
277609089f2SHongbin Zheng 
278609089f2SHongbin Zheng   // Add code to to load the iv bounds for this set of iterations.
279609089f2SHongbin Zheng   Builder.SetInsertPoint(LoadIVBoundsBB);
280609089f2SHongbin Zheng   LowerBound = Builder.CreateLoad(LowerBoundPtr, "omp.lowerBound");
281609089f2SHongbin Zheng   UpperBound = Builder.CreateLoad(UpperBoundPtr, "omp.upperBound");
282609089f2SHongbin Zheng 
283609089f2SHongbin Zheng   // Subtract one as the upper bound provided by openmp is a < comparison
284609089f2SHongbin Zheng   // whereas the codegenForSequential function creates a <= comparison.
285609089f2SHongbin Zheng   UpperBound = Builder.CreateSub(UpperBound, ConstantInt::get(IntPtrTy, 1),
286609089f2SHongbin Zheng                                  "omp.upperBoundAdjusted");
287609089f2SHongbin Zheng 
288609089f2SHongbin Zheng   Builder.CreateBr(CheckNextBB);
289609089f2SHongbin Zheng   Builder.SetInsertPoint(--Builder.GetInsertPoint());
290c967d8e6STobias Grosser   IV = createLoop(LowerBound, UpperBound, Stride, Builder, P, AfterBB,
291c967d8e6STobias Grosser                   ICmpInst::ICMP_SLE);
292609089f2SHongbin Zheng 
293609089f2SHongbin Zheng   BasicBlock::iterator LoopBody = Builder.GetInsertPoint();
294609089f2SHongbin Zheng   Builder.SetInsertPoint(AfterBB->begin());
295609089f2SHongbin Zheng 
296609089f2SHongbin Zheng   // Add code to terminate this openmp subfunction.
297609089f2SHongbin Zheng   Builder.SetInsertPoint(ExitBB);
298609089f2SHongbin Zheng   createCallLoopEndNowait();
299609089f2SHongbin Zheng   Builder.CreateRetVoid();
300609089f2SHongbin Zheng 
301609089f2SHongbin Zheng   Builder.SetInsertPoint(LoopBody);
302609089f2SHongbin Zheng   *SubFunction = FN;
303609089f2SHongbin Zheng 
304609089f2SHongbin Zheng   return IV;
305609089f2SHongbin Zheng }
306609089f2SHongbin Zheng 
307609089f2SHongbin Zheng Value *OMPGenerator::createParallelLoop(Value *LowerBound, Value *UpperBound,
308609089f2SHongbin Zheng                                         Value *Stride,
309609089f2SHongbin Zheng                                         SetVector<Value*> &Values,
310609089f2SHongbin Zheng                                         ValueToValueMapTy &Map,
311609089f2SHongbin Zheng                                         BasicBlock::iterator *LoopBody) {
312609089f2SHongbin Zheng   Value *Struct, *IV, *SubfunctionParam, *NumberOfThreads;
313609089f2SHongbin Zheng   Function *SubFunction;
314609089f2SHongbin Zheng 
315609089f2SHongbin Zheng   Struct = loadValuesIntoStruct(Values);
316609089f2SHongbin Zheng 
317609089f2SHongbin Zheng   BasicBlock::iterator PrevInsertPoint = Builder.GetInsertPoint();
318609089f2SHongbin Zheng   IV = createSubfunction(Stride, Struct, Values, Map, &SubFunction);
319609089f2SHongbin Zheng   *LoopBody = Builder.GetInsertPoint();
320609089f2SHongbin Zheng   Builder.SetInsertPoint(PrevInsertPoint);
321609089f2SHongbin Zheng 
322609089f2SHongbin Zheng   // Create call for GOMP_parallel_loop_runtime_start.
323609089f2SHongbin Zheng   SubfunctionParam = Builder.CreateBitCast(Struct, Builder.getInt8PtrTy(),
324609089f2SHongbin Zheng                                            "omp_data");
325609089f2SHongbin Zheng 
326609089f2SHongbin Zheng   NumberOfThreads = Builder.getInt32(0);
327609089f2SHongbin Zheng 
328609089f2SHongbin Zheng   // Add one as the upper bound provided by openmp is a < comparison
329609089f2SHongbin Zheng   // whereas the codegenForSequential function creates a <= comparison.
330609089f2SHongbin Zheng   UpperBound = Builder.CreateAdd(UpperBound,
331609089f2SHongbin Zheng                                  ConstantInt::get(getIntPtrTy(), 1));
332609089f2SHongbin Zheng 
333609089f2SHongbin Zheng   createCallParallelLoopStart(SubFunction, SubfunctionParam, NumberOfThreads,
334609089f2SHongbin Zheng                               LowerBound, UpperBound, Stride);
335609089f2SHongbin Zheng   Builder.CreateCall(SubFunction, SubfunctionParam);
336609089f2SHongbin Zheng   createCallParallelEnd();
337609089f2SHongbin Zheng 
338609089f2SHongbin Zheng   return IV;
339609089f2SHongbin Zheng }
340