From 4f4bf7c3482598c02bea7fbe9bbcca56ac720313 Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Thu, 15 Mar 2018 15:47:20 +0000 Subject: [OPENMP] Codegen for `omp declare target` construct. Added initial codegen for device side of declarations inside `omp declare target` construct + codegen for implicit `declare target` functions, which are used in the target regions. llvm-svn: 327636 --- clang/lib/CodeGen/CodeGenModule.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index e75780a0a93..3c503eb66fa 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -2383,6 +2383,12 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction( // Any attempts to use a MultiVersion function should result in retrieving // the iFunc instead. Name Mangling will handle the rest of the changes. if (const FunctionDecl *FD = cast_or_null(D)) { + // For the device mark the function as one that should be emitted. + if (getLangOpts().OpenMPIsDevice && OpenMPRuntime && + !OpenMPRuntime->markAsGlobalTarget(FD) && FD->isDefined() && + !DontDefer && !IsForDefinition) + addDeferredDeclToEmit(GD); + if (FD->isMultiVersion() && FD->getAttr()->isDefaultVersion()) { UpdateMultiVersionNames(GD, FD); if (!IsForDefinition) @@ -3072,6 +3078,12 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D, if (getLangOpts().OpenCL && ASTTy->isSamplerT()) return; + // If this is OpenMP device, check if it is legal to emit this global + // normally. + if (LangOpts.OpenMPIsDevice && OpenMPRuntime && + OpenMPRuntime->emitTargetGlobalVariable(D)) + return; + llvm::Constant *Init = nullptr; CXXRecordDecl *RD = ASTTy->getBaseElementTypeUnsafe()->getAsCXXRecordDecl(); bool NeedsGlobalCtor = false; -- cgit v1.2.3