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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@347793
91177308-0d34-0410-b5e6-
96231b3b80d8
// region.
if (LangOpts.OpenMP && LangOpts.OpenMPIsDevice &&
!isInOpenMPDeclareTargetContext() &&
- !isInOpenMPTargetExecutionDirective())
+ !isInOpenMPTargetExecutionDirective()) {
+ if (!DefinitionRequired)
+ MarkVirtualMembersReferenced(Loc, Class);
return;
+ }
// Try to insert this class into the map.
LoadExternalVTableUses();
{}
}
+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_}}