[llvm-commits] [llvm] r80667 - in /llvm/trunk: include/llvm/Analysis/ProfileInfo.h lib/Analysis/ProfileEstimatorPass.cpp
Andreas Neustifter
astifter at gmx.at
Tue Sep 1 03:06:06 PDT 2009
Author: astifter
Date: Tue Sep 1 05:06:05 2009
New Revision: 80667
URL: http://llvm.org/viewvc/llvm-project?rev=80667&view=rev
Log:
Preparation for Optimal Edge Profiling:
Optimal edge profiling is only possible when blocks with no predecessors get an
virtual edge (BB,0) that counts the execution frequencies of this
function-exiting blocks.
This patch makes the necessary changes before actually enabling optimal edge profiling.
Modified:
llvm/trunk/include/llvm/Analysis/ProfileInfo.h
llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp
Modified: llvm/trunk/include/llvm/Analysis/ProfileInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ProfileInfo.h?rev=80667&r1=80666&r2=80667&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/ProfileInfo.h (original)
+++ llvm/trunk/include/llvm/Analysis/ProfileInfo.h Tue Sep 1 05:06:05 2009
@@ -63,8 +63,13 @@
// getFunction() - Returns the Function for an Edge, checking for validity.
static const Function* getFunction(Edge e) {
- assert(e.second && "Invalid ProfileInfo::Edge");
- return e.second->getParent();
+ if (e.first) {
+ return e.first->getParent();
+ } else if (e.second) {
+ return e.second->getParent();
+ }
+ assert(0 && "Invalid ProfileInfo::Edge");
+ return (const Function*)0;
}
// getEdge() - Creates an Edge from two BasicBlocks.
Modified: llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp?rev=80667&r1=80666&r2=80667&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp (original)
+++ llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp Tue Sep 1 05:06:05 2009
@@ -168,7 +168,14 @@
std::set<BasicBlock*> ProcessedSuccs;
// Otherwise consider weight of outgoing edges and store them for
- // distribution of remaining weight.
+ // distribution of remaining weight. In case the block has no successors
+ // create a (BB,0) edge.
+ succ_iterator bbi = succ_begin(BB), bbe = succ_end(BB);
+ if (bbi == bbe) {
+ Edge edge = getEdge(BB,0);
+ EdgeInformation[BB->getParent()][edge] = BBWeight;
+ printEdgeWeight(edge);
+ }
for ( succ_iterator bbi = succ_begin(BB), bbe = succ_end(BB);
bbi != bbe; ++bbi ) {
if (ProcessedSuccs.insert(*bbi).second) {
More information about the llvm-commits
mailing list