r342741 - [OPENMP] Disable emission of the class with vptr if they are not used in

Alexey Bataev via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 21 07:55:27 PDT 2018


Author: abataev
Date: Fri Sep 21 07:55:26 2018
New Revision: 342741

URL: http://llvm.org/viewvc/llvm-project?rev=342741&view=rev
Log:
[OPENMP] Disable emission of the class with vptr if they are not used in
target constructs.

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

Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/test/OpenMP/declare_target_codegen.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=342741&r1=342740&r2=342741&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Sep 21 07:55:26 2018
@@ -14918,7 +14918,8 @@ void Sema::MarkVTableUsed(SourceLocation
   // 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.

Modified: cfe/trunk/test/OpenMP/declare_target_codegen.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/declare_target_codegen.cpp?rev=342741&r1=342740&r2=342741&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/declare_target_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/declare_target_codegen.cpp Fri Sep 21 07:55:26 2018
@@ -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}}




More information about the cfe-commits mailing list