[llvm-commits] [PATCH] Fix profile info consistency check.

Andreas Simbuerger simbuerg at fim.uni-passau.de
Thu Dec 8 08:08:34 PST 2011


The consistency check for EdgeProfile Info is only
working if the IR code consists of less edges than
the read profile information.

It should work on codes with more edges than read too.
---
 lib/Analysis/ProfileInfoLoaderPass.cpp |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/Analysis/ProfileInfoLoaderPass.cpp b/lib/Analysis/ProfileInfoLoaderPass.cpp
index 098079b..0875a2c 100644
--- a/lib/Analysis/ProfileInfoLoaderPass.cpp
+++ b/lib/Analysis/ProfileInfoLoaderPass.cpp
@@ -132,7 +132,7 @@ void LoaderPass::recurseBasicBlock(const BasicBlock *BB) {
 void LoaderPass::readEdge(ProfileInfo::Edge e,
                           std::vector<unsigned> &ECs) {
   if (ReadCount < ECs.size()) {
-    double weight = ECs[ReadCount++];
+    double weight = ECs[ReadCount];
     if (weight != ProfileInfoLoader::Uncounted) {
       // Here the data realm changes from the unsigned of the file to the
       // double of the ProfileInfo. This conversion is save because we know
@@ -141,7 +141,7 @@ void LoaderPass::readEdge(ProfileInfo::Edge e,
       EdgeInformation[getFunction(e)][e] += (double)weight;
 
       DEBUG(dbgs() << "--Read Edge Counter for " << e
-                   << " (# "<< (ReadCount-1) << "): "
+                   << " (# "<< ReadCount << "): "
                    << (unsigned)getEdgeWeight(e) << "\n");
     } else {
       // This happens only if reading optimal profiling information, not when
@@ -149,6 +149,8 @@ void LoaderPass::readEdge(ProfileInfo::Edge e,
       SpanningTree.insert(e);
     }
   }
+
+  ReadCount++;
 }
 
 bool LoaderPass::runOnModule(Module &M) {
-- 
1.7.4.1




More information about the llvm-commits mailing list