[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
This commit is contained in:
Alexey Bataev 2018-11-28 19:00:07 +00:00
parent 2c8a054310
commit 719713ab7d
2 changed files with 28 additions and 1 deletions

View File

@ -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();

View File

@ -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_}}