/// run - Estimate the profile information from the specified file.
virtual bool runOnFunction(Function &F);
+ /// getAdjustedAnalysisPointer - This method is used when a pass implements
+ /// an analysis interface through multiple inheritance. If needed, it
+ /// should override this to adjust the this pointer as needed for the
+ /// specified pass info.
+ virtual void *getAdjustedAnalysisPointer(const PassInfo *PI) {
+ if (PI->isPassID(&ProfileInfo::ID))
+ return (ProfileInfo*)this;
+ return this;
+ }
+
virtual void recurseBasicBlock(BasicBlock *BB);
void inline printEdgeWeight(Edge);
}
static void inline printEdgeError(ProfileInfo::Edge e, const char *M) {
- DEBUG(errs() << "-- Edge " << e << " is not calculated, " << M << "\n");
+ DEBUG(dbgs() << "-- Edge " << e << " is not calculated, " << M << "\n");
}
void inline ProfileEstimatorPass::printEdgeWeight(Edge E) {
- DEBUG(errs() << "-- Weight of Edge " << E << ":"
+ DEBUG(dbgs() << "-- Weight of Edge " << E << ":"
<< format("%20.20g", getEdgeWeight(E)) << "\n");
}
// from weight.
if (MinimalWeight.find(*ei) != MinimalWeight.end()) {
incoming -= MinimalWeight[*ei];
- DEBUG(errs() << "Reserving " << format("%.20g",MinimalWeight[*ei]) << " at " << (*ei) << "\n");
+ DEBUG(dbgs() << "Reserving " << format("%.20g",MinimalWeight[*ei]) << " at " << (*ei) << "\n");
}
} else {
incoming -= w;
// Read necessary minimal weight.
if (MinimalWeight.find(*ei) != MinimalWeight.end()) {
EdgeInformation[BB->getParent()][*ei] += MinimalWeight[*ei];
- DEBUG(errs() << "Additionally " << format("%.20g",MinimalWeight[*ei]) << " at " << (*ei) << "\n");
+ DEBUG(dbgs() << "Additionally " << format("%.20g",MinimalWeight[*ei]) << " at " << (*ei) << "\n");
}
printEdgeWeight(*ei);
MinimalWeight[e] = 0;
}
MinimalWeight[e] += w;
- DEBUG(errs() << "Minimal Weight for " << e << ": " << format("%.20g",MinimalWeight[e]) << "\n");
+ DEBUG(dbgs() << "Minimal Weight for " << e << ": " << format("%.20g",MinimalWeight[e]) << "\n");
Dest = Parent;
}
}
// from block weight, this is readded later on.
if (MinimalWeight.find(edge) != MinimalWeight.end()) {
BBWeight -= MinimalWeight[edge];
- DEBUG(errs() << "Reserving " << format("%.20g",MinimalWeight[edge]) << " at " << edge << "\n");
+ DEBUG(dbgs() << "Reserving " << format("%.20g",MinimalWeight[edge]) << " at " << edge << "\n");
}
}
}
// Readd minial necessary weight.
if (MinimalWeight.find(*ei) != MinimalWeight.end()) {
EdgeInformation[BB->getParent()][*ei] += MinimalWeight[*ei];
- DEBUG(errs() << "Additionally " << format("%.20g",MinimalWeight[*ei]) << " at " << (*ei) << "\n");
+ DEBUG(dbgs() << "Additionally " << format("%.20g",MinimalWeight[*ei]) << " at " << (*ei) << "\n");
}
printEdgeWeight(*ei);
}
// Clear Minimal Edges.
MinimalWeight.clear();
- DEBUG(errs() << "Working on function " << F.getNameStr() << "\n");
+ DEBUG(dbgs() << "Working on function " << F.getNameStr() << "\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.
BasicBlock *entry = &F.getEntryBlock();
- BlockInformation[&F][entry] = pow(2,32);
+ BlockInformation[&F][entry] = pow(2.0, 32.0);
Edge edge = getEdge(0,entry);
EdgeInformation[&F][edge] = BlockInformation[&F][entry];
printEdgeWeight(edge);
if (Dest != *bbi) {
// If there is no circle, just set edge weight to 0
EdgeInformation[&F][e] = 0;
- DEBUG(errs() << "Assuming edge weight: ");
+ DEBUG(dbgs() << "Assuming edge weight: ");
printEdgeWeight(e);
found = true;
}
}
if (!found) {
cleanup = true;
- DEBUG(errs() << "No assumption possible in Fuction "<<F.getName()<<", setting all to zero\n");
+ DEBUG(dbgs() << "No assumption possible in Fuction "<<F.getName()<<", setting all to zero\n");
}
}
}
for (Function::const_iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI) {
const BasicBlock *BB = &(*FI);
BlockInformation[&F][BB] = 0;
- pred_const_iterator predi = pred_begin(BB), prede = pred_end(BB);
+ const_pred_iterator predi = pred_begin(BB), prede = pred_end(BB);
if (predi == prede) {
Edge e = getEdge(0,BB);
setEdgeWeight(e,0);