//
//===----------------------------------------------------------------------===//
+#include "ProfilingUtils.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Module.h"
#include "llvm/Pass.h"
+#include "llvm/Support/Compiler.h"
#include "llvm/Support/Streams.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Instrumentation.h"
-#include "ProfilingUtils.h"
#include <set>
using namespace llvm;
namespace {
- class EdgeProfiler : public ModulePass {
+ class VISIBILITY_HIDDEN EdgeProfiler : public ModulePass {
bool runOnModule(Module &M);
+ public:
+ static const int ID; // Pass identifcation, replacement for typeid
+ EdgeProfiler() : ModulePass((intptr_t)&ID) {}
};
+ const int EdgeProfiler::ID = 0;
RegisterPass<EdgeProfiler> X("insert-edge-profiling",
"Insert instrumentation for edge profiling");
}
ModulePass *llvm::createEdgeProfilerPass() { return new EdgeProfiler(); }
bool EdgeProfiler::runOnModule(Module &M) {
- Function *Main = M.getMainFunction();
+ Function *Main = M.getFunction("main");
if (Main == 0) {
- llvm_cerr << "WARNING: cannot insert edge profiling into a module"
- << " with no main function!\n";
+ cerr << "WARNING: cannot insert edge profiling into a module"
+ << " with no main function!\n";
return false; // No main, no instrumentation!
}
NumEdges += BB->getTerminator()->getNumSuccessors();
}
- const Type *ATy = ArrayType::get(Type::UIntTy, NumEdges);
+ const Type *ATy = ArrayType::get(Type::Int32Ty, NumEdges);
GlobalVariable *Counters =
new GlobalVariable(ATy, false, GlobalValue::InternalLinkage,
Constant::getNullValue(ATy), "EdgeProfCounters", &M);