mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-02 19:24:25 +00:00
Update llvm-prof for ProfileInfo API changes.
- Patch by Erick Tryzelaar git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78880 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -58,10 +58,10 @@ namespace {
|
|||||||
// PairSecondSort - A sorting predicate to sort by the second element of a pair.
|
// PairSecondSort - A sorting predicate to sort by the second element of a pair.
|
||||||
template<class T>
|
template<class T>
|
||||||
struct PairSecondSortReverse
|
struct PairSecondSortReverse
|
||||||
: public std::binary_function<std::pair<T, unsigned>,
|
: public std::binary_function<std::pair<T, double>,
|
||||||
std::pair<T, unsigned>, bool> {
|
std::pair<T, double>, bool> {
|
||||||
bool operator()(const std::pair<T, unsigned> &LHS,
|
bool operator()(const std::pair<T, double> &LHS,
|
||||||
const std::pair<T, unsigned> &RHS) const {
|
const std::pair<T, double> &RHS) const {
|
||||||
return LHS.second > RHS.second;
|
return LHS.second > RHS.second;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -98,7 +98,7 @@ namespace {
|
|||||||
|
|
||||||
virtual void emitBasicBlockEndAnnot(const BasicBlock *BB, raw_ostream &OS) {
|
virtual void emitBasicBlockEndAnnot(const BasicBlock *BB, raw_ostream &OS) {
|
||||||
// Figure out how many times each successor executed.
|
// Figure out how many times each successor executed.
|
||||||
std::vector<std::pair<ProfileInfo::Edge, unsigned> > SuccCounts;
|
std::vector<std::pair<ProfileInfo::Edge, double> > SuccCounts;
|
||||||
|
|
||||||
const TerminatorInst *TI = BB->getTerminator();
|
const TerminatorInst *TI = BB->getTerminator();
|
||||||
for (unsigned s = 0, e = TI->getNumSuccessors(); s != e; ++s) {
|
for (unsigned s = 0, e = TI->getNumSuccessors(); s != e; ++s) {
|
||||||
@ -151,8 +151,8 @@ bool ProfileInfoPrinterPass::runOnModule(Module &M) {
|
|||||||
// the command line, for now, just keep things simple.
|
// the command line, for now, just keep things simple.
|
||||||
|
|
||||||
// Emit the most frequent function table...
|
// Emit the most frequent function table...
|
||||||
std::vector<std::pair<Function*, unsigned> > FunctionCounts;
|
std::vector<std::pair<Function*, double> > FunctionCounts;
|
||||||
std::vector<std::pair<BasicBlock*, unsigned> > Counts;
|
std::vector<std::pair<BasicBlock*, double> > Counts;
|
||||||
for (Module::iterator FI = M.begin(), FE = M.end(); FI != FE; ++FI) {
|
for (Module::iterator FI = M.begin(), FE = M.end(); FI != FE; ++FI) {
|
||||||
if (FI->isDeclaration()) continue;
|
if (FI->isDeclaration()) continue;
|
||||||
double w = ignoreMissing(PI.getExecutionCount(FI));
|
double w = ignoreMissing(PI.getExecutionCount(FI));
|
||||||
@ -168,7 +168,7 @@ bool ProfileInfoPrinterPass::runOnModule(Module &M) {
|
|||||||
sort(FunctionCounts.begin(), FunctionCounts.end(),
|
sort(FunctionCounts.begin(), FunctionCounts.end(),
|
||||||
PairSecondSortReverse<Function*>());
|
PairSecondSortReverse<Function*>());
|
||||||
|
|
||||||
uint64_t TotalExecutions = 0;
|
double TotalExecutions = 0;
|
||||||
for (unsigned i = 0, e = FunctionCounts.size(); i != e; ++i)
|
for (unsigned i = 0, e = FunctionCounts.size(); i != e; ++i)
|
||||||
TotalExecutions += FunctionCounts[i].second;
|
TotalExecutions += FunctionCounts[i].second;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user