forked from OSchip/llvm-project
Extend -ftime-report to give more information about time spent reading module files.
llvm-svn: 242094
This commit is contained in:
parent
f754b1fe12
commit
ce18a187f7
|
@ -30,6 +30,7 @@
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
class raw_fd_ostream;
|
class raw_fd_ostream;
|
||||||
class Timer;
|
class Timer;
|
||||||
|
class TimerGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace clang {
|
namespace clang {
|
||||||
|
@ -101,7 +102,10 @@ class CompilerInstance : public ModuleLoader {
|
||||||
/// \brief The semantic analysis object.
|
/// \brief The semantic analysis object.
|
||||||
std::unique_ptr<Sema> TheSema;
|
std::unique_ptr<Sema> TheSema;
|
||||||
|
|
||||||
/// \brief The frontend timer
|
/// \brief The frontend timer group.
|
||||||
|
std::unique_ptr<llvm::TimerGroup> FrontendTimerGroup;
|
||||||
|
|
||||||
|
/// \brief The frontend timer.
|
||||||
std::unique_ptr<llvm::Timer> FrontendTimer;
|
std::unique_ptr<llvm::Timer> FrontendTimer;
|
||||||
|
|
||||||
/// \brief The ASTReader, if one exists.
|
/// \brief The ASTReader, if one exists.
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include "llvm/ADT/TinyPtrVector.h"
|
#include "llvm/ADT/TinyPtrVector.h"
|
||||||
#include "llvm/Bitcode/BitstreamReader.h"
|
#include "llvm/Bitcode/BitstreamReader.h"
|
||||||
#include "llvm/Support/DataTypes.h"
|
#include "llvm/Support/DataTypes.h"
|
||||||
|
#include "llvm/Support/Timer.h"
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -380,6 +381,9 @@ private:
|
||||||
/// \brief The module manager which manages modules and their dependencies
|
/// \brief The module manager which manages modules and their dependencies
|
||||||
ModuleManager ModuleMgr;
|
ModuleManager ModuleMgr;
|
||||||
|
|
||||||
|
/// \brief A timer used to track the time spent deserializing.
|
||||||
|
std::unique_ptr<llvm::Timer> ReadTimer;
|
||||||
|
|
||||||
/// \brief The location where the module file will be considered as
|
/// \brief The location where the module file will be considered as
|
||||||
/// imported from. For non-module AST types it should be invalid.
|
/// imported from. For non-module AST types it should be invalid.
|
||||||
SourceLocation CurrentImportLoc;
|
SourceLocation CurrentImportLoc;
|
||||||
|
@ -1281,12 +1285,16 @@ public:
|
||||||
///
|
///
|
||||||
/// \param UseGlobalIndex If true, the AST reader will try to load and use
|
/// \param UseGlobalIndex If true, the AST reader will try to load and use
|
||||||
/// the global module index.
|
/// the global module index.
|
||||||
|
///
|
||||||
|
/// \param ReadTimer If non-null, a timer used to track the time spent
|
||||||
|
/// deserializing.
|
||||||
ASTReader(Preprocessor &PP, ASTContext &Context,
|
ASTReader(Preprocessor &PP, ASTContext &Context,
|
||||||
const PCHContainerOperations &PCHContainerOps,
|
const PCHContainerOperations &PCHContainerOps,
|
||||||
StringRef isysroot = "", bool DisableValidation = false,
|
StringRef isysroot = "", bool DisableValidation = false,
|
||||||
bool AllowASTWithCompilerErrors = false,
|
bool AllowASTWithCompilerErrors = false,
|
||||||
bool AllowConfigurationMismatch = false,
|
bool AllowConfigurationMismatch = false,
|
||||||
bool ValidateSystemInputs = false, bool UseGlobalIndex = true);
|
bool ValidateSystemInputs = false, bool UseGlobalIndex = true,
|
||||||
|
std::unique_ptr<llvm::Timer> ReadTimer = {});
|
||||||
|
|
||||||
~ASTReader() override;
|
~ASTReader() override;
|
||||||
|
|
||||||
|
@ -1710,7 +1718,7 @@ public:
|
||||||
/// \brief Notify ASTReader that we started deserialization of
|
/// \brief Notify ASTReader that we started deserialization of
|
||||||
/// a decl or type so until FinishedDeserializing is called there may be
|
/// a decl or type so until FinishedDeserializing is called there may be
|
||||||
/// decls that are initializing. Must be paired with FinishedDeserializing.
|
/// decls that are initializing. Must be paired with FinishedDeserializing.
|
||||||
void StartedDeserializing() override { ++NumCurrentElementsDeserializing; }
|
void StartedDeserializing() override;
|
||||||
|
|
||||||
/// \brief Notify ASTReader that we finished the deserialization of
|
/// \brief Notify ASTReader that we finished the deserialization of
|
||||||
/// a decl or type. Must be paired with StartedDeserializing.
|
/// a decl or type. Must be paired with StartedDeserializing.
|
||||||
|
|
|
@ -497,7 +497,9 @@ void CompilerInstance::createCodeCompletionConsumer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompilerInstance::createFrontendTimer() {
|
void CompilerInstance::createFrontendTimer() {
|
||||||
FrontendTimer.reset(new llvm::Timer("Clang front-end timer"));
|
FrontendTimerGroup.reset(new llvm::TimerGroup("Clang front-end time report"));
|
||||||
|
FrontendTimer.reset(
|
||||||
|
new llvm::Timer("Clang front-end timer", *FrontendTimerGroup));
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeCompleteConsumer *
|
CodeCompleteConsumer *
|
||||||
|
@ -1237,13 +1239,18 @@ void CompilerInstance::createModuleManager() {
|
||||||
HeaderSearchOptions &HSOpts = getHeaderSearchOpts();
|
HeaderSearchOptions &HSOpts = getHeaderSearchOpts();
|
||||||
std::string Sysroot = HSOpts.Sysroot;
|
std::string Sysroot = HSOpts.Sysroot;
|
||||||
const PreprocessorOptions &PPOpts = getPreprocessorOpts();
|
const PreprocessorOptions &PPOpts = getPreprocessorOpts();
|
||||||
|
std::unique_ptr<llvm::Timer> ReadTimer;
|
||||||
|
if (FrontendTimerGroup)
|
||||||
|
ReadTimer = llvm::make_unique<llvm::Timer>("Reading modules",
|
||||||
|
*FrontendTimerGroup);
|
||||||
ModuleManager = new ASTReader(
|
ModuleManager = new ASTReader(
|
||||||
getPreprocessor(), *Context, *getPCHContainerOperations(),
|
getPreprocessor(), *Context, *getPCHContainerOperations(),
|
||||||
Sysroot.empty() ? "" : Sysroot.c_str(), PPOpts.DisablePCHValidation,
|
Sysroot.empty() ? "" : Sysroot.c_str(), PPOpts.DisablePCHValidation,
|
||||||
/*AllowASTWithCompilerErrors=*/false,
|
/*AllowASTWithCompilerErrors=*/false,
|
||||||
/*AllowConfigurationMismatch=*/false,
|
/*AllowConfigurationMismatch=*/false,
|
||||||
HSOpts.ModulesValidateSystemHeaders,
|
HSOpts.ModulesValidateSystemHeaders,
|
||||||
getFrontendOpts().UseGlobalModuleIndex);
|
getFrontendOpts().UseGlobalModuleIndex,
|
||||||
|
std::move(ReadTimer));
|
||||||
if (hasASTConsumer()) {
|
if (hasASTConsumer()) {
|
||||||
ModuleManager->setDeserializationListener(
|
ModuleManager->setDeserializationListener(
|
||||||
getASTConsumer().GetASTDeserializationListener());
|
getASTConsumer().GetASTDeserializationListener());
|
||||||
|
@ -1259,6 +1266,11 @@ void CompilerInstance::createModuleManager() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CompilerInstance::loadModuleFile(StringRef FileName) {
|
bool CompilerInstance::loadModuleFile(StringRef FileName) {
|
||||||
|
llvm::Timer Timer;
|
||||||
|
if (FrontendTimerGroup)
|
||||||
|
Timer.init("Preloading " + FileName.str(), *FrontendTimerGroup);
|
||||||
|
llvm::TimeRegion TimeLoading(FrontendTimerGroup ? &Timer : nullptr);
|
||||||
|
|
||||||
// Helper to recursively read the module names for all modules we're adding.
|
// Helper to recursively read the module names for all modules we're adding.
|
||||||
// We mark these as known and redirect any attempt to load that module to
|
// We mark these as known and redirect any attempt to load that module to
|
||||||
// the files we were handed.
|
// the files we were handed.
|
||||||
|
@ -1418,6 +1430,11 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
|
||||||
for (auto &Listener : DependencyCollectors)
|
for (auto &Listener : DependencyCollectors)
|
||||||
Listener->attachToASTReader(*ModuleManager);
|
Listener->attachToASTReader(*ModuleManager);
|
||||||
|
|
||||||
|
llvm::Timer Timer;
|
||||||
|
if (FrontendTimerGroup)
|
||||||
|
Timer.init("Loading " + ModuleFileName, *FrontendTimerGroup);
|
||||||
|
llvm::TimeRegion TimeLoading(FrontendTimerGroup ? &Timer : nullptr);
|
||||||
|
|
||||||
// Try to load the module file.
|
// Try to load the module file.
|
||||||
unsigned ARRFlags =
|
unsigned ARRFlags =
|
||||||
Explicit ? 0 : ASTReader::ARR_OutOfDate | ASTReader::ARR_Missing;
|
Explicit ? 0 : ASTReader::ARR_OutOfDate | ASTReader::ARR_Missing;
|
||||||
|
|
|
@ -8396,6 +8396,11 @@ void ASTReader::diagnoseOdrViolations() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ASTReader::StartedDeserializing() {
|
||||||
|
if (++NumCurrentElementsDeserializing == 1 && ReadTimer.get())
|
||||||
|
ReadTimer->startTimer();
|
||||||
|
}
|
||||||
|
|
||||||
void ASTReader::FinishedDeserializing() {
|
void ASTReader::FinishedDeserializing() {
|
||||||
assert(NumCurrentElementsDeserializing &&
|
assert(NumCurrentElementsDeserializing &&
|
||||||
"FinishedDeserializing not paired with StartedDeserializing");
|
"FinishedDeserializing not paired with StartedDeserializing");
|
||||||
|
@ -8420,6 +8425,9 @@ void ASTReader::FinishedDeserializing() {
|
||||||
|
|
||||||
diagnoseOdrViolations();
|
diagnoseOdrViolations();
|
||||||
|
|
||||||
|
if (ReadTimer)
|
||||||
|
ReadTimer->stopTimer();
|
||||||
|
|
||||||
// We are not in recursive loading, so it's safe to pass the "interesting"
|
// We are not in recursive loading, so it's safe to pass the "interesting"
|
||||||
// decls to the consumer.
|
// decls to the consumer.
|
||||||
if (Consumer)
|
if (Consumer)
|
||||||
|
@ -8458,12 +8466,14 @@ ASTReader::ASTReader(Preprocessor &PP, ASTContext &Context,
|
||||||
StringRef isysroot, bool DisableValidation,
|
StringRef isysroot, bool DisableValidation,
|
||||||
bool AllowASTWithCompilerErrors,
|
bool AllowASTWithCompilerErrors,
|
||||||
bool AllowConfigurationMismatch, bool ValidateSystemInputs,
|
bool AllowConfigurationMismatch, bool ValidateSystemInputs,
|
||||||
bool UseGlobalIndex)
|
bool UseGlobalIndex,
|
||||||
|
std::unique_ptr<llvm::Timer> ReadTimer)
|
||||||
: Listener(new PCHValidator(PP, *this)), DeserializationListener(nullptr),
|
: Listener(new PCHValidator(PP, *this)), DeserializationListener(nullptr),
|
||||||
OwnsDeserializationListener(false), SourceMgr(PP.getSourceManager()),
|
OwnsDeserializationListener(false), SourceMgr(PP.getSourceManager()),
|
||||||
FileMgr(PP.getFileManager()), PCHContainerOps(PCHContainerOps),
|
FileMgr(PP.getFileManager()), PCHContainerOps(PCHContainerOps),
|
||||||
Diags(PP.getDiagnostics()), SemaObj(nullptr), PP(PP), Context(Context),
|
Diags(PP.getDiagnostics()), SemaObj(nullptr), PP(PP), Context(Context),
|
||||||
Consumer(nullptr), ModuleMgr(PP.getFileManager(), PCHContainerOps),
|
Consumer(nullptr), ModuleMgr(PP.getFileManager(), PCHContainerOps),
|
||||||
|
ReadTimer(std::move(ReadTimer)),
|
||||||
isysroot(isysroot), DisableValidation(DisableValidation),
|
isysroot(isysroot), DisableValidation(DisableValidation),
|
||||||
AllowASTWithCompilerErrors(AllowASTWithCompilerErrors),
|
AllowASTWithCompilerErrors(AllowASTWithCompilerErrors),
|
||||||
AllowConfigurationMismatch(AllowConfigurationMismatch),
|
AllowConfigurationMismatch(AllowConfigurationMismatch),
|
||||||
|
|
Loading…
Reference in New Issue