зеркало из https://github.com/microsoft/clang-1.git
teach -ftime-report to time the code generator and -emit-llvm times.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64873 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
445026698c
Коммит
6f114eb1d6
|
@ -26,6 +26,7 @@
|
||||||
#include "llvm/CodeGen/SchedulerRegistry.h"
|
#include "llvm/CodeGen/SchedulerRegistry.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/Support/Compiler.h"
|
#include "llvm/Support/Compiler.h"
|
||||||
|
#include "llvm/Support/Timer.h"
|
||||||
#include "llvm/System/Path.h"
|
#include "llvm/System/Path.h"
|
||||||
#include "llvm/System/Program.h"
|
#include "llvm/System/Program.h"
|
||||||
#include "llvm/Target/SubtargetFeature.h"
|
#include "llvm/Target/SubtargetFeature.h"
|
||||||
|
@ -45,6 +46,9 @@ namespace {
|
||||||
std::string OutputFile;
|
std::string OutputFile;
|
||||||
bool GenerateDebugInfo;
|
bool GenerateDebugInfo;
|
||||||
|
|
||||||
|
Timer LLVMIRGeneration;
|
||||||
|
Timer CodeGenerationTime;
|
||||||
|
|
||||||
llvm::OwningPtr<CodeGenerator> Gen;
|
llvm::OwningPtr<CodeGenerator> Gen;
|
||||||
|
|
||||||
llvm::Module *TheModule;
|
llvm::Module *TheModule;
|
||||||
|
@ -81,10 +85,13 @@ namespace {
|
||||||
InputFile(infile),
|
InputFile(infile),
|
||||||
OutputFile(outfile),
|
OutputFile(outfile),
|
||||||
GenerateDebugInfo(debug),
|
GenerateDebugInfo(debug),
|
||||||
|
LLVMIRGeneration("LLVM IR Generation Time"),
|
||||||
|
CodeGenerationTime("Code Generation Time"),
|
||||||
Gen(CreateLLVMCodeGen(Diags, langopts, InputFile, GenerateDebugInfo)),
|
Gen(CreateLLVMCodeGen(Diags, langopts, InputFile, GenerateDebugInfo)),
|
||||||
TheModule(0), TheTargetData(0), AsmOutStream(0), ModuleProvider(0),
|
TheModule(0), TheTargetData(0), AsmOutStream(0), ModuleProvider(0),
|
||||||
CodeGenPasses(0), PerModulePasses(0), PerFunctionPasses(0) {
|
CodeGenPasses(0), PerModulePasses(0), PerFunctionPasses(0) {
|
||||||
|
|
||||||
|
// Enable -time-passes if -ftime-report is enabled.
|
||||||
llvm::TimePassesIsEnabled = CompileOpts.TimePasses;
|
llvm::TimePassesIsEnabled = CompileOpts.TimePasses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,22 +105,43 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void InitializeTU(TranslationUnit& TU) {
|
virtual void InitializeTU(TranslationUnit& TU) {
|
||||||
|
|
||||||
|
if (CompileOpts.TimePasses)
|
||||||
|
LLVMIRGeneration.startTimer();
|
||||||
|
|
||||||
Gen->InitializeTU(TU);
|
Gen->InitializeTU(TU);
|
||||||
|
|
||||||
TheModule = Gen->GetModule();
|
TheModule = Gen->GetModule();
|
||||||
ModuleProvider = new ExistingModuleProvider(TheModule);
|
ModuleProvider = new ExistingModuleProvider(TheModule);
|
||||||
TheTargetData =
|
TheTargetData =
|
||||||
new llvm::TargetData(TU.getContext().Target.getTargetDescription());
|
new llvm::TargetData(TU.getContext().Target.getTargetDescription());
|
||||||
|
|
||||||
|
if (CompileOpts.TimePasses)
|
||||||
|
LLVMIRGeneration.stopTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void HandleTopLevelDecl(Decl *D) {
|
virtual void HandleTopLevelDecl(Decl *D) {
|
||||||
|
if (CompileOpts.TimePasses)
|
||||||
|
LLVMIRGeneration.startTimer();
|
||||||
|
|
||||||
Gen->HandleTopLevelDecl(D);
|
Gen->HandleTopLevelDecl(D);
|
||||||
|
|
||||||
|
if (CompileOpts.TimePasses)
|
||||||
|
LLVMIRGeneration.stopTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void HandleTranslationUnit(TranslationUnit& TU) {
|
virtual void HandleTranslationUnit(TranslationUnit& TU) {
|
||||||
|
if (CompileOpts.TimePasses)
|
||||||
|
LLVMIRGeneration.startTimer();
|
||||||
|
|
||||||
Gen->HandleTranslationUnit(TU);
|
Gen->HandleTranslationUnit(TU);
|
||||||
|
|
||||||
EmitAssembly();
|
if (CompileOpts.TimePasses)
|
||||||
|
LLVMIRGeneration.stopTimer();
|
||||||
|
|
||||||
|
// EmitAssembly times itself.
|
||||||
|
EmitAssembly();
|
||||||
|
|
||||||
// Force a flush here in case we never get released.
|
// Force a flush here in case we never get released.
|
||||||
if (AsmOutStream)
|
if (AsmOutStream)
|
||||||
AsmOutStream->flush();
|
AsmOutStream->flush();
|
||||||
|
@ -326,6 +354,8 @@ void BackendConsumer::EmitAssembly() {
|
||||||
// Silently ignore if we weren't initialized for some reason.
|
// Silently ignore if we weren't initialized for some reason.
|
||||||
if (!TheModule || !TheTargetData)
|
if (!TheModule || !TheTargetData)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
TimeRegion Region(CodeGenerationTime);
|
||||||
|
|
||||||
// Make sure IR generation is happy with the module. This is
|
// Make sure IR generation is happy with the module. This is
|
||||||
// released by the module provider.
|
// released by the module provider.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче