//
//===----------------------------------------------------------------------===//
#define DEBUG_TYPE "profile-estimator"
-#include "llvm/Pass.h"
#include "llvm/Analysis/Passes.h"
-#include "llvm/Analysis/ProfileInfo.h"
#include "llvm/Analysis/LoopInfo.h"
+#include "llvm/Analysis/ProfileInfo.h"
+#include "llvm/Pass.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
-#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Format.h"
+#include "llvm/Support/raw_ostream.h"
using namespace llvm;
static cl::opt<double>
// loop, thus the edge is a backedge, continue and do not check if the
// value is valid.
if (BBisHeader && BBLoop->contains(*bbi)) {
- printEdgeError(edge, "but is backedge, continueing");
+ printEdgeError(edge, "but is backedge, continuing");
continue;
}
// If the edges value is missing (and this is no loop header, and this is
double incoming = BBWeight;
// Subtract the flow leaving the loop.
std::set<Edge> ProcessedExits;
- for (SmallVector<Edge, 8>::iterator ei = ExitEdges.begin(),
+ for (SmallVectorImpl<Edge>::iterator ei = ExitEdges.begin(),
ee = ExitEdges.end(); ei != ee; ++ei) {
if (ProcessedExits.insert(*ei).second) {
double w = getEdgeWeight(*ei);
// be distributed is split and the rounded, the last edge gets a somewhat
// bigger value, but we are close enough for an estimation.
double fraction = floor(incoming/Edges.size());
- for (SmallVector<Edge, 8>::iterator ei = Edges.begin(), ee = Edges.end();
+ for (SmallVectorImpl<Edge>::iterator ei = Edges.begin(), ee = Edges.end();
ei != ee; ++ei) {
double w = 0;
if (ei != (ee-1)) {
}
}
- double fraction = floor(BBWeight/Edges.size());
+ double fraction = Edges.size() ? floor(BBWeight/Edges.size()) : 0.0;
// Finally we know what flow is still not leaving the block, distribute this
// flow onto the empty edges.
- for (SmallVector<Edge, 8>::iterator ei = Edges.begin(), ee = Edges.end();
+ for (SmallVectorImpl<Edge>::iterator ei = Edges.begin(), ee = Edges.end();
ei != ee; ++ei) {
if (ei != (ee-1)) {
EdgeInformation[BB->getParent()][*ei] += fraction;
FunctionInformation.erase(&F);
BlockInformation[&F].clear();
EdgeInformation[&F].clear();
+ BBToVisit.clear();
// Mark all blocks as to visit.
for (Function::iterator bi = F.begin(), be = F.end(); bi != be; ++bi)
// Clear Minimal Edges.
MinimalWeight.clear();
- DEBUG(dbgs() << "Working on function " << F.getNameStr() << "\n");
+ DEBUG(dbgs() << "Working on function " << F.getName() << "\n");
// Since the entry block is the first one and has no predecessors, the edge
// (0,entry) is inserted with the starting weight of 1.