[PATCH] D129700: [clang] Don't emit type tests for dllexport/import classes

Arthur Eubanks via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 13 15:54:23 PDT 2022


aeubanks created this revision.
aeubanks added reviewers: pcc, tejohnson.
Herald added subscribers: ormris, steven_wu, hiraditya.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

According to https://clang.llvm.org/docs/LTOVisibility.html, classes on
Windows with dllimport/export receive public LTO visibility and
therefore should not participate in WPD.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129700

Files:
  clang/lib/CodeGen/CGVTables.cpp
  clang/test/CodeGenCXX/lto-visibility-inference.cpp


Index: clang/test/CodeGenCXX/lto-visibility-inference.cpp
===================================================================
--- clang/test/CodeGenCXX/lto-visibility-inference.cpp
+++ clang/test/CodeGenCXX/lto-visibility-inference.cpp
@@ -74,10 +74,10 @@
   // MS: type.test{{.*}}!"?AUC2@@"
   c2->f();
   // ITANIUM: type.test{{.*}}!"_ZTS2C3"
-  // MS: type.test{{.*}}!"?AUC3@@"
+  // MS-NOT: type.test{{.*}}!"?AUC3@@"
   c3->f();
   // ITANIUM: type.test{{.*}}!"_ZTS2C4"
-  // MS: type.test{{.*}}!"?AUC4@@"
+  // MS-NOT: type.test{{.*}}!"?AUC4@@"
   c4->f();
   // ITANIUM-NOT: type.test{{.*}}!"_ZTS2C5"
   // MS-NOT: type.test{{.*}}!"?AUC5@@"
Index: clang/lib/CodeGen/CGVTables.cpp
===================================================================
--- clang/lib/CodeGen/CGVTables.cpp
+++ clang/lib/CodeGen/CGVTables.cpp
@@ -1176,7 +1176,8 @@
 }
 
 bool CodeGenModule::AlwaysHasLTOVisibilityPublic(const CXXRecordDecl *RD) {
-  if (RD->hasAttr<LTOVisibilityPublicAttr>() || RD->hasAttr<UuidAttr>())
+  if (RD->hasAttr<LTOVisibilityPublicAttr>() || RD->hasAttr<UuidAttr>() ||
+      RD->hasAttr<DLLExportAttr>() || RD->hasAttr<DLLImportAttr>())
     return true;
 
   if (!getCodeGenOpts().LTOVisibilityPublicStd)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129700.444441.patch
Type: text/x-patch
Size: 1218 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220713/fb57f504/attachment.bin>


More information about the cfe-commits mailing list