diff options
author | Anton Afanasyev <anton.a.afanasyev@gmail.com> | 2019-03-30 08:42:48 +0000 |
---|---|---|
committer | Anton Afanasyev <anton.a.afanasyev@gmail.com> | 2019-03-30 08:42:48 +0000 |
commit | d880de2d19d46f7cfea7aa593602458440bc1e8d (patch) | |
tree | 462bf94e899135c45aae23c3cf79251f521003e7 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 98b8ecde64d89cca944d9a975b12319dd0376cc0 (diff) | |
download | bcm5719-llvm-d880de2d19d46f7cfea7aa593602458440bc1e8d.tar.gz bcm5719-llvm-d880de2d19d46f7cfea7aa593602458440bc1e8d.zip |
Adds `-ftime-trace` option to clang that produces Chrome `chrome://tracing` compatible JSON profiling output dumps.
This change adds hierarchical "time trace" profiling blocks that can be visualized in Chrome, in a "flame chart" style. Each profiling block can have a "detail" string that for example indicates the file being processed, template name being instantiated, function being optimized etc.
This is taken from GitHub PR: https://github.com/aras-p/llvm-project-20170507/pull/2
Patch by Aras Pranckevičius.
Differential Revision: https://reviews.llvm.org/D58675
llvm-svn: 357340
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 91f162820cb..1a2e420233e 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -58,6 +58,7 @@ #include "llvm/Support/ConvertUTF.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MD5.h" +#include "llvm/Support/TimeProfiler.h" using namespace clang; using namespace CodeGen; @@ -2482,6 +2483,9 @@ void CodeGenModule::EmitGlobalDefinition(GlobalDecl GD, llvm::GlobalValue *GV) { if (!shouldEmitFunction(GD)) return; + llvm::TimeTraceScope TimeScope( + "CodeGen Function", [&]() { return FD->getQualifiedNameAsString(); }); + if (const auto *Method = dyn_cast<CXXMethodDecl>(D)) { // Make sure to emit the definition(s) before we emit the thunks. // This is necessary for the generation of certain thunks. |