#include "bolt/Passes/FrameAnalysis.h"
#include "bolt/Core/CallGraphWalker.h"
#include "bolt/Core/ParallelUtilities.h"
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/Support/Timer.h"
#include <fstream>
#include <stack>
#define DEBUG_TYPE …
usingnamespacellvm;
namespace opts {
extern cl::OptionCategory BoltOptCategory;
extern cl::opt<unsigned> Verbosity;
static cl::list<std::string>
FrameOptFunctionNames("funcs-fop", cl::CommaSeparated,
cl::desc("list of functions to apply frame opts"),
cl::value_desc("func1,func2,func3,..."));
static cl::opt<std::string> FrameOptFunctionNamesFile(
"funcs-file-fop",
cl::desc("file with list of functions to frame optimize"));
static cl::opt<bool> TimeFA("time-fa", cl::desc("time frame analysis steps"),
cl::ReallyHidden, cl::cat(BoltOptCategory));
static cl::opt<bool>
ExperimentalSW("experimental-shrink-wrapping",
cl::desc("process functions with stack pointer arithmetic"),
cl::ReallyHidden, cl::ZeroOrMore, cl::cat(BoltOptCategory));
bool shouldFrameOptimize(const llvm::bolt::BinaryFunction &Function) { … }
}
namespace llvm {
namespace bolt {
raw_ostream &operator<<(raw_ostream &OS, const FrameIndexEntry &FIE) { … }
namespace {
class FrameAccessAnalysis { … };
}
void FrameAnalysis::addArgAccessesFor(MCInst &Inst, ArgAccesses &&AA) { … }
void FrameAnalysis::addArgInStackAccessFor(MCInst &Inst,
const ArgInStackAccess &Arg) { … }
void FrameAnalysis::addFIEFor(MCInst &Inst, const FrameIndexEntry &FIE) { … }
ErrorOr<ArgAccesses &> FrameAnalysis::getArgAccessesFor(const MCInst &Inst) { … }
ErrorOr<const ArgAccesses &>
FrameAnalysis::getArgAccessesFor(const MCInst &Inst) const { … }
ErrorOr<const FrameIndexEntry &>
FrameAnalysis::getFIEFor(const MCInst &Inst) const { … }
void FrameAnalysis::traverseCG(BinaryFunctionCallGraph &CG) { … }
bool FrameAnalysis::updateArgsTouchedFor(const BinaryFunction &BF, MCInst &Inst,
int CurOffset) { … }
bool FrameAnalysis::computeArgsAccessed(BinaryFunction &BF) { … }
bool FrameAnalysis::restoreFrameIndex(BinaryFunction &BF) { … }
void FrameAnalysis::cleanAnnotations() { … }
FrameAnalysis::FrameAnalysis(BinaryContext &BC, BinaryFunctionCallGraph &CG)
: … { … }
void FrameAnalysis::printStats() { … }
void FrameAnalysis::clearSPTMap() { … }
void FrameAnalysis::preComputeSPT() { … }
}
}