summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2014-05-07 06:18:01 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2014-05-07 06:18:01 +0000
commit15007ba94a581bac1cf167db0f18ea607823477f (patch)
treec23be445a3a89be1d907c6be8dacc8551387d535
parent5944d9ce3e53a479ca2e780a54eb1309e31da097 (diff)
downloadbcm5719-llvm-15007ba94a581bac1cf167db0f18ea607823477f.tar.gz
bcm5719-llvm-15007ba94a581bac1cf167db0f18ea607823477f.zip
[OPENMP] Fixed problem with temp removal on some platforms in codegen for '#pragma omp parallel'
llvm-svn: 208162
-rw-r--r--clang/lib/CodeGen/CGOpenMPRuntime.cpp14
-rw-r--r--clang/lib/CodeGen/CGOpenMPRuntime.h3
-rw-r--r--clang/test/OpenMP/parallel_codegen.cpp2
3 files changed, 7 insertions, 12 deletions
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 2009f409118..da86e2b52d0 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -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;
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.h b/clang/lib/CodeGen/CGOpenMPRuntime.h
index 7ba7ada2b13..06103cf4d6f 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.h
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.h
@@ -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
diff --git a/clang/test/OpenMP/parallel_codegen.cpp b/clang/test/OpenMP/parallel_codegen.cpp
index 2bc57f5870f..d20bc84856d 100644
--- a/clang/test/OpenMP/parallel_codegen.cpp
+++ b/clang/test/OpenMP/parallel_codegen.cpp
@@ -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
OpenPOWER on IntegriCloud