r213927 - [OPENMP] Improved codegen for outlined functions for 'parallel' directives.
Alexey Bataev
a.bataev at hotmail.com
Fri Jul 25 00:55:18 PDT 2014
Author: abataev
Date: Fri Jul 25 02:55:17 2014
New Revision: 213927
URL: http://llvm.org/viewvc/llvm-project?rev=213927&view=rev
Log:
[OPENMP] Improved codegen for outlined functions for 'parallel' directives.
Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=213927&r1=213926&r2=213927&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Fri Jul 25 02:55:17 2014
@@ -128,12 +128,31 @@ llvm::Value *CGOpenMPRuntime::GetOpenMPG
if (I != OpenMPGtidMap.end()) {
GTid = I->second;
} 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);
+ // Check if current function is a function which has first parameter
+ // with type int32 and name ".global_tid.".
+ if (!CGF.CurFn->arg_empty() &&
+ CGF.CurFn->arg_begin()->getType()->isPointerTy() &&
+ CGF.CurFn->arg_begin()
+ ->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;
}
return GTid;
More information about the cfe-commits
mailing list