@@ -902,14 +902,19 @@ addPreservedGUID(const ModuleSummaryIndex &Index,
902902
903903 GlobalValueSummary *GVSummary = Summary.get ();
904904 if (isa<FunctionSummary>(GVSummary)) {
905- FunctionSummary *FS = cast<FunctionSummary>(GVSummary);
905+ auto *FS = cast<FunctionSummary>(GVSummary);
906906 for (auto &Call: FS->calls ()) {
907907 addPreservedGUID (Index, Preserved, Call.first .getGUID ());
908908 }
909909 for (auto &GUID: FS->type_tests ()) {
910910 addPreservedGUID (Index, Preserved, GUID);
911911 }
912912 }
913+ if (isa<AliasSummary>(GVSummary)) {
914+ auto *AS = cast<AliasSummary>(GVSummary);
915+ auto GUID = AS->getAliasee ().getOriginalName ();
916+ addPreservedGUID (Index, Preserved, GUID);
917+ }
913918 }
914919#else
915920 auto SummaryList = Index.findGlobalValueSummaryList (GUID);
@@ -997,6 +1002,15 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
9971002 // combined index
9981003 //
9991004 // This is copied from `lib/LTO/ThinLTOCodeGenerator.cpp`
1005+ #if LLVM_VERSION_GE(5, 0)
1006+ computeDeadSymbols (Ret->Index , Ret->GUIDPreservedSymbols );
1007+ ComputeCrossModuleImport (
1008+ Ret->Index ,
1009+ Ret->ModuleToDefinedGVSummaries ,
1010+ Ret->ImportLists ,
1011+ Ret->ExportLists
1012+ );
1013+ #else
10001014 auto DeadSymbols = computeDeadSymbols (Ret->Index , Ret->GUIDPreservedSymbols );
10011015 ComputeCrossModuleImport (
10021016 Ret->Index ,
@@ -1005,6 +1019,7 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
10051019 Ret->ExportLists ,
10061020 &DeadSymbols
10071021 );
1022+ #endif
10081023
10091024 // Resolve LinkOnce/Weak symbols, this has to be computed early be cause it
10101025 // impacts the caching.
0 commit comments