Add time trace scopes to addToCallGraph & getCFG (#174717)
This PR adds performance instrumentation to `clang::CallGraph` and `clang::CFG` to aid in benchmarking the overhead of call graph construction and CFG rebuilding. This aims to facilitate benchmarking on large codebases like LLVM to ensure that the performance impact of new analysis-based warnings remains within acceptable regressions.
This commit is contained in:
parent
2926b4100d
commit
11dcb756c6
@ -26,6 +26,7 @@
|
||||
#include "llvm/ADT/SetVector.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/iterator_range.h"
|
||||
#include "llvm/Support/TimeProfiler.h"
|
||||
#include <memory>
|
||||
|
||||
namespace clang {
|
||||
@ -61,6 +62,7 @@ public:
|
||||
///
|
||||
/// Recursively walks the declaration to find all the dependent Decls as well.
|
||||
void addToCallGraph(Decl *D) {
|
||||
llvm::TimeTraceScope TimeProfile("AddToCallGraph");
|
||||
TraverseDecl(D);
|
||||
}
|
||||
|
||||
|
||||
@ -52,6 +52,7 @@
|
||||
#include "llvm/Support/Format.h"
|
||||
#include "llvm/Support/GraphWriter.h"
|
||||
#include "llvm/Support/SaveAndRestore.h"
|
||||
#include "llvm/Support/TimeProfiler.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <cassert>
|
||||
#include <memory>
|
||||
@ -5359,6 +5360,7 @@ CFGBlock *CFG::createBlock() {
|
||||
/// buildCFG - Constructs a CFG from an AST.
|
||||
std::unique_ptr<CFG> CFG::buildCFG(const Decl *D, Stmt *Statement,
|
||||
ASTContext *C, const BuildOptions &BO) {
|
||||
llvm::TimeTraceScope TimeProfile("BuildCFG");
|
||||
CFGBuilder Builder(C, BO);
|
||||
return Builder.buildCFG(D, Statement);
|
||||
}
|
||||
|
||||
@ -333,8 +333,10 @@ Frontend (test.cc)
|
||||
| | InstantiateFunction (fooA<int>, a.h:7)
|
||||
| | | InstantiateFunction (fooB<int>, b.h:8)
|
||||
| | | | DeferInstantiation (fooC<int>)
|
||||
| | | | BuildCFG
|
||||
| | | DeferInstantiation (fooMTA<int>)
|
||||
| | | InstantiateFunction (fooC<int>, b.h:3)
|
||||
| | | | BuildCFG
|
||||
| | | InstantiateFunction (fooMTA<int>, a.h:4)
|
||||
)",
|
||||
buildTraceGraph(Json));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user