Skip to content

Commit f34ecb5

Browse files
committed
[clang] Don't emit type tests for dllexport/import classes
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. Reviewed By: pcc Differential Revision: https://reviews.llvm.org/D129700
1 parent 9cf1881 commit f34ecb5

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

clang/lib/CodeGen/CGVTables.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,8 @@ void CodeGenModule::EmitDeferredVTables() {
12121212
}
12131213

12141214
bool CodeGenModule::AlwaysHasLTOVisibilityPublic(const CXXRecordDecl *RD) {
1215-
if (RD->hasAttr<LTOVisibilityPublicAttr>() || RD->hasAttr<UuidAttr>())
1215+
if (RD->hasAttr<LTOVisibilityPublicAttr>() || RD->hasAttr<UuidAttr>() ||
1216+
RD->hasAttr<DLLExportAttr>() || RD->hasAttr<DLLImportAttr>())
12161217
return true;
12171218

12181219
if (!getCodeGenOpts().LTOVisibilityPublicStd)
@@ -1239,13 +1240,9 @@ bool CodeGenModule::HasHiddenLTOVisibility(const CXXRecordDecl *RD) {
12391240
if (!isExternallyVisible(LV.getLinkage()))
12401241
return true;
12411242

1242-
if (getTriple().isOSBinFormatCOFF()) {
1243-
if (RD->hasAttr<DLLExportAttr>() || RD->hasAttr<DLLImportAttr>())
1244-
return false;
1245-
} else {
1246-
if (LV.getVisibility() != HiddenVisibility)
1247-
return false;
1248-
}
1243+
if (!getTriple().isOSBinFormatCOFF() &&
1244+
LV.getVisibility() != HiddenVisibility)
1245+
return false;
12491246

12501247
return !AlwaysHasLTOVisibilityPublic(RD);
12511248
}

clang/test/CodeGenCXX/lto-visibility-inference.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ void f(C1 *c1, C2 *c2, C3 *c3, C4 *c4, C5 *c5, C6 *c6, std::C7 *c7,
7474
// MS: type.test{{.*}}!"?AUC2@@"
7575
c2->f();
7676
// ITANIUM: type.test{{.*}}!"_ZTS2C3"
77-
// MS: type.test{{.*}}!"?AUC3@@"
77+
// MS-NOT: type.test{{.*}}!"?AUC3@@"
7878
c3->f();
7979
// ITANIUM: type.test{{.*}}!"_ZTS2C4"
80-
// MS: type.test{{.*}}!"?AUC4@@"
80+
// MS-NOT: type.test{{.*}}!"?AUC4@@"
8181
c4->f();
8282
// ITANIUM-NOT: type.test{{.*}}!"_ZTS2C5"
8383
// MS-NOT: type.test{{.*}}!"?AUC5@@"

0 commit comments

Comments
 (0)