diff options
author | Alexandre Ganea <aganea@havenstudios.com> | 2025-09-05 15:28:19 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-09-05 15:28:19 -0400 |
commit | 5cda2424c8f9a0ecac2cc9f6c7f41883a16bea12 (patch) | |
tree | 81c45e1bb024b48f3089d8c5e4764ddf34bc662d /llvm/lib/LTO/LTOBackend.cpp | |
parent | a549e73cad60336d8e9c0622ae7ad86aa65ef4ce (diff) | |
download | llvm-5cda2424c8f9a0ecac2cc9f6c7f41883a16bea12.zip llvm-5cda2424c8f9a0ecac2cc9f6c7f41883a16bea12.tar.gz llvm-5cda2424c8f9a0ecac2cc9f6c7f41883a16bea12.tar.bz2 |
[LLD][COFF] Add more `--time-trace` tags for ThinLTO linking (#156471)
In order to better see what's going on during ThinLTO linking, this PR
adds more profile tags when using `--time-trace` on a `lld-link.exe`
invocation.
After PR, linking `clang.exe`:
<img width="3839" height="2026" alt="Capture d’écran 2025-09-02 082021"
src="https://github.com/user-attachments/assets/bf0c85ba-2f85-4bbf-a5c1-800039b56910"
/>
Linking a custom (Unreal Engine game) binary gives a completly
different picture, probably because of using Unity files, and the sheer
amount of input files (here, providing over 60 GB of .OBJs/.LIBs).
<img width="1940" height="1008" alt="Capture d’écran 2025-09-02 102048"
src="https://github.com/user-attachments/assets/60b28630-7995-45ce-9e8c-13f3cb5312e0"
/>
Diffstat (limited to 'llvm/lib/LTO/LTOBackend.cpp')
-rw-r--r-- | llvm/lib/LTO/LTOBackend.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp index 5e8cd12..ce42fc5 100644 --- a/llvm/lib/LTO/LTOBackend.cpp +++ b/llvm/lib/LTO/LTOBackend.cpp @@ -366,6 +366,7 @@ bool lto::opt(const Config &Conf, TargetMachine *TM, unsigned Task, Module &Mod, bool IsThinLTO, ModuleSummaryIndex *ExportSummary, const ModuleSummaryIndex *ImportSummary, const std::vector<uint8_t> &CmdArgs) { + llvm::TimeTraceScope timeScope("opt"); if (EmbedBitcode == LTOBitcodeEmbedding::EmbedPostMergePreOptimized) { // FIXME: the motivation for capturing post-merge bitcode and command line // is replicating the compilation environment from bitcode, without needing @@ -399,6 +400,7 @@ bool lto::opt(const Config &Conf, TargetMachine *TM, unsigned Task, Module &Mod, static void codegen(const Config &Conf, TargetMachine *TM, AddStreamFn AddStream, unsigned Task, Module &Mod, const ModuleSummaryIndex &CombinedIndex) { + llvm::TimeTraceScope timeScope("codegen"); if (Conf.PreCodeGenModuleHook && !Conf.PreCodeGenModuleHook(Task, Mod)) return; @@ -552,6 +554,7 @@ Error lto::finalizeOptimizationRemarks( Error lto::backend(const Config &C, AddStreamFn AddStream, unsigned ParallelCodeGenParallelismLevel, Module &Mod, ModuleSummaryIndex &CombinedIndex) { + llvm::TimeTraceScope timeScope("LTO backend"); Expected<const Target *> TOrErr = initAndLookupTarget(C, Mod); if (!TOrErr) return TOrErr.takeError(); @@ -577,6 +580,7 @@ Error lto::backend(const Config &C, AddStreamFn AddStream, static void dropDeadSymbols(Module &Mod, const GVSummaryMapTy &DefinedGlobals, const ModuleSummaryIndex &Index) { + llvm::TimeTraceScope timeScope("Drop dead symbols"); std::vector<GlobalValue*> DeadGVs; for (auto &GV : Mod.global_values()) if (GlobalValueSummary *GVS = DefinedGlobals.lookup(GV.getGUID())) @@ -603,6 +607,7 @@ Error lto::thinBackend(const Config &Conf, unsigned Task, AddStreamFn AddStream, MapVector<StringRef, BitcodeModule> *ModuleMap, bool CodeGenOnly, AddStreamFn IRAddStream, const std::vector<uint8_t> &CmdArgs) { + llvm::TimeTraceScope timeScope("Thin backend", Mod.getModuleIdentifier()); Expected<const Target *> TOrErr = initAndLookupTarget(Conf, Mod); if (!TOrErr) return TOrErr.takeError(); @@ -679,6 +684,7 @@ Error lto::thinBackend(const Config &Conf, unsigned Task, AddStreamFn AddStream, return finalizeOptimizationRemarks(std::move(DiagnosticOutputFile)); auto ModuleLoader = [&](StringRef Identifier) { + llvm::TimeTraceScope moduleLoaderScope("Module loader", Identifier); assert(Mod.getContext().isODRUniquingDebugTypes() && "ODR Type uniquing should be enabled on the context"); if (ModuleMap) { @@ -712,10 +718,13 @@ Error lto::thinBackend(const Config &Conf, unsigned Task, AddStreamFn AddStream, return MOrErr; }; - FunctionImporter Importer(CombinedIndex, ModuleLoader, - ClearDSOLocalOnDeclarations); - if (Error Err = Importer.importFunctions(Mod, ImportList).takeError()) - return Err; + { + llvm::TimeTraceScope importScope("Import functions"); + FunctionImporter Importer(CombinedIndex, ModuleLoader, + ClearDSOLocalOnDeclarations); + if (Error Err = Importer.importFunctions(Mod, ImportList).takeError()) + return Err; + } // Do this after any importing so that imported code is updated. updateMemProfAttributes(Mod, CombinedIndex); |