Skip to content

Commit

Permalink
Reformat the register strings in the output so Stoke can parse withou…
Browse files Browse the repository at this point in the history
…t preprocessing.

Summary:
Minor change. Reformat the def-in, live-out register strings so that Stoke can parse
without doing preprocessing.

(cherry picked from FBD5537421)
  • Loading branch information
yzhao30 authored and maksfb committed Jul 27, 2017
1 parent 87481cb commit eb64d03
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
7 changes: 4 additions & 3 deletions bolt/Passes/StokeInfo.cpp
Expand Up @@ -12,7 +12,7 @@ cl::OptionCategory StokeOptCategory("STOKE pass options");

static cl::opt<std::string>
StokeOutputDataFilename("stoke-out",
cl::desc("output data for stoke's use"),
cl::desc("output data (.csv) for Stoke's use"),
cl::Optional,
cl::cat(StokeOptCategory));
}
Expand Down Expand Up @@ -80,7 +80,7 @@ void StokeInfo::checkInstr(const BinaryContext &BC, const BinaryFunction &BF,
} // end of for (auto *BB : ...)
}

bool StokeInfo::analyze(const BinaryContext &BC, BinaryFunction &BF,
bool StokeInfo::checkFunction(const BinaryContext &BC, BinaryFunction &BF,
DataflowInfoManager &DInfo, RegAnalysis &RA,
StokeFuncInfo &FuncInfo) {

Expand All @@ -95,6 +95,7 @@ bool StokeInfo::analyze(const BinaryContext &BC, BinaryFunction &BF,
FuncInfo.Offset = BF.getFileOffset();
FuncInfo.Size = BF.getMaxSize();
FuncInfo.NumInstrs = BF.getNumNonPseudos();
FuncInfo.NumBlocks = BF.size();
// early stop for large functions
if (FuncInfo.NumInstrs > 500) {
return false;
Expand Down Expand Up @@ -176,7 +177,7 @@ void StokeInfo::runOnFunctions(
for (auto &BF : BFs) {
DataflowInfoManager DInfo(BC, BF.second, &RA/*RA.get()*/, nullptr);
FuncInfo.reset();
if (analyze(BC, BF.second, DInfo, RA, FuncInfo)) {
if (checkFunction(BC, BF.second, DInfo, RA, FuncInfo)) {
FuncInfo.printData(Outfile);
}
}
Expand Down
12 changes: 7 additions & 5 deletions bolt/Passes/StokeInfo.h
Expand Up @@ -39,6 +39,7 @@ struct StokeFuncInfo {
uint64_t Offset;
uint64_t Size;
uint64_t NumInstrs;
uint64_t NumBlocks;
bool IsLoopFree;
unsigned NumLoops;
unsigned MaxLoopDepth;
Expand All @@ -59,7 +60,7 @@ struct StokeFuncInfo {

void reset() {
FuncName = "";
Offset = Size = NumInstrs = 0;
Offset = Size = NumInstrs = NumBlocks = 0;
NumLoops = MaxLoopDepth = 0;
HotSize = TotalSize = 0;
Score = 0;
Expand All @@ -77,7 +78,7 @@ struct StokeFuncInfo {
void printCsvHeader(std::ofstream &Outfile) {
if (Outfile.is_open()) {
Outfile
<< "FuncName,Offset,Size,NumInstrs,"
<< "FuncName,Offset,Size,NumInstrs,NumBlocks,"
<< "IsLoopFree,NumLoops,MaxLoopDepth,"
<< "HotSize,TotalSize,"
<< "Score,"
Expand All @@ -91,7 +92,8 @@ struct StokeFuncInfo {
void printData(std::ofstream &Outfile) {
if (Outfile.is_open()) {
Outfile
<< FuncName << "," << Offset << "," << Size << "," << NumInstrs << ","
<< FuncName << ","
<< Offset << "," << Size << "," << NumInstrs << "," << NumBlocks << ","
<< IsLoopFree << "," << NumLoops << "," << MaxLoopDepth << ","
<< HotSize << "," << TotalSize << ","
<< Score << ","
Expand All @@ -101,7 +103,7 @@ struct StokeFuncInfo {
}
Outfile << "}\",\"{ ";
for (auto s : LiveOut) {
Outfile << s << " ";
Outfile << "%" << s << " ";
}
Outfile << "}\"," << HeapOut << "," << StackOut << ","
<< HasRipAddr << ","
Expand Down Expand Up @@ -132,7 +134,7 @@ class StokeInfo : public BinaryFunctionPass {
StokeFuncInfo &FuncInfo);

/// Get all required information for the stoke optimization
bool analyze(const BinaryContext &BC, BinaryFunction &BF,
bool checkFunction(const BinaryContext &BC, BinaryFunction &BF,
DataflowInfoManager &DInfo, RegAnalysis &RA,
StokeFuncInfo &FuncInfo);

Expand Down

0 comments on commit eb64d03

Please sign in to comment.