From fc7c4be59a276584b9ed0a562e677b3826170088 Mon Sep 17 00:00:00 2001 From: Arthur Eubanks Date: Tue, 21 Oct 2025 20:58:27 +0000 Subject: [PATCH 1/4] PassWrapper: Access GlobalValueSummaryInfo::SummaryList via getter for LLVM 22+ https://github.com/llvm/llvm-project/pull/164355 makes SummaryList private and provides a getter method. @rustbot label llvm-main --- compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index 8d9c4b48b5c4a..b571a060594c6 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -1220,9 +1220,14 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules, size_t num_modules, // being lifted from `lib/LTO/LTO.cpp` as well DenseMap PrevailingCopy; for (auto &I : Ret->Index) { - if (I.second.SummaryList.size() > 1) +#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(I.second.SummaryList); + getFirstDefinitionForLinker(SummaryList); } auto isPrevailing = [&](GlobalValue::GUID GUID, const GlobalValueSummary *S) { const auto &Prevailing = PrevailingCopy.find(GUID); @@ -1253,7 +1258,12 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules, size_t num_modules, // linkage will stay as external, and internal will stay as internal. std::set 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(); From f38839a87488db4b50490e7dd8a2c7ad7d87394d Mon Sep 17 00:00:00 2001 From: Arthur Eubanks Date: Tue, 21 Oct 2025 21:35:23 +0000 Subject: [PATCH 2/4] format --- compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index b571a060594c6..d6ac51123550a 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -1226,8 +1226,7 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules, size_t num_modules, const auto &SummaryList = I.second.SummaryList; #endif if (SummaryList.size() > 1) - PrevailingCopy[I.first] = - getFirstDefinitionForLinker(SummaryList); + PrevailingCopy[I.first] = getFirstDefinitionForLinker(SummaryList); } auto isPrevailing = [&](GlobalValue::GUID GUID, const GlobalValueSummary *S) { const auto &Prevailing = PrevailingCopy.find(GUID); From 875cc36b17b45193fed023ce21fc7ec99535f105 Mon Sep 17 00:00:00 2001 From: Arthur Eubanks Date: Tue, 21 Oct 2025 22:21:50 +0000 Subject: [PATCH 3/4] actually compile --- compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index d6ac51123550a..bcd19d9fc3a17 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -1142,7 +1142,7 @@ struct LLVMRustThinLTOModule { // This is copied from `lib/LTO/ThinLTOCodeGenerator.cpp`, not sure what it // does. static const GlobalValueSummary * -getFirstDefinitionForLinker(const GlobalValueSummaryList &GVSummaryList) { +getFirstDefinitionForLinker(ArrayRef> GVSummaryList) { auto StrongDefForLinker = llvm::find_if( GVSummaryList, [](const std::unique_ptr &Summary) { auto Linkage = Summary->linkage(); From 1e8054669cba8341e3725dde1ed260ec82b3fdc0 Mon Sep 17 00:00:00 2001 From: Arthur Eubanks Date: Tue, 21 Oct 2025 22:29:48 +0000 Subject: [PATCH 4/4] format --- compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp index bcd19d9fc3a17..239d604f57c05 100644 --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp @@ -1141,8 +1141,8 @@ struct LLVMRustThinLTOModule { // This is copied from `lib/LTO/ThinLTOCodeGenerator.cpp`, not sure what it // does. -static const GlobalValueSummary * -getFirstDefinitionForLinker(ArrayRef> GVSummaryList) { +static const GlobalValueSummary *getFirstDefinitionForLinker( + ArrayRef> GVSummaryList) { auto StrongDefForLinker = llvm::find_if( GVSummaryList, [](const std::unique_ptr &Summary) { auto Linkage = Summary->linkage();