]> granicus.if.org Git - clang/commitdiff
[OPENMP] Fixed problem with temp removal on some platforms in codegen for '#pragma...
authorAlexey Bataev <a.bataev@hotmail.com>
Wed, 7 May 2014 06:18:01 +0000 (06:18 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Wed, 7 May 2014 06:18:01 +0000 (06:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208162 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGOpenMPRuntime.cpp
lib/CodeGen/CGOpenMPRuntime.h
test/OpenMP/parallel_codegen.cpp

index 2009f4091187408cfda2169d1e1c19e0b45f1526..da86e2b52d0d9cf61e98a229a911e42e8d5e3c9f 100644 (file)
@@ -38,10 +38,7 @@ CGOpenMPRuntime::CGOpenMPRuntime(CodeGenModule &CGM)
 
 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::GetOrCreateDefaultOpenMPLocation(OpenMPLocationFlags Flags) {
           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::EmitOpenMPUpdateLocation(
 
   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;
index 7ba7ada2b13f6dfd1ce983045d851996aa99d39c..06103cf4d6f50fddb3c800bc54c96ab6932f372e 100644 (file)
@@ -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
index 2bc57f5870fd07e1c50b2c8a94c4d752be5a0963..d20bc84856d6f01bfd5fbd1179aeb35485085592 100644 (file)
@@ -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