Skip to content

Commit

Permalink
Add option to time passes
Browse files Browse the repository at this point in the history
Summary:
As we begin to work on optimization passes for bolt, it is important to
keep track of the time spent in each of these to measure their
contribution to the time bolt takes to finish rewriting a program.

(cherry picked from FBD4301136)
  • Loading branch information
rafaelauler authored and maksfb committed Dec 8, 2016
1 parent 3888c56 commit c570038
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions bolt/BinaryPassManager.cpp
Expand Up @@ -10,6 +10,7 @@
//===----------------------------------------------------------------------===//

#include "BinaryPassManager.h"
#include "llvm/Support/Timer.h"

using namespace llvm;

Expand All @@ -19,6 +20,10 @@ extern llvm::cl::opt<bool> PrintAll;
extern llvm::cl::opt<bool> DumpDotAll;
extern llvm::cl::opt<bool> DynoStatsAll;

llvm::cl::opt<bool> TimeOpts("time-opts",
cl::desc("print time spent in each optimization"),
cl::init(false), cl::ZeroOrMore);

static cl::opt<bool>
EliminateUnreachable("eliminate-unreachable",
cl::desc("eliminate unreachable code"),
Expand Down Expand Up @@ -135,6 +140,9 @@ namespace bolt {

using namespace opts;

const char BinaryFunctionPassManager::TimerGroupName[] =
"Binary Function Pass Manager";

cl::opt<bool> BinaryFunctionPassManager::AlwaysOn(
"always-run-pass",
cl::desc("Used for passes that are always enabled"),
Expand All @@ -148,6 +156,8 @@ void BinaryFunctionPassManager::runPasses() {

auto &Pass = OptPassPair.second;

NamedRegionTimer(Pass->getName(), TimerGroupName, TimeOpts);

callWithDynoStats(
[this,&Pass] {
Pass->runOnFunctions(BC, BFs, LargeFunctions);
Expand Down
1 change: 1 addition & 0 deletions bolt/BinaryPassManager.h
Expand Up @@ -34,6 +34,7 @@ class BinaryFunctionPassManager {
std::set<uint64_t> &LargeFunctions;
std::vector<std::pair<const cl::opt<bool> &,
std::unique_ptr<BinaryFunctionPass>>> Passes;
static const char TimerGroupName[];

public:
BinaryFunctionPassManager(BinaryContext &BC,
Expand Down

0 comments on commit c570038

Please sign in to comment.