Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions llvm/lib/LTO/LTO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,16 +471,14 @@ static void thinLTOInternalizeAndPromoteGUID(
ValueInfo VI, function_ref<bool(StringRef, ValueInfo)> isExported,
function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
isPrevailing) {
auto ExternallyVisibleCopies =
llvm::count_if(VI.getSummaryList(),
[](const std::unique_ptr<GlobalValueSummary> &Summary) {
return !GlobalValue::isLocalLinkage(Summary->linkage());
});

// Before performing index-based internalization and promotion for this GUID,
// the local flag should be consistent with the summary list linkage types.
VI.verifyLocal();

bool SingleExternallyVisibleCopy =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional suggestion: make this const bool so it's clearer it doesn't get modified later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

VI.getSummaryList().size() == 1 &&
!GlobalValue::isLocalLinkage(VI.getSummaryList().front()->linkage());

for (auto &S : VI.getSummaryList()) {
// First see if we need to promote an internal value because it is not
// exported.
Expand Down Expand Up @@ -543,7 +541,9 @@ static void thinLTOInternalizeAndPromoteGUID(
GlobalValue::isExternalWeakLinkage(S->linkage()))
continue;

if (isPrevailing(VI.getGUID(), S.get()) && ExternallyVisibleCopies == 1)
// We may have a single summary copy that is externally visible but not
// prevailing if the prevailing copy is in a native object.
if (SingleExternallyVisibleCopy && isPrevailing(VI.getGUID(), S.get()))
S->setLinkage(GlobalValue::InternalLinkage);
}
}
Expand Down