summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2018-11-28 19:00:07 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2018-11-28 19:00:07 +0000
commit719713ab7d310708b83b026519bddce2a406d497 (patch)
treeb28fd4db3a5a3d3aeee1629a3e56044db9bb8fbc
parent2c8a0543107b23d3032b63e010dd4665f251d14f (diff)
downloadbcm5719-llvm-719713ab7d310708b83b026519bddce2a406d497.tar.gz
bcm5719-llvm-719713ab7d310708b83b026519bddce2a406d497.zip
[OPENMP]Fix emission of the target regions in virtual functions.
Fixed emission of the target regions found in the virtual functions. Previously we may end up with the situation when those regions could be skipped. llvm-svn: 347793
-rw-r--r--clang/lib/Sema/SemaDeclCXX.cpp5
-rw-r--r--clang/test/OpenMP/declare_target_codegen.cpp24
2 files changed, 28 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 8a716ed4cca..e408c043791 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -14968,8 +14968,11 @@ void Sema::MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class,
// region.
if (LangOpts.OpenMP && LangOpts.OpenMPIsDevice &&
!isInOpenMPDeclareTargetContext() &&
- !isInOpenMPTargetExecutionDirective())
+ !isInOpenMPTargetExecutionDirective()) {
+ if (!DefinitionRequired)
+ MarkVirtualMembersReferenced(Loc, Class);
return;
+ }
// Try to insert this class into the map.
LoadExternalVTableUses();
diff --git a/clang/test/OpenMP/declare_target_codegen.cpp b/clang/test/OpenMP/declare_target_codegen.cpp
index 70da60a422e..cc7525a44b2 100644
--- a/clang/test/OpenMP/declare_target_codegen.cpp
+++ b/clang/test/OpenMP/declare_target_codegen.cpp
@@ -180,6 +180,30 @@ void B<T>::virtual_foo() {
{}
}
+struct A {
+ virtual void emitted() {}
+};
+
+template <typename T>
+struct C : public A {
+ virtual void emitted();
+};
+
+template <typename T>
+void C<T>::emitted() {
+#pragma omp target
+ {}
+}
+
+int main() {
+ A *X = new C<int>();
+ X->emitted();
+ return 0;
+}
+
+// CHECK-DAG: define {{.*}}void @__omp_offloading_{{.*}}virtual_foo{{.*}}_l[[@LINE-25]]()
+// CHECK-DAG: define {{.*}}void @__omp_offloading_{{.*}}emitted{{.*}}_l[[@LINE-11]]()
+
// CHECK-DAG: declare extern_weak signext i32 @__create()
// CHECK-NOT: define {{.*}}{{baz1|baz4|maini1|Base|virtual_}}
OpenPOWER on IntegriCloud