#include "llvm/Bytecode/Reader.h"
#include "llvm/Assembly/Parser.h"
#include "llvm/Analysis/Verifier.h"
+#include "llvm/Target/TargetData.h"
#include "llvm/Support/PassNameParser.h"
+#include "Support/Timer.h"
#include <algorithm>
ModulePassPrinter(const PassInfo *PI) : PassToPrint(PI) {}
virtual bool run(Module &M) {
- std::cout << "Printing Analysis info for Pass "
- << PassToPrint->getPassName() << ":\n";
+ std::cout << "Printing analysis '" << PassToPrint->getPassName() << "':\n";
getAnalysisID<Pass>(PassToPrint).print(std::cout, &M);
// Get and print pass...
return false;
}
+
+ virtual const char *getPassName() const { return "'Pass' Printer"; }
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequiredID(PassToPrint);
FunctionPassPrinter(const PassInfo *PI) : PassToPrint(PI) {}
virtual bool runOnFunction(Function &F) {
- std::cout << "Printing Analysis info for function '" << F.getName()
- << "': Pass " << PassToPrint->getPassName() << ":\n";
+ std::cout << "Printing analysis '" << PassToPrint->getPassName()
+ << "' for function '" << F.getName() << "':\n";
getAnalysisID<Pass>(PassToPrint).print(std::cout, F.getParent());
// Get and print pass...
return false;
}
+ virtual const char *getPassName() const { return "FunctionPass Printer"; }
+
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequiredID(PassToPrint);
AU.setPreservesAll();
return false;
}
+ virtual const char *getPassName() const { return "BasicBlockPass Printer"; }
+
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequiredID(PassToPrint);
AU.setPreservesAll();
AnalysesList(cl::desc("Analyses available:"));
+static Timer BytecodeLoadTimer("Bytecode Loader");
+
int main(int argc, char **argv) {
cl::ParseCommandLineOptions(argc, argv, " llvm analysis printer tool\n");
Module *CurMod = 0;
try {
+#if 0
+ TimeRegion RegionTimer(BytecodeLoadTimer);
+#endif
CurMod = ParseBytecodeFile(InputFilename);
if (!CurMod && !(CurMod = ParseAssemblyFile(InputFilename))){
std::cerr << argv[0] << ": input file didn't read correctly.\n";
//
PassManager Passes;
+ // Add an appropriate TargetData instance for this module...
+ Passes.add(new TargetData("analyze", CurMod));
+
// Make sure the input LLVM is well formed.
Passes.add(createVerifierPass());