diff options
author | Teresa Johnson <tejohnson@google.com> | 2022-11-16 07:05:11 -0800 |
---|---|---|
committer | Teresa Johnson <tejohnson@google.com> | 2022-11-16 09:42:41 -0800 |
commit | 9eacbba290d87ba23796e3ba6a57138d99aca9e5 (patch) | |
tree | 94d26a2ffeea7e5c5b08d6f5003690db77fe18f3 /llvm/lib/LTO/LTO.cpp | |
parent | c2600244fc142c82c6d4cebf87d2143618b914f7 (diff) | |
download | llvm-9eacbba290d87ba23796e3ba6a57138d99aca9e5.zip llvm-9eacbba290d87ba23796e3ba6a57138d99aca9e5.tar.gz llvm-9eacbba290d87ba23796e3ba6a57138d99aca9e5.tar.bz2 |
Restore "[MemProf] ThinLTO summary support" with more fixes
This restores commit 98ed423361de2f9dc0113a31be2aa04524489ca9 and
follow on fix 00c22351ba697dbddb4b5bf0ad94e4bcea4b316b, which were
reverted in 5d938eb6f79b16f55266dd23d5df831f552ea082 due to an
MSVC bot failure. I've included a fix for that failure.
Differential Revision: https://reviews.llvm.org/D135714
Diffstat (limited to 'llvm/lib/LTO/LTO.cpp')
-rw-r--r-- | llvm/lib/LTO/LTO.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index dc28b68..9bfbabc 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/lib/LTO/LTO.cpp @@ -911,9 +911,25 @@ Error LTO::linkRegularLTO(RegularLTOState::AddedModule Mod, Error LTO::addThinLTO(BitcodeModule BM, ArrayRef<InputFile::Symbol> Syms, const SymbolResolution *&ResI, const SymbolResolution *ResE) { + const SymbolResolution *ResITmp = ResI; + for (const InputFile::Symbol &Sym : Syms) { + assert(ResITmp != ResE); + SymbolResolution Res = *ResITmp++; + + if (!Sym.getIRName().empty()) { + auto GUID = GlobalValue::getGUID(GlobalValue::getGlobalIdentifier( + Sym.getIRName(), GlobalValue::ExternalLinkage, "")); + if (Res.Prevailing) + ThinLTO.PrevailingModuleForGUID[GUID] = BM.getModuleIdentifier(); + } + } + if (Error Err = BM.readSummary(ThinLTO.CombinedIndex, BM.getModuleIdentifier(), - ThinLTO.ModuleMap.size())) + ThinLTO.ModuleMap.size(), [&](GlobalValue::GUID GUID) { + return ThinLTO.PrevailingModuleForGUID[GUID] == + BM.getModuleIdentifier(); + })) return Err; for (const InputFile::Symbol &Sym : Syms) { @@ -924,7 +940,8 @@ Error LTO::addThinLTO(BitcodeModule BM, ArrayRef<InputFile::Symbol> Syms, auto GUID = GlobalValue::getGUID(GlobalValue::getGlobalIdentifier( Sym.getIRName(), GlobalValue::ExternalLinkage, "")); if (Res.Prevailing) { - ThinLTO.PrevailingModuleForGUID[GUID] = BM.getModuleIdentifier(); + assert(ThinLTO.PrevailingModuleForGUID[GUID] == + BM.getModuleIdentifier()); // For linker redefined symbols (via --wrap or --defsym) we want to // switch the linkage to `weak` to prevent IPOs from happening. @@ -1454,6 +1471,7 @@ ThinBackend lto::createWriteIndexesThinBackend( Error LTO::runThinLTO(AddStreamFn AddStream, FileCache Cache, const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols) { + ThinLTO.CombinedIndex.releaseTemporaryMemory(); timeTraceProfilerBegin("ThinLink", StringRef("")); auto TimeTraceScopeExit = llvm::make_scope_exit([]() { if (llvm::timeTraceProfilerEnabled()) |