[clang] 3fffe68 - [Serialization] Add -ftime-trace block for reading loaded modules.

Sam McCall via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 9 05:37:05 PST 2022


Author: Sam McCall
Date: 2022-12-09T14:36:57+01:00
New Revision: 3fffe6826448ac2daf9c4feb8e48ae8d601aca06

URL: https://github.com/llvm/llvm-project/commit/3fffe6826448ac2daf9c4feb8e48ae8d601aca06
DIFF: https://github.com/llvm/llvm-project/commit/3fffe6826448ac2daf9c4feb8e48ae8d601aca06.diff

LOG: [Serialization] Add -ftime-trace block for reading loaded modules.

The existing ReadAST block only describes the top-level PCM file being
loaded, when in practice most of the time taken is dealing with other
PCM files which are loaded in turn.

Because this work isn't strictly recursive (first all the modules are
discovered, then processsed in several flat loops), we can't have a neat
recursive structure like processing of source files. Instead, slap a
timer on the largest of these boxes: reading the AST block for modules.
In practice this shows where most of the time goes, and in particular
which modules are most expensive.

Added: 
    

Modified: 
    clang/lib/Serialization/ASTReader.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index a775d14c5ac13..f577eba6e04be 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -4295,6 +4295,7 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName,
   // hit errors parsing the ASTs at this point.
   for (ImportedModule &M : Loaded) {
     ModuleFile &F = *M.Mod;
+    llvm::TimeTraceScope Scope2("Read Loaded AST", F.ModuleName);
 
     // Read the AST block.
     if (llvm::Error Err = ReadASTBlock(F, ClientLoadCapabilities)) {


        


More information about the cfe-commits mailing list