[PATCH] D44796: Set dso_local on vtables

Rafael Avila de Espindola via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 22 11:41:35 PDT 2018


espindola created this revision.
espindola added reviewers: rnk, echristo.

https://reviews.llvm.org/D44796

Files:
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGenCXX/dllexport.cpp


Index: test/CodeGenCXX/dllexport.cpp
===================================================================
--- test/CodeGenCXX/dllexport.cpp
+++ test/CodeGenCXX/dllexport.cpp
@@ -41,6 +41,8 @@
 // GNU-NOT: @ExternGlobalDecl
 __declspec(dllexport) extern int ExternGlobalDecl;
 
+// GNU-DAG: @_ZTVN10__cxxabiv117__class_type_infoE = external dso_local global
+
 // dllexport implies a definition.
 // MSC-DAG: @"?GlobalDef@@3HA" = dso_local dllexport global i32 0, align 4
 // GNU-DAG: @GlobalDef            = dso_local dllexport global i32 0, align 4
Index: lib/CodeGen/ItaniumCXXABI.cpp
===================================================================
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -2848,6 +2848,7 @@
 
   const char *VTableName = nullptr;
 
+  const CXXRecordDecl *RD = nullptr;
   switch (Ty->getTypeClass()) {
 #define TYPE(Class, Base)
 #define ABSTRACT_TYPE(Class, Base)
@@ -2899,8 +2900,7 @@
     break;
 
   case Type::Record: {
-    const CXXRecordDecl *RD =
-      cast<CXXRecordDecl>(cast<RecordType>(Ty)->getDecl());
+    RD = cast<CXXRecordDecl>(cast<RecordType>(Ty)->getDecl());
 
     if (!RD->hasDefinition() || !RD->getNumBases()) {
       VTableName = ClassTypeInfo;
@@ -2948,6 +2948,7 @@
 
   llvm::Constant *VTable =
     CGM.getModule().getOrInsertGlobal(VTableName, CGM.Int8PtrTy);
+  CGM.setGVProperties(cast<llvm::GlobalValue>(VTable->stripPointerCasts()), RD);
 
   llvm::Type *PtrDiffTy =
     CGM.getTypes().ConvertType(CGM.getContext().getPointerDiffType());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44796.139483.patch
Type: text/x-patch
Size: 1529 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180322/01f7b543/attachment.bin>


More information about the cfe-commits mailing list