From bd8ff9bd7041106c00ac24e90dd788679b19415d Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Thu, 30 Aug 2018 18:56:11 +0000 Subject: [OPENMP] Fix PR38710: static functions are not emitted as implicitly 'declare target'. All the functions, referenced in implicit|explicit target regions must be emitted during code emission for the device. llvm-svn: 341093 --- clang/lib/CodeGen/CodeGenModule.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index c5cac6a3982..51869ef7cbe 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -2579,17 +2579,16 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction( if (getLangOpts().OpenMPIsDevice && OpenMPRuntime && !OpenMPRuntime->markAsGlobalTarget(GD) && FD->isDefined() && !DontDefer && !IsForDefinition) { - if (const FunctionDecl *FDDef = FD->getDefinition()) - if (getContext().DeclMustBeEmitted(FDDef)) { - GlobalDecl GDDef; - if (const auto *CD = dyn_cast(FDDef)) - GDDef = GlobalDecl(CD, GD.getCtorType()); - else if (const auto *DD = dyn_cast(FDDef)) - GDDef = GlobalDecl(DD, GD.getDtorType()); - else - GDDef = GlobalDecl(FDDef); - addDeferredDeclToEmit(GDDef); - } + if (const FunctionDecl *FDDef = FD->getDefinition()) { + GlobalDecl GDDef; + if (const auto *CD = dyn_cast(FDDef)) + GDDef = GlobalDecl(CD, GD.getCtorType()); + else if (const auto *DD = dyn_cast(FDDef)) + GDDef = GlobalDecl(DD, GD.getDtorType()); + else + GDDef = GlobalDecl(FDDef); + EmitGlobal(GDDef); + } } if (FD->isMultiVersion()) { -- cgit v1.2.3