mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
Teach the BranchProbabilityInfo pass to print its results, and use that
to bring it under direct test instead of merely indirectly testing it in the BlockFrequencyInfo pass. The next step is to start adding tests for the various heuristics employed, and to start fixing those heuristics once they're under test. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142778 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -12,11 +12,13 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/Constants.h"
|
||||
#include "llvm/Function.h"
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/LLVMContext.h"
|
||||
#include "llvm/Metadata.h"
|
||||
#include "llvm/Analysis/BranchProbabilityInfo.h"
|
||||
#include "llvm/Analysis/LoopInfo.h"
|
||||
#include "llvm/Support/CFG.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
|
||||
using namespace llvm;
|
||||
@@ -453,11 +455,26 @@ void BranchProbabilityInfo::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
}
|
||||
|
||||
bool BranchProbabilityInfo::runOnFunction(Function &F) {
|
||||
LastF = &F; // Store the last function we ran on for printing.
|
||||
LoopInfo &LI = getAnalysis<LoopInfo>();
|
||||
BranchProbabilityAnalysis BPA(this, &LI);
|
||||
return BPA.runOnFunction(F);
|
||||
}
|
||||
|
||||
void BranchProbabilityInfo::print(raw_ostream &OS, const Module *) const {
|
||||
OS << "---- Branch Probabilities ----\n";
|
||||
// We print the probabilities from the last function the analysis ran over,
|
||||
// or the function it is currently running over.
|
||||
assert(LastF && "Cannot print prior to running over a function");
|
||||
for (Function::const_iterator BI = LastF->begin(), BE = LastF->end();
|
||||
BI != BE; ++BI) {
|
||||
for (succ_const_iterator SI = succ_begin(BI), SE = succ_end(BI);
|
||||
SI != SE; ++SI) {
|
||||
printEdgeProbability(OS << " ", BI, *SI);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t BranchProbabilityInfo::getSumForBlock(const BasicBlock *BB) const {
|
||||
uint32_t Sum = 0;
|
||||
|
||||
@@ -537,8 +554,9 @@ getEdgeProbability(const BasicBlock *Src, const BasicBlock *Dst) const {
|
||||
}
|
||||
|
||||
raw_ostream &
|
||||
BranchProbabilityInfo::printEdgeProbability(raw_ostream &OS, BasicBlock *Src,
|
||||
BasicBlock *Dst) const {
|
||||
BranchProbabilityInfo::printEdgeProbability(raw_ostream &OS,
|
||||
const BasicBlock *Src,
|
||||
const BasicBlock *Dst) const {
|
||||
|
||||
const BranchProbability Prob = getEdgeProbability(Src, Dst);
|
||||
OS << "edge " << Src->getNameStr() << " -> " << Dst->getNameStr()
|
||||
|
Reference in New Issue
Block a user