mirror of https://github.com/microsoft/clang.git
[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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341093 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
914b703238
commit
c029fb7612
|
@ -1832,7 +1832,8 @@ llvm::Value *CGOpenMPRuntimeNVPTX::emitTeamsOutlinedFunction(
|
|||
}
|
||||
|
||||
void CGOpenMPRuntimeNVPTX::emitGenericVarsProlog(CodeGenFunction &CGF,
|
||||
SourceLocation Loc) {
|
||||
SourceLocation Loc,
|
||||
bool WithSPMDCheck) {
|
||||
if (getDataSharingMode(CGM) != CGOpenMPRuntimeNVPTX::Generic)
|
||||
return;
|
||||
|
||||
|
@ -1855,7 +1856,8 @@ void CGOpenMPRuntimeNVPTX::emitGenericVarsProlog(CodeGenFunction &CGF,
|
|||
GlobalRecordSize = llvm::alignTo(GlobalRecordSize, Alignment);
|
||||
|
||||
llvm::Value *GlobalRecCastAddr;
|
||||
if (getExecutionMode() == CGOpenMPRuntimeNVPTX::EM_Unknown) {
|
||||
if (WithSPMDCheck ||
|
||||
getExecutionMode() == CGOpenMPRuntimeNVPTX::EM_Unknown) {
|
||||
llvm::BasicBlock *ExitBB = CGF.createBasicBlock(".exit");
|
||||
llvm::BasicBlock *SPMDBB = CGF.createBasicBlock(".spmd");
|
||||
llvm::BasicBlock *NonSPMDBB = CGF.createBasicBlock(".non-spmd");
|
||||
|
@ -1963,7 +1965,8 @@ void CGOpenMPRuntimeNVPTX::emitGenericVarsProlog(CodeGenFunction &CGF,
|
|||
I->getSecond().MappedParams->apply(CGF);
|
||||
}
|
||||
|
||||
void CGOpenMPRuntimeNVPTX::emitGenericVarsEpilog(CodeGenFunction &CGF) {
|
||||
void CGOpenMPRuntimeNVPTX::emitGenericVarsEpilog(CodeGenFunction &CGF,
|
||||
bool WithSPMDCheck) {
|
||||
if (getDataSharingMode(CGM) != CGOpenMPRuntimeNVPTX::Generic)
|
||||
return;
|
||||
|
||||
|
@ -1979,7 +1982,8 @@ void CGOpenMPRuntimeNVPTX::emitGenericVarsEpilog(CodeGenFunction &CGF) {
|
|||
Addr);
|
||||
}
|
||||
if (I->getSecond().GlobalRecordAddr) {
|
||||
if (getExecutionMode() == CGOpenMPRuntimeNVPTX::EM_Unknown) {
|
||||
if (WithSPMDCheck ||
|
||||
getExecutionMode() == CGOpenMPRuntimeNVPTX::EM_Unknown) {
|
||||
CGBuilderTy &Bld = CGF.Builder;
|
||||
llvm::BasicBlock *ExitBB = CGF.createBasicBlock(".exit");
|
||||
llvm::BasicBlock *NonSPMDBB = CGF.createBasicBlock(".non-spmd");
|
||||
|
@ -3972,13 +3976,13 @@ void CGOpenMPRuntimeNVPTX::emitFunctionProlog(CodeGenFunction &CGF,
|
|||
Data.insert(std::make_pair(VD, std::make_pair(FD, Address::invalid())));
|
||||
}
|
||||
if (!NeedToDelayGlobalization) {
|
||||
emitGenericVarsProlog(CGF, D->getBeginLoc());
|
||||
emitGenericVarsProlog(CGF, D->getBeginLoc(), /*WithSPMDCheck=*/true);
|
||||
struct GlobalizationScope final : EHScopeStack::Cleanup {
|
||||
GlobalizationScope() = default;
|
||||
|
||||
void Emit(CodeGenFunction &CGF, Flags flags) override {
|
||||
static_cast<CGOpenMPRuntimeNVPTX &>(CGF.CGM.getOpenMPRuntime())
|
||||
.emitGenericVarsEpilog(CGF);
|
||||
.emitGenericVarsEpilog(CGF, /*WithSPMDCheck=*/true);
|
||||
}
|
||||
};
|
||||
CGF.EHStack.pushCleanup<GlobalizationScope>(NormalAndEHCleanup);
|
||||
|
|
|
@ -72,10 +72,11 @@ private:
|
|||
void emitNonSPMDEntryFooter(CodeGenFunction &CGF, EntryFunctionState &EST);
|
||||
|
||||
/// Helper for generic variables globalization prolog.
|
||||
void emitGenericVarsProlog(CodeGenFunction &CGF, SourceLocation Loc);
|
||||
void emitGenericVarsProlog(CodeGenFunction &CGF, SourceLocation Loc,
|
||||
bool WithSPMDCheck = false);
|
||||
|
||||
/// Helper for generic variables globalization epilog.
|
||||
void emitGenericVarsEpilog(CodeGenFunction &CGF);
|
||||
void emitGenericVarsEpilog(CodeGenFunction &CGF, bool WithSPMDCheck = false);
|
||||
|
||||
/// Helper for SPMD mode target directive's entry function.
|
||||
void emitSPMDEntryHeader(CodeGenFunction &CGF, EntryFunctionState &EST,
|
||||
|
|
|
@ -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<CXXConstructorDecl>(FDDef))
|
||||
GDDef = GlobalDecl(CD, GD.getCtorType());
|
||||
else if (const auto *DD = dyn_cast<CXXDestructorDecl>(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<CXXConstructorDecl>(FDDef))
|
||||
GDDef = GlobalDecl(CD, GD.getCtorType());
|
||||
else if (const auto *DD = dyn_cast<CXXDestructorDecl>(FDDef))
|
||||
GDDef = GlobalDecl(DD, GD.getDtorType());
|
||||
else
|
||||
GDDef = GlobalDecl(FDDef);
|
||||
EmitGlobal(GDDef);
|
||||
}
|
||||
}
|
||||
|
||||
if (FD->isMultiVersion()) {
|
||||
|
|
|
@ -78,7 +78,7 @@ public:
|
|||
|
||||
int foo();
|
||||
|
||||
int baz1();
|
||||
static int baz1() { return 0; }
|
||||
|
||||
int baz2();
|
||||
|
||||
|
|
Loading…
Reference in New Issue