summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2018-05-02 15:45:28 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2018-05-02 15:45:28 +0000
commit6d944109144acdfdba7caf6fd1a29cbbff0f4628 (patch)
tree0004f17c954ab995661a4f4443c4c3d60e889ec7 /clang/lib/CodeGen
parentf1fadea5cec7e3b49de653c648e1a63436513894 (diff)
downloadbcm5719-llvm-6d944109144acdfdba7caf6fd1a29cbbff0f4628.tar.gz
bcm5719-llvm-6d944109144acdfdba7caf6fd1a29cbbff0f4628.zip
[OPENMP] Support C++ member functions in the device constructs.
Added correct emission of the C++ member functions for the device function when they are used in the device constructs. llvm-svn: 331365
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGOpenMPRuntime.cpp13
-rw-r--r--clang/lib/CodeGen/CGOpenMPRuntime.h2
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp2
3 files changed, 5 insertions, 12 deletions
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 2c66f6947d3..18b51ea0bcc 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -899,9 +899,6 @@ static void EmitOMPAggregateInit(CodeGenFunction &CGF, Address DestAddr,
static llvm::Optional<OMPDeclareTargetDeclAttr::MapTypeTy>
isDeclareTargetDeclaration(const ValueDecl *VD) {
- if (const auto *MD = dyn_cast<CXXMethodDecl>(VD))
- if (!MD->isStatic())
- return llvm::None;
for (const Decl *D : VD->redecls()) {
if (!D->hasAttrs())
continue;
@@ -7934,28 +7931,24 @@ CGOpenMPRuntime::DisableAutoDeclareTargetRAII::~DisableAutoDeclareTargetRAII() {
CGM.getOpenMPRuntime().ShouldMarkAsGlobal = SavedShouldMarkAsGlobal;
}
-bool CGOpenMPRuntime::markAsGlobalTarget(const FunctionDecl *D) {
+bool CGOpenMPRuntime::markAsGlobalTarget(GlobalDecl GD) {
if (!CGM.getLangOpts().OpenMPIsDevice || !ShouldMarkAsGlobal)
return true;
+ const auto *D = cast<FunctionDecl>(GD.getDecl());
const FunctionDecl *FD = D->getCanonicalDecl();
// Do not to emit function if it is marked as declare target as it was already
// emitted.
if (isDeclareTargetDeclaration(D)) {
if (D->hasBody() && AlreadyEmittedTargetFunctions.count(FD) == 0) {
if (auto *F = dyn_cast_or_null<llvm::Function>(
- CGM.GetGlobalValue(CGM.getMangledName(D))))
+ CGM.GetGlobalValue(CGM.getMangledName(GD))))
return !F->isDeclaration();
return false;
}
return true;
}
- // Do not mark member functions except for static.
- if (const auto *Method = dyn_cast<CXXMethodDecl>(FD))
- if (!Method->isStatic())
- return true;
-
return !AlreadyEmittedTargetFunctions.insert(FD).second;
}
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.h b/clang/lib/CodeGen/CGOpenMPRuntime.h
index e1ce09adc22..4546da4746f 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.h
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.h
@@ -1505,7 +1505,7 @@ public:
/// Marks the declaration as alread emitted for the device code and returns
/// true, if it was marked already, and false, otherwise.
- bool markAsGlobalTarget(const FunctionDecl *D);
+ bool markAsGlobalTarget(GlobalDecl GD);
};
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 063b9be4cd0..6e3747a188b 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -2398,7 +2398,7 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction(
if (const FunctionDecl *FD = cast_or_null<FunctionDecl>(D)) {
// For the device mark the function as one that should be emitted.
if (getLangOpts().OpenMPIsDevice && OpenMPRuntime &&
- !OpenMPRuntime->markAsGlobalTarget(FD) && FD->isDefined() &&
+ !OpenMPRuntime->markAsGlobalTarget(GD) && FD->isDefined() &&
!DontDefer && !IsForDefinition)
addDeferredDeclToEmit(GD);
OpenPOWER on IntegriCloud