summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2018-08-21 22:39:17 +0000
committerHans Wennborg <hans@hanshq.net>2018-08-21 22:39:17 +0000
commitd8568622e6c4df768f8963d7b80d2d47e5b8f03b (patch)
tree86ff9b8fb32464da10c93826584daa6c245fa190 /clang/lib/CodeGen/CodeGenModule.cpp
parente23b77ca937f826d0561c0a02a1b5a414a3fc148 (diff)
downloadbcm5719-llvm-d8568622e6c4df768f8963d7b80d2d47e5b8f03b.tar.gz
bcm5719-llvm-d8568622e6c4df768f8963d7b80d2d47e5b8f03b.zip
Merging r340191:
------------------------------------------------------------------------ r340191 | abataev | 2018-08-20 20:03:40 +0200 (Mon, 20 Aug 2018) | 6 lines [OPENMP] Fix crash on the emission of the weak function declaration. If the function is actually a weak reference, it should not be marked as deferred definition as this is only a declaration. Patch adds checks for the definitions if they must be emitted. Otherwise, only declaration is emitted. ------------------------------------------------------------------------ llvm-svn: 340351
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 8c5e0df0969..155ee6c6af1 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -2539,15 +2539,17 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction(
if (getLangOpts().OpenMPIsDevice && OpenMPRuntime &&
!OpenMPRuntime->markAsGlobalTarget(GD) && FD->isDefined() &&
!DontDefer && !IsForDefinition) {
- 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);
- addDeferredDeclToEmit(GDDef);
+ 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 (FD->isMultiVersion()) {
OpenPOWER on IntegriCloud