[llvm-branch-commits] [cfe-branch] r340351 - Merging r340191:
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Aug 21 15:39:17 PDT 2018
Author: hans
Date: Tue Aug 21 15:39:17 2018
New Revision: 340351
URL: http://llvm.org/viewvc/llvm-project?rev=340351&view=rev
Log:
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.
------------------------------------------------------------------------
Modified:
cfe/branches/release_70/ (props changed)
cfe/branches/release_70/lib/CodeGen/CodeGenModule.cpp
cfe/branches/release_70/test/OpenMP/declare_target_codegen.cpp
Propchange: cfe/branches/release_70/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Aug 21 15:39:17 2018
@@ -1,4 +1,4 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:338552-338553,338602,338627,338749,338934,338942,339074,339128,339170,339210,339264,339281,339317,339372-339374,339379,339428,339494,339597,339603,340048,340079,340101
+/cfe/trunk:338552-338553,338602,338627,338749,338934,338942,339074,339128,339170,339210,339264,339281,339317,339372-339374,339379,339428,339494,339597,339603,340048,340079,340101,340191
/cfe/trunk/test:170344
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_70/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_70/lib/CodeGen/CodeGenModule.cpp?rev=340351&r1=340350&r2=340351&view=diff
==============================================================================
--- cfe/branches/release_70/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/branches/release_70/lib/CodeGen/CodeGenModule.cpp Tue Aug 21 15:39:17 2018
@@ -2539,15 +2539,17 @@ llvm::Constant *CodeGenModule::GetOrCrea
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()) {
Modified: cfe/branches/release_70/test/OpenMP/declare_target_codegen.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_70/test/OpenMP/declare_target_codegen.cpp?rev=340351&r1=340350&r2=340351&view=diff
==============================================================================
--- cfe/branches/release_70/test/OpenMP/declare_target_codegen.cpp (original)
+++ cfe/branches/release_70/test/OpenMP/declare_target_codegen.cpp Tue Aug 21 15:39:17 2018
@@ -91,5 +91,19 @@ int baz2() {
return 2 + baz3();
}
+extern int create() throw();
+
+static __typeof(create) __t_create __attribute__((__weakref__("__create")));
+
+int baz5() {
+ bool a;
+// CHECK-DAG: define weak void @__omp_offloading_{{.*}}baz5{{.*}}_l[[@LINE+1]](i64 {{.*}})
+#pragma omp target
+ a = __extension__(void *) & __t_create != 0;
+ return a;
+}
+
+// CHECK-DAG: declare extern_weak signext i32 @__create()
+
// CHECK-NOT: define {{.*}}{{baz1|baz4|maini1}}
#endif // HEADER
More information about the llvm-branch-commits
mailing list