//
// 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.
//
//===----------------------------------------------------------------------===//
//
#include "llvm/InstrTypes.h"
#include "llvm/Support/Streams.h"
#include <cstdio>
+#include <cstdlib>
#include <map>
using namespace llvm;
//
ProfileInfoLoader::ProfileInfoLoader(const char *ToolName,
const std::string &Filename,
- Module &TheModule) : M(TheModule) {
+ Module &TheModule) :
+ M(TheModule), Warned(false) {
FILE *F = fopen(Filename.c_str(), "r");
if (F == 0) {
cerr << ToolName << ": Error opening '" << Filename << "': ";
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 {
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++]));
}
Counts.back().second += EdgeCounts[i].second;
unsigned SuccNum = EdgeCounts[i].first.second;
if (SuccNum >= TI->getNumSuccessors()) {
- static bool Warned = false;
if (!Warned) {
cerr << "WARNING: profile info doesn't seem to match"
<< " the program!\n";