Skip to content

Commit

Permalink
[LLD][COFF] Add support for --time-trace (#68236)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
aganea authored Oct 6, 2023
1 parent 84cbd9f commit 356139b
Show file tree
Hide file tree
Showing 25 changed files with 458 additions and 226 deletions.
2 changes: 2 additions & 0 deletions lld/COFF/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ struct Configuration {
uint32_t minorSubsystemVersion = 0;
uint32_t timestamp = 0;
uint32_t functionPadMin = 0;
uint32_t timeTraceGranularity = 0;
bool dynamicBase = true;
bool allowBind = true;
bool cetCompat = false;
Expand All @@ -309,6 +310,7 @@ struct Configuration {
bool swaprunNet = false;
bool thinLTOEmitImportsFiles;
bool thinLTOIndexOnly;
bool timeTraceEnabled = false;
bool autoImport = false;
bool pseudoRelocs = false;
bool stdcallFixup = false;
Expand Down
3 changes: 3 additions & 0 deletions lld/COFF/DebugTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/Parallel.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/TimeProfiler.h"

using namespace llvm;
using namespace llvm::codeview;
Expand Down Expand Up @@ -1068,13 +1069,15 @@ TypeMerger::~TypeMerger() = default;
void TypeMerger::mergeTypesWithGHash() {
// Load ghashes. Do type servers and PCH objects first.
{
llvm::TimeTraceScope timeScope("Load GHASHes");
ScopedTimer t1(ctx.loadGHashTimer);
parallelForEach(dependencySources,
[&](TpiSource *source) { source->loadGHashes(); });
parallelForEach(objectSources,
[&](TpiSource *source) { source->loadGHashes(); });
}

llvm::TimeTraceScope timeScope("Merge types (GHASH)");
ScopedTimer t2(ctx.mergeGHashTimer);
GHashState ghashState;

Expand Down
Loading

0 comments on commit 356139b

Please sign in to comment.