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.
Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D127876 Files: clang/lib/CodeGen/CGClass.cpp clang/lib/CodeGen/CGVTables.cpp clang/lib/CodeGen/CodeGenModule.h clang/lib/CodeGen/ItaniumCXXABI.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,16 +74,16 @@ // 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: type.test{{.*}}!"_ZTS2C5" - // MS: type.test{{.*}}!"?AUC5@@" + // ITANIUM-NOT: type.test{{.*}}!"_ZTS2C5" + // MS-NOT: type.test{{.*}}!"?AUC5@@" c5->f(); - // ITANIUM: type.test{{.*}}!"_ZTS2C6" - // MS: type.test{{.*}}!"?AUC6@@" + // ITANIUM-NOT: type.test{{.*}}!"_ZTS2C6" + // MS-NOT: type.test{{.*}}!"?AUC6@@" c6->f(); // ITANIUM: type.test{{.*}}!"_ZTSSt2C7" // MS-STD: type.test{{.*}}!"?AUC7@std@@" Index: clang/lib/CodeGen/ItaniumCXXABI.cpp =================================================================== --- clang/lib/CodeGen/ItaniumCXXABI.cpp +++ clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -669,7 +669,7 @@ bool ShouldEmitWPDInfo = CGM.getCodeGenOpts().WholeProgramVTables && // Don't insert type tests if we are forcing public std visibility. - !CGM.HasLTOVisibilityPublicStd(RD); + !CGM.AlwaysHasLTOVisibilityPublic(RD); llvm::Value *VirtualFn = nullptr; { Index: clang/lib/CodeGen/CodeGenModule.h =================================================================== --- clang/lib/CodeGen/CodeGenModule.h +++ clang/lib/CodeGen/CodeGenModule.h @@ -1385,7 +1385,7 @@ /// Returns whether the given record has public std LTO visibility /// and therefore may not participate in (single-module) CFI and whole-program /// vtable optimization. - bool HasLTOVisibilityPublicStd(const CXXRecordDecl *RD); + bool AlwaysHasLTOVisibilityPublic(const CXXRecordDecl *RD); /// Returns the vcall visibility of the given type. This is the scope in which /// a virtual function call could be made which ends up being dispatched to a Index: clang/lib/CodeGen/CGVTables.cpp =================================================================== --- clang/lib/CodeGen/CGVTables.cpp +++ clang/lib/CodeGen/CGVTables.cpp @@ -1175,7 +1175,15 @@ DeferredVTables.clear(); } -bool CodeGenModule::HasLTOVisibilityPublicStd(const CXXRecordDecl *RD) { +bool CodeGenModule::AlwaysHasLTOVisibilityPublic(const CXXRecordDecl *RD) { + if (RD->hasAttr<LTOVisibilityPublicAttr>() || RD->hasAttr<UuidAttr>()) + return true; + + if (getTriple().isOSBinFormatCOFF()) { + if (RD->hasAttr<DLLExportAttr>() || RD->hasAttr<DLLImportAttr>()) + return true; + } + if (!getCodeGenOpts().LTOVisibilityPublicStd) return false; @@ -1200,18 +1208,12 @@ if (!isExternallyVisible(LV.getLinkage())) return true; - if (RD->hasAttr<LTOVisibilityPublicAttr>() || RD->hasAttr<UuidAttr>()) - return false; - - if (getTriple().isOSBinFormatCOFF()) { - if (RD->hasAttr<DLLExportAttr>() || RD->hasAttr<DLLImportAttr>()) - return false; - } else { + if (!getTriple().isOSBinFormatCOFF()) { if (LV.getVisibility() != HiddenVisibility) return false; } - return !HasLTOVisibilityPublicStd(RD); + return !AlwaysHasLTOVisibilityPublic(RD); } llvm::GlobalObject::VCallVisibility CodeGenModule::GetVCallVisibilityLevel( Index: clang/lib/CodeGen/CGClass.cpp =================================================================== --- clang/lib/CodeGen/CGClass.cpp +++ clang/lib/CodeGen/CGClass.cpp @@ -2697,7 +2697,7 @@ else if (CGM.getCodeGenOpts().WholeProgramVTables && // Don't insert type test assumes if we are forcing public std // visibility. - !CGM.HasLTOVisibilityPublicStd(RD)) { + !CGM.AlwaysHasLTOVisibilityPublic(RD)) { llvm::Metadata *MD = CGM.CreateMetadataIdentifierForType(QualType(RD->getTypeForDecl(), 0)); llvm::Value *TypeId =
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits