Skip to content

Commit 356139b

Browse files
authored
[LLD][COFF] Add support for --time-trace (#68236)
This adds support for generating Chrome-tracing .json profile traces in the LLD COFF driver. Also add the necessary time scopes, so that the profile trace shows in great detail which tasks are executed. As an example, this is what we see when linking a Unreal Engine executable: ![image](https://github.com/llvm/llvm-project/assets/37383324/b2e26eb4-9d37-4cf9-b002-48b604e7dcb7)
1 parent 84cbd9f commit 356139b

25 files changed

+458
-226
lines changed

lld/COFF/Config.h

+2
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ struct Configuration {
286286
uint32_t minorSubsystemVersion = 0;
287287
uint32_t timestamp = 0;
288288
uint32_t functionPadMin = 0;
289+
uint32_t timeTraceGranularity = 0;
289290
bool dynamicBase = true;
290291
bool allowBind = true;
291292
bool cetCompat = false;
@@ -309,6 +310,7 @@ struct Configuration {
309310
bool swaprunNet = false;
310311
bool thinLTOEmitImportsFiles;
311312
bool thinLTOIndexOnly;
313+
bool timeTraceEnabled = false;
312314
bool autoImport = false;
313315
bool pseudoRelocs = false;
314316
bool stdcallFixup = false;

lld/COFF/DebugTypes.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "llvm/Support/FormatVariadic.h"
3030
#include "llvm/Support/Parallel.h"
3131
#include "llvm/Support/Path.h"
32+
#include "llvm/Support/TimeProfiler.h"
3233

3334
using namespace llvm;
3435
using namespace llvm::codeview;
@@ -1068,13 +1069,15 @@ TypeMerger::~TypeMerger() = default;
10681069
void TypeMerger::mergeTypesWithGHash() {
10691070
// Load ghashes. Do type servers and PCH objects first.
10701071
{
1072+
llvm::TimeTraceScope timeScope("Load GHASHes");
10711073
ScopedTimer t1(ctx.loadGHashTimer);
10721074
parallelForEach(dependencySources,
10731075
[&](TpiSource *source) { source->loadGHashes(); });
10741076
parallelForEach(objectSources,
10751077
[&](TpiSource *source) { source->loadGHashes(); });
10761078
}
10771079

1080+
llvm::TimeTraceScope timeScope("Merge types (GHASH)");
10781081
ScopedTimer t2(ctx.mergeGHashTimer);
10791082
GHashState ghashState;
10801083

0 commit comments

Comments
 (0)