Skip to content

Commit f5b8a31

Browse files
committed
[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
1 parent 871ea69 commit f5b8a31

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

llvm/lib/LTO/LTO.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "llvm/LTO/LTO.h"
14+
#include "llvm/ADT/ScopeExit.h"
1415
#include "llvm/ADT/SmallSet.h"
1516
#include "llvm/ADT/Statistic.h"
1617
#include "llvm/ADT/StringExtras.h"
@@ -1398,6 +1399,11 @@ ThinBackend lto::createWriteIndexesThinBackend(
13981399

13991400
Error LTO::runThinLTO(AddStreamFn AddStream, NativeObjectCache Cache,
14001401
const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols) {
1402+
timeTraceProfilerBegin("ThinLink", StringRef(""));
1403+
auto TimeTraceScopeExit = llvm::make_scope_exit([]() {
1404+
if (llvm::timeTraceProfilerEnabled())
1405+
llvm::timeTraceProfilerEnd();
1406+
});
14011407
if (ThinLTO.ModuleMap.empty())
14021408
return Error::success();
14031409

@@ -1512,6 +1518,11 @@ Error LTO::runThinLTO(AddStreamFn AddStream, NativeObjectCache Cache,
15121518

15131519
generateParamAccessSummary(ThinLTO.CombinedIndex);
15141520

1521+
if (llvm::timeTraceProfilerEnabled())
1522+
llvm::timeTraceProfilerEnd();
1523+
1524+
TimeTraceScopeExit.release();
1525+
15151526
std::unique_ptr<ThinBackendProc> BackendProc =
15161527
ThinLTO.Backend(Conf, ThinLTO.CombinedIndex, ModuleToDefinedGVSummaries,
15171528
AddStream, Cache);

llvm/lib/LTO/ThinLTOCodeGenerator.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "llvm/LTO/legacy/ThinLTOCodeGenerator.h"
1515
#include "llvm/Support/CommandLine.h"
1616

17+
#include "llvm/ADT/ScopeExit.h"
1718
#include "llvm/ADT/Statistic.h"
1819
#include "llvm/ADT/StringExtras.h"
1920
#include "llvm/Analysis/AliasAnalysis.h"
@@ -996,6 +997,11 @@ ThinLTOCodeGenerator::writeGeneratedObject(int count, StringRef CacheEntryPath,
996997

997998
// Main entry point for the ThinLTO processing
998999
void ThinLTOCodeGenerator::run() {
1000+
timeTraceProfilerBegin("ThinLink", StringRef(""));
1001+
auto TimeTraceScopeExit = llvm::make_scope_exit([]() {
1002+
if (llvm::timeTraceProfilerEnabled())
1003+
llvm::timeTraceProfilerEnd();
1004+
});
9991005
// Prepare the resulting object vector
10001006
assert(ProducedBinaries.empty() && "The generator should not be reused");
10011007
if (SavedObjectsDirectoryPath.empty())
@@ -1141,6 +1147,11 @@ void ThinLTOCodeGenerator::run() {
11411147
ModulesVec.push_back(&Mod->getSingleBitcodeModule());
11421148
std::vector<int> ModulesOrdering = lto::generateModulesOrdering(ModulesVec);
11431149

1150+
if (llvm::timeTraceProfilerEnabled())
1151+
llvm::timeTraceProfilerEnd();
1152+
1153+
TimeTraceScopeExit.release();
1154+
11441155
// Parallel optimizer + codegen
11451156
{
11461157
ThreadPool Pool(heavyweight_hardware_concurrency(ThreadCount));

0 commit comments

Comments
 (0)