@@ -1134,8 +1134,8 @@ struct LLVMRustThinLTOModule {
11341134
11351135// This is copied from `lib/LTO/ThinLTOCodeGenerator.cpp`, not sure what it
11361136// does.
1137- static const GlobalValueSummary *
1138- getFirstDefinitionForLinker ( const GlobalValueSummaryList & GVSummaryList) {
1137+ static const GlobalValueSummary *getFirstDefinitionForLinker (
1138+ ArrayRef<std::unique_ptr<GlobalValueSummary>> GVSummaryList) {
11391139 auto StrongDefForLinker = llvm::find_if (
11401140 GVSummaryList, [](const std::unique_ptr<GlobalValueSummary> &Summary) {
11411141 auto Linkage = Summary->linkage ();
@@ -1213,9 +1213,13 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules, size_t num_modules,
12131213 // being lifted from `lib/LTO/LTO.cpp` as well
12141214 DenseMap<GlobalValue::GUID, const GlobalValueSummary *> PrevailingCopy;
12151215 for (auto &I : Ret->Index ) {
1216- if (I.second .SummaryList .size () > 1 )
1217- PrevailingCopy[I.first ] =
1218- getFirstDefinitionForLinker (I.second .SummaryList );
1216+ #if LLVM_VERSION_GE(22, 0)
1217+ const auto &SummaryList = I.second .getSummaryList ();
1218+ #else
1219+ const auto &SummaryList = I.second .SummaryList ;
1220+ #endif
1221+ if (SummaryList.size () > 1 )
1222+ PrevailingCopy[I.first ] = getFirstDefinitionForLinker (SummaryList);
12191223 }
12201224 auto isPrevailing = [&](GlobalValue::GUID GUID, const GlobalValueSummary *S) {
12211225 const auto &Prevailing = PrevailingCopy.find (GUID);
@@ -1246,7 +1250,12 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules, size_t num_modules,
12461250 // linkage will stay as external, and internal will stay as internal.
12471251 std::set<GlobalValue::GUID> ExportedGUIDs;
12481252 for (auto &List : Ret->Index ) {
1249- for (auto &GVS : List.second .SummaryList ) {
1253+ #if LLVM_VERSION_GE(22, 0)
1254+ const auto &SummaryList = List.second .getSummaryList ();
1255+ #else
1256+ const auto &SummaryList = List.second .SummaryList ;
1257+ #endif
1258+ for (auto &GVS : SummaryList) {
12501259 if (GlobalValue::isLocalLinkage (GVS->linkage ()))
12511260 continue ;
12521261 auto GUID = GVS->getOriginalName ();
0 commit comments