From 96cb97c4533a0a02c2d62ffb1121cd275aa43dd5 Mon Sep 17 00:00:00 2001 From: Teresa Johnson Date: Thu, 23 Sep 2021 17:22:54 -0700 Subject: [ThinLTO] Update combined index for SamplePGO indirect calls to locals In ThinLTO for locals we normally compute the GUID from the name after prepending the source path to get a unique global id. SamplePGO indirect call profiles contain the target GUID without this uniquification, however (unless compiling with -funique-internal-linkage-names). In order to correctly handle the call edges added to the combined index for these indirect calls, during importing and bitcode writing we consult a map of original to full GUID to identify the actual callee. However, for a large application this was consuming a lot of compile time as we need to do this repeatedly (especially during importing where we may traverse call edges multiple times). To fix this implement a suggestion in one of the FIXME comments, and actually modify the call edges during a single traversal after the index is built to perform the fixups once. I combined this fixup with the dead code analysis performed on the index in order to avoid adding an additional walk of the index. The dead code analysis is the first analysis performed on the index. This reduced the time required for a large thin link with SamplePGO by about 20%. No new test added, but I confirmed that there are existing tests that will fail when no fixup is performed. Differential Revision: https://reviews.llvm.org/D110374 --- llvm/lib/IR/ModuleSummaryIndex.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'llvm/lib/IR/ModuleSummaryIndex.cpp') diff --git a/llvm/lib/IR/ModuleSummaryIndex.cpp b/llvm/lib/IR/ModuleSummaryIndex.cpp index f4ac6ca..b003ebc 100644 --- a/llvm/lib/IR/ModuleSummaryIndex.cpp +++ b/llvm/lib/IR/ModuleSummaryIndex.cpp @@ -251,12 +251,13 @@ void ModuleSummaryIndex::propagateAttributes( bool IsDSOLocal = true; for (auto &S : P.second.SummaryList) { if (!isGlobalValueLive(S.get())) { - // computeDeadSymbols should have marked all copies live. Note that - // it is possible that there is a GUID collision between internal - // symbols with the same name in different files of the same name but - // not enough distinguishing path. Because computeDeadSymbols should - // conservatively mark all copies live we can assert here that all are - // dead if any copy is dead. + // computeDeadSymbolsAndUpdateIndirectCalls should have marked all + // copies live. Note that it is possible that there is a GUID collision + // between internal symbols with the same name in different files of the + // same name but not enough distinguishing path. Because + // computeDeadSymbolsAndUpdateIndirectCalls should conservatively mark + // all copies live we can assert here that all are dead if any copy is + // dead. assert(llvm::none_of( P.second.SummaryList, [&](const std::unique_ptr &Summary) { -- cgit v1.1