[OPENMP] Disable emission of the class with vptr if they are not used in
authorAlexey Bataev <a.bataev@hotmail.com>
Fri, 21 Sep 2018 14:55:26 +0000 (14:55 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Fri, 21 Sep 2018 14:55:26 +0000 (14:55 +0000)
target constructs.

Prevent compilation of the classes with the virtual tables when
compiling for the device.

llvm-svn: 342741

clang/lib/Sema/SemaDeclCXX.cpp
clang/test/OpenMP/declare_target_codegen.cpp

index fd0f487..95ad45d 100644 (file)
@@ -14918,7 +14918,8 @@ void Sema::MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class,
   // Do not mark as used if compiling for the device outside of the target
   // region.
   if (LangOpts.OpenMP && LangOpts.OpenMPIsDevice &&
-      !isInOpenMPDeclareTargetContext() && !getCurFunctionDecl())
+      !isInOpenMPDeclareTargetContext() &&
+      !isInOpenMPTargetExecutionDirective())
     return;
 
   // Try to insert this class into the map.
index 2475c49..87f534e 100644 (file)
@@ -157,6 +157,16 @@ struct Bake {
 template class Bake<int>;
 #pragma omp end declare target
 
+struct BaseNonT {
+  virtual ~BaseNonT() {}
+};
+
+#pragma omp declare target
+struct BakeNonT {
+  virtual ~BakeNonT() {}
+};
+#pragma omp end declare target
+
 // CHECK-DAG: declare extern_weak signext i32 @__create()
 
 // CHECK-NOT: define {{.*}}{{baz1|baz4|maini1|Base}}