[ThinLTO] Add TimeTrace for Thinlink step

Results from Clang self-build:

{F17435948}

Testing:
ninja check-all

Reviewed By: anton-afanasyev

Differential Revision: https://reviews.llvm.org/D104428
This commit is contained in:
modimo 2021-08-03 13:18:57 -07:00
parent 871ea69803
commit f5b8a3125a
2 changed files with 22 additions and 0 deletions

View File

@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/LTO/LTO.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
@ -1398,6 +1399,11 @@ ThinBackend lto::createWriteIndexesThinBackend(
Error LTO::runThinLTO(AddStreamFn AddStream, NativeObjectCache Cache,
const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols) {
timeTraceProfilerBegin("ThinLink", StringRef(""));
auto TimeTraceScopeExit = llvm::make_scope_exit([]() {
if (llvm::timeTraceProfilerEnabled())
llvm::timeTraceProfilerEnd();
});
if (ThinLTO.ModuleMap.empty())
return Error::success();
@ -1512,6 +1518,11 @@ Error LTO::runThinLTO(AddStreamFn AddStream, NativeObjectCache Cache,
generateParamAccessSummary(ThinLTO.CombinedIndex);
if (llvm::timeTraceProfilerEnabled())
llvm::timeTraceProfilerEnd();
TimeTraceScopeExit.release();
std::unique_ptr<ThinBackendProc> BackendProc =
ThinLTO.Backend(Conf, ThinLTO.CombinedIndex, ModuleToDefinedGVSummaries,
AddStream, Cache);

View File

@ -14,6 +14,7 @@
#include "llvm/LTO/legacy/ThinLTOCodeGenerator.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Analysis/AliasAnalysis.h"
@ -996,6 +997,11 @@ ThinLTOCodeGenerator::writeGeneratedObject(int count, StringRef CacheEntryPath,
// Main entry point for the ThinLTO processing
void ThinLTOCodeGenerator::run() {
timeTraceProfilerBegin("ThinLink", StringRef(""));
auto TimeTraceScopeExit = llvm::make_scope_exit([]() {
if (llvm::timeTraceProfilerEnabled())
llvm::timeTraceProfilerEnd();
});
// Prepare the resulting object vector
assert(ProducedBinaries.empty() && "The generator should not be reused");
if (SavedObjectsDirectoryPath.empty())
@ -1141,6 +1147,11 @@ void ThinLTOCodeGenerator::run() {
ModulesVec.push_back(&Mod->getSingleBitcodeModule());
std::vector<int> ModulesOrdering = lto::generateModulesOrdering(ModulesVec);
if (llvm::timeTraceProfilerEnabled())
llvm::timeTraceProfilerEnd();
TimeTraceScopeExit.release();
// Parallel optimizer + codegen
{
ThreadPool Pool(heavyweight_hardware_concurrency(ThreadCount));