r208162 - [OPENMP] Fixed problem with temp removal on some platforms in codegen for '#pragma omp parallel'

Alexey Bataev a.bataev at hotmail.com
Tue May 6 23:18:01 PDT 2014


Author: abataev
Date: Wed May  7 01:18:01 2014
New Revision: 208162

URL: http://llvm.org/viewvc/llvm-project?rev=208162&view=rev
Log:
[OPENMP] Fixed problem with temp removal on some platforms in codegen for '#pragma omp parallel'

Modified:
    cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
    cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
    cfe/trunk/test/OpenMP/parallel_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=208162&r1=208161&r2=208162&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Wed May  7 01:18:01 2014
@@ -38,10 +38,7 @@ CGOpenMPRuntime::CGOpenMPRuntime(CodeGen
 
 llvm::Value *
 CGOpenMPRuntime::GetOrCreateDefaultOpenMPLocation(OpenMPLocationFlags Flags) {
-  llvm::Twine OpenMPDefaultLocName =
-      ".kmpc_default_loc_" + llvm::Twine::utohexstr(Flags) + ".addr";
-  llvm::Value *Entry =
-      CGM.getModule().getNamedValue(OpenMPDefaultLocName.str());
+  llvm::Value *Entry = OpenMPDefaultLocMap.lookup(Flags);
   if (!Entry) {
     if (!DefaultOpenMPPSource) {
       // Initialize default location for psource field of ident_t structure of
@@ -54,7 +51,7 @@ CGOpenMPRuntime::GetOrCreateDefaultOpenM
           llvm::ConstantExpr::getBitCast(DefaultOpenMPPSource, CGM.Int8PtrTy);
     }
     llvm::GlobalVariable *DefaultOpenMPLocation = cast<llvm::GlobalVariable>(
-        CGM.CreateRuntimeVariable(IdentTy, OpenMPDefaultLocName.str()));
+        CGM.CreateRuntimeVariable(IdentTy, ".kmpc_default_loc.addr"));
     DefaultOpenMPLocation->setUnnamedAddr(true);
     DefaultOpenMPLocation->setConstant(true);
     DefaultOpenMPLocation->setLinkage(llvm::GlobalValue::PrivateLinkage);
@@ -79,16 +76,13 @@ llvm::Value *CGOpenMPRuntime::EmitOpenMP
 
   assert(CGF.CurFn && "No function in current CodeGenFunction.");
 
-  llvm::Twine OpenMPLocName =
-      ".kmpc_loc_" + llvm::Twine::utohexstr(Flags) + ".addr";
-
   llvm::Value *LocValue = nullptr;
   OpenMPLocMapTy::iterator I = OpenMPLocMap.find(CGF.CurFn);
   if (I != OpenMPLocMap.end()) {
     LocValue = I->second;
   } else {
-    // Generate "ident_t .kmpc_loc_<flags>.addr;"
-    llvm::AllocaInst *AI = CGF.CreateTempAlloca(IdentTy, OpenMPLocName);
+    // Generate "ident_t .kmpc_loc.addr;"
+    llvm::AllocaInst *AI = CGF.CreateTempAlloca(IdentTy, ".kmpc_loc.addr");
     AI->setAlignment(CGM.getDataLayout().getPrefTypeAlignment(IdentTy));
     OpenMPLocMap[CGF.CurFn] = AI;
     LocValue = AI;

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h?rev=208162&r1=208161&r2=208162&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h Wed May  7 01:18:01 2014
@@ -76,6 +76,9 @@ private:
   /// \brief Default const ident_t object used for initialization of all other
   /// ident_t objects.
   llvm::Constant *DefaultOpenMPPSource;
+  /// \brief Map of flags and corrsponding default locations.
+  typedef llvm::DenseMap<unsigned, llvm::Value *> OpenMPDefaultLocMapTy;
+  OpenMPDefaultLocMapTy OpenMPDefaultLocMap;
   llvm::Value *GetOrCreateDefaultOpenMPLocation(OpenMPLocationFlags Flags);
   /// \brief Describes ident structure that describes a source location.
   /// All descriptions are taken from

Modified: cfe/trunk/test/OpenMP/parallel_codegen.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/parallel_codegen.cpp?rev=208162&r1=208161&r2=208162&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/parallel_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/parallel_codegen.cpp Wed May  7 01:18:01 2014
@@ -2,8 +2,6 @@
 // RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp=libiomp5 -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -g -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix=CHECK-DEBUG %s
 // expected-no-diagnostics
-// FIXME: This test stiil crashing because of mem leak.
-// REQUIRES: disabled
 #ifndef HEADER
 #define HEADER
 





More information about the cfe-commits mailing list