Propagate debug loc info through prologue/epilogue.
[oota-llvm.git] / lib / Analysis / ProfileInfoLoader.cpp
index b1ed235c10c1307c6a3ed229650e15077805a4d5..3a0a740f0035dac54044516398947360793bf367 100644 (file)
@@ -2,8 +2,8 @@
 //
 //                      The LLVM Compiler Infrastructure
 //
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
@@ -18,6 +18,7 @@
 #include "llvm/InstrTypes.h"
 #include "llvm/Support/Streams.h"
 #include <cstdio>
+#include <cstdlib>
 #include <map>
 using namespace llvm;
 
@@ -152,7 +153,8 @@ void ProfileInfoLoader::getFunctionCounts(std::vector<std::pair<Function*,
       getBlockCounts(BlockCounts);
 
       for (unsigned i = 0, e = BlockCounts.size(); i != e; ++i)
-        if (&BlockCounts[i].first->getParent()->front() == BlockCounts[i].first)
+        if (&BlockCounts[i].first->getParent()->getEntryBlock() ==
+            BlockCounts[i].first)
           Counts.push_back(std::make_pair(BlockCounts[i].first->getParent(),
                                           BlockCounts[i].second));
     } else {
@@ -164,7 +166,7 @@ void ProfileInfoLoader::getFunctionCounts(std::vector<std::pair<Function*,
   unsigned Counter = 0;
   for (Module::iterator I = M.begin(), E = M.end();
        I != E && Counter != FunctionCounts.size(); ++I)
-    if (!I->isExternal())
+    if (!I->isDeclaration())
       Counts.push_back(std::make_pair(I, FunctionCounts[Counter++]));
 }