-
Notifications
You must be signed in to change notification settings - Fork 15k
[WPD] Reduce ThinLTO link time by avoiding unnecessary summary analysis #164046
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1161,14 +1161,10 @@ bool DevirtIndex::tryFindVirtualCallTargets( | |
| // and therefore the same GUID. This can happen if there isn't enough | ||
| // distinguishing path when compiling the source file. In that case we | ||
| // conservatively return false early. | ||
| if (P.VTableVI.hasLocal() && P.VTableVI.getSummaryList().size() > 1) | ||
| return false; | ||
| const GlobalVarSummary *VS = nullptr; | ||
| bool LocalFound = false; | ||
| for (const auto &S : P.VTableVI.getSummaryList()) { | ||
| if (GlobalValue::isLocalLinkage(S->linkage())) { | ||
| if (LocalFound) | ||
| return false; | ||
| LocalFound = true; | ||
| } | ||
| auto *CurVS = cast<GlobalVarSummary>(S->getBaseObject()); | ||
| if (!CurVS->vTableFuncs().empty() || | ||
| // Previously clang did not attach the necessary type metadata to | ||
|
|
@@ -1184,6 +1180,7 @@ bool DevirtIndex::tryFindVirtualCallTargets( | |
| // with public LTO visibility. | ||
| if (VS->getVCallVisibility() == GlobalObject::VCallVisibilityPublic) | ||
| return false; | ||
| break; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before this change, loop iterates all After this change, the visibility check happens on the first There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, per https://clang.llvm.org/docs/LTOVisibility.html: "A class’s LTO visibility is treated as an ODR-relevant property of its definition, so it must be consistent between translation units." There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the pointer. The optimization on finding representative vtable value summary LGTM. |
||
| } | ||
| } | ||
| // There will be no VS if all copies are available_externally having no | ||
|
|
@@ -2591,6 +2588,11 @@ void DevirtIndex::run() { | |
| if (ExportSummary.typeIdCompatibleVtableMap().empty()) | ||
| return; | ||
|
|
||
| // Assert that we haven't made any changes that would affect the hasLocal() | ||
| // flag on the GUID summary info. | ||
| assert(!ExportSummary.withInternalizeAndPromote() && | ||
| "Expect index-based WPD to run before internalization and promotion"); | ||
|
|
||
| DenseMap<GlobalValue::GUID, std::vector<StringRef>> NameByGUID; | ||
| for (const auto &P : ExportSummary.typeIdCompatibleVtableMap()) { | ||
| NameByGUID[GlobalValue::getGUIDAssumingExternalLinkage(P.first)].push_back( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit pick on the compile error: I think
ValueInfostruct needs to have a method to exposehasLocalstate, something likeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have that locally, but the branch seems hopelessly messed up right now despite force pushing etc. I may have to close this PR and start a new one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok I think my latest force push added them