Skip to content
Merged
Changes from all commits
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
21 changes: 15 additions & 6 deletions compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1141,8 +1141,8 @@ struct LLVMRustThinLTOModule {

// This is copied from `lib/LTO/ThinLTOCodeGenerator.cpp`, not sure what it
// does.
static const GlobalValueSummary *
getFirstDefinitionForLinker(const GlobalValueSummaryList &GVSummaryList) {
static const GlobalValueSummary *getFirstDefinitionForLinker(
ArrayRef<std::unique_ptr<GlobalValueSummary>> GVSummaryList) {
auto StrongDefForLinker = llvm::find_if(
GVSummaryList, [](const std::unique_ptr<GlobalValueSummary> &Summary) {
auto Linkage = Summary->linkage();
Expand Down Expand Up @@ -1220,9 +1220,13 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules, size_t num_modules,
// being lifted from `lib/LTO/LTO.cpp` as well
DenseMap<GlobalValue::GUID, const GlobalValueSummary *> PrevailingCopy;
for (auto &I : Ret->Index) {
if (I.second.SummaryList.size() > 1)
PrevailingCopy[I.first] =
getFirstDefinitionForLinker(I.second.SummaryList);
#if LLVM_VERSION_GE(22, 0)
const auto &SummaryList = I.second.getSummaryList();
#else
const auto &SummaryList = I.second.SummaryList;
#endif
if (SummaryList.size() > 1)
PrevailingCopy[I.first] = getFirstDefinitionForLinker(SummaryList);
}
auto isPrevailing = [&](GlobalValue::GUID GUID, const GlobalValueSummary *S) {
const auto &Prevailing = PrevailingCopy.find(GUID);
Expand Down Expand Up @@ -1253,7 +1257,12 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules, size_t num_modules,
// linkage will stay as external, and internal will stay as internal.
std::set<GlobalValue::GUID> ExportedGUIDs;
for (auto &List : Ret->Index) {
for (auto &GVS : List.second.SummaryList) {
#if LLVM_VERSION_GE(22, 0)
const auto &SummaryList = List.second.getSummaryList();
#else
const auto &SummaryList = List.second.SummaryList;
#endif
for (auto &GVS : SummaryList) {
if (GlobalValue::isLocalLinkage(GVS->linkage()))
continue;
auto GUID = GVS->getOriginalName();
Expand Down
Loading