forked from OSchip/llvm-project
[OPENMP] Improved codegen for outlined functions for 'parallel' directives.
llvm-svn: 213927
This commit is contained in:
parent
94bd553eb8
commit
d6c57554f9
|
@ -128,12 +128,31 @@ llvm::Value *CGOpenMPRuntime::GetOpenMPGlobalThreadNum(CodeGenFunction &CGF,
|
||||||
if (I != OpenMPGtidMap.end()) {
|
if (I != OpenMPGtidMap.end()) {
|
||||||
GTid = I->second;
|
GTid = I->second;
|
||||||
} else {
|
} else {
|
||||||
// Generate "int32 .kmpc_global_thread_num.addr;"
|
// Check if current function is a function which has first parameter
|
||||||
CGBuilderTy::InsertPointGuard IPG(CGF.Builder);
|
// with type int32 and name ".global_tid.".
|
||||||
CGF.Builder.SetInsertPoint(CGF.AllocaInsertPt);
|
if (!CGF.CurFn->arg_empty() &&
|
||||||
llvm::Value *Args[] = {EmitOpenMPUpdateLocation(CGF, Loc)};
|
CGF.CurFn->arg_begin()->getType()->isPointerTy() &&
|
||||||
GTid = CGF.EmitRuntimeCall(
|
CGF.CurFn->arg_begin()
|
||||||
CreateRuntimeFunction(OMPRTL__kmpc_global_thread_num), Args);
|
->getType()
|
||||||
|
->getPointerElementType()
|
||||||
|
->isIntegerTy() &&
|
||||||
|
CGF.CurFn->arg_begin()
|
||||||
|
->getType()
|
||||||
|
->getPointerElementType()
|
||||||
|
->getIntegerBitWidth() == 32 &&
|
||||||
|
CGF.CurFn->arg_begin()->hasName() &&
|
||||||
|
CGF.CurFn->arg_begin()->getName() == ".global_tid.") {
|
||||||
|
CGBuilderTy::InsertPointGuard IPG(CGF.Builder);
|
||||||
|
CGF.Builder.SetInsertPoint(CGF.AllocaInsertPt);
|
||||||
|
GTid = CGF.Builder.CreateLoad(CGF.CurFn->arg_begin());
|
||||||
|
} else {
|
||||||
|
// Generate "int32 .kmpc_global_thread_num.addr;"
|
||||||
|
CGBuilderTy::InsertPointGuard IPG(CGF.Builder);
|
||||||
|
CGF.Builder.SetInsertPoint(CGF.AllocaInsertPt);
|
||||||
|
llvm::Value *Args[] = {EmitOpenMPUpdateLocation(CGF, Loc)};
|
||||||
|
GTid = CGF.EmitRuntimeCall(
|
||||||
|
CreateRuntimeFunction(OMPRTL__kmpc_global_thread_num), Args);
|
||||||
|
}
|
||||||
OpenMPGtidMap[CGF.CurFn] = GTid;
|
OpenMPGtidMap[CGF.CurFn] = GTid;
|
||||||
}
|
}
|
||||||
return GTid;
|
return GTid;
|
||||||
|
|
Loading…
Reference in New Issue