Add timing of bitcode parser to Subzero.
Adds timers to each bitcode block parser in Subzero, to get a reading
on how much time is used by the bitcode parser.
BUG=None
R=jvoung@chromium.org, stichnot@chromium.org
Review URL: https://codereview.chromium.org/688543003
diff --git a/src/IceTimerTree.def b/src/IceTimerTree.def
index 6de5055..1fbd709 100644
--- a/src/IceTimerTree.def
+++ b/src/IceTimerTree.def
@@ -14,35 +14,42 @@
#ifndef SUBZERO_SRC_ICETIMERTREE_DEF
-#define TIMERTREE_TABLE \
- /* enum value */ \
- X(O2) \
- X(Om1) \
- X(advancedPhiLowering) \
- X(convertToIce) \
- X(deletePhis) \
- X(doAddressOpt) \
- X(doArgLowering) \
- X(doBranchOpt) \
- X(doNopInsertion) \
- X(emit) \
- X(genCode) \
- X(genFrame) \
- X(initUnhandled) \
- X(linearScan) \
- X(liveRange) \
- X(liveRangeCtor) \
- X(liveness) \
- X(livenessLightweight) \
- X(llvmConvert) \
- X(parse) \
- X(placePhiLoads) \
- X(placePhiStores) \
- X(regAlloc) \
- X(renumberInstructions) \
- X(szmain) \
- X(translate) \
- X(validateLiveness) \
+#define TIMERTREE_TABLE \
+ /* enum value */ \
+ X(O2) \
+ X(Om1) \
+ X(advancedPhiLowering) \
+ X(convertToIce) \
+ X(deletePhis) \
+ X(doAddressOpt) \
+ X(doArgLowering) \
+ X(doBranchOpt) \
+ X(doNopInsertion) \
+ X(emit) \
+ X(genCode) \
+ X(genFrame) \
+ X(initUnhandled) \
+ X(linearScan) \
+ X(liveRange) \
+ X(liveRangeCtor) \
+ X(liveness) \
+ X(livenessLightweight) \
+ X(llvmConvert) \
+ X(parse) \
+ X(parseConstants) \
+ X(parseFunctions) \
+ X(parseFunctionValuesymtabs) \
+ X(parseGlobals) \
+ X(parseModule) \
+ X(parseModuleValuesymtabs) \
+ X(parseTypes) \
+ X(placePhiLoads) \
+ X(placePhiStores) \
+ X(regAlloc) \
+ X(renumberInstructions) \
+ X(szmain) \
+ X(translate) \
+ X(validateLiveness) \
X(vmetadata)
//#define X(tag)
diff --git a/src/PNaClTranslator.cpp b/src/PNaClTranslator.cpp
index 2bd47b8..f2d8e0c 100644
--- a/src/PNaClTranslator.cpp
+++ b/src/PNaClTranslator.cpp
@@ -631,11 +631,14 @@
class TypesParser : public BlockParserBaseClass {
public:
TypesParser(unsigned BlockID, BlockParserBaseClass *EnclosingParser)
- : BlockParserBaseClass(BlockID, EnclosingParser), NextTypeId(0) {}
+ : BlockParserBaseClass(BlockID, EnclosingParser),
+ Timer(Ice::TimerStack::TT_parseTypes, getTranslator().getContext()),
+ NextTypeId(0) {}
~TypesParser() override {}
private:
+ Ice::TimerMarker Timer;
// The type ID that will be associated with the next type defining
// record in the types block.
unsigned NextTypeId;
@@ -801,12 +804,15 @@
class GlobalsParser : public BlockParserBaseClass {
public:
GlobalsParser(unsigned BlockID, BlockParserBaseClass *EnclosingParser)
- : BlockParserBaseClass(BlockID, EnclosingParser), InitializersNeeded(0),
- NextGlobalID(0), DummyGlobalVar(Ice::VariableDeclaration::create(
- getTranslator().getContext())),
+ : BlockParserBaseClass(BlockID, EnclosingParser),
+ Timer(Ice::TimerStack::TT_parseGlobals, getTranslator().getContext()),
+ InitializersNeeded(0), NextGlobalID(0),
+ DummyGlobalVar(
+ Ice::VariableDeclaration::create(getTranslator().getContext())),
CurGlobalVar(DummyGlobalVar) {}
private:
+ Ice::TimerMarker Timer;
// Keeps track of how many initializers are expected for the global variable
// declaration being built.
unsigned InitializersNeeded;
@@ -1004,6 +1010,7 @@
public:
FunctionParser(unsigned BlockID, BlockParserBaseClass *EnclosingParser)
: BlockParserBaseClass(BlockID, EnclosingParser),
+ Timer(Ice::TimerStack::TT_parseFunctions, getTranslator().getContext()),
Func(new Ice::Cfg(getTranslator().getContext())), CurrentBbIndex(0),
FcnId(Context->getNextFunctionBlockValueID()),
FuncDecl(Context->getFunctionByID(FcnId)),
@@ -1036,6 +1043,7 @@
}
private:
+ Ice::TimerMarker Timer;
// The corresponding ICE function defined by the function block.
Ice::Cfg *Func;
// The index to the current basic block being built.
@@ -2251,12 +2259,14 @@
public:
ConstantsParser(unsigned BlockID, FunctionParser *FuncParser)
- : BlockParserBaseClass(BlockID, FuncParser), FuncParser(FuncParser),
- NextConstantType(Ice::IceType_void) {}
+ : BlockParserBaseClass(BlockID, FuncParser),
+ Timer(Ice::TimerStack::TT_parseConstants, getTranslator().getContext()),
+ FuncParser(FuncParser), NextConstantType(Ice::IceType_void) {}
~ConstantsParser() override {}
private:
+ Ice::TimerMarker Timer;
// The parser of the function block this constants block appears in.
FunctionParser *FuncParser;
// The type to use for succeeding constants.
@@ -2366,9 +2376,12 @@
public:
FunctionValuesymtabParser(unsigned BlockID, FunctionParser *EnclosingParser)
- : ValuesymtabParser(BlockID, EnclosingParser) {}
+ : ValuesymtabParser(BlockID, EnclosingParser),
+ Timer(Ice::TimerStack::TT_parseFunctionValuesymtabs,
+ getTranslator().getContext()) {}
private:
+ Ice::TimerMarker Timer;
// Returns the enclosing function parser.
FunctionParser *getFunctionParser() const {
return reinterpret_cast<FunctionParser *>(GetEnclosingParser());
@@ -2439,11 +2452,14 @@
public:
ModuleParser(unsigned BlockID, TopLevelParser *Context)
: BlockParserBaseClass(BlockID, Context),
+ Timer(Ice::TimerStack::TT_parseModule,
+ Context->getTranslator().getContext()),
GlobalDeclarationNamesAndInitializersInstalled(false) {}
~ModuleParser() override {}
private:
+ Ice::TimerMarker Timer;
// True if we have already installed names for unnamed global declarations,
// and have generated global constant initializers.
bool GlobalDeclarationNamesAndInitializersInstalled;
@@ -2505,11 +2521,14 @@
public:
ModuleValuesymtabParser(unsigned BlockID, ModuleParser *MP)
- : ValuesymtabParser(BlockID, MP) {}
+ : ValuesymtabParser(BlockID, MP),
+ Timer(Ice::TimerStack::TT_parseModuleValuesymtabs,
+ getTranslator().getContext()) {}
~ModuleValuesymtabParser() override {}
private:
+ Ice::TimerMarker Timer;
void setValueName(uint64_t Index, StringType &Name) override;
void setBbName(uint64_t Index, StringType &Name) override;
};
diff --git a/src/llvm2ice.cpp b/src/llvm2ice.cpp
index ffbf196..fd0cc30 100644
--- a/src/llvm2ice.cpp
+++ b/src/llvm2ice.cpp
@@ -300,12 +300,12 @@
<< "--build-on-read=0 not allowed\n";
return GetReturnValue(1);
}
+ if (SubzeroTimingEnabled)
+ Ctx.dumpTimers();
if (TimeEachFunction) {
const bool DumpCumulative = false;
Ctx.dumpTimers(Ice::GlobalContext::TSK_Funcs, DumpCumulative);
}
- if (SubzeroTimingEnabled)
- Ctx.dumpTimers();
const bool FinalStats = true;
Ctx.dumpStats("_FINAL_", FinalStats);
return GetReturnValue(ErrorStatus);