Chris Lattner | 6f82d07 | 2003-10-28 19:16:35 +0000 | [diff] [blame] | 1 | //===- llvm-prof.cpp - Read in and process llvmprof.out data files --------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by the LLVM research group and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This tools is meant for use with the various LLVM profiling instrumentation |
| 11 | // passes. It reads in the data file produced by executing an instrumented |
| 12 | // program, and outputs a nice report. |
| 13 | // |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
Chris Lattner | e436779 | 2003-10-28 20:13:07 +0000 | [diff] [blame^] | 16 | #include "ProfileInfo.h" |
Chris Lattner | 6f82d07 | 2003-10-28 19:16:35 +0000 | [diff] [blame] | 17 | #include "llvm/Bytecode/Reader.h" |
| 18 | #include "Support/CommandLine.h" |
Chris Lattner | e436779 | 2003-10-28 20:13:07 +0000 | [diff] [blame^] | 19 | #include <iostream> |
Chris Lattner | 6f82d07 | 2003-10-28 19:16:35 +0000 | [diff] [blame] | 20 | |
| 21 | namespace { |
| 22 | cl::opt<std::string> |
| 23 | BytecodeFile(cl::Positional, cl::desc("<program bytecode file>"), |
| 24 | cl::Required); |
| 25 | |
| 26 | cl::opt<std::string> |
| 27 | ProfileDataFile(cl::Positional, cl::desc("<llvmprof.out file>"), |
| 28 | cl::Optional, cl::init("llvmprof.out")); |
| 29 | } |
| 30 | |
| 31 | int main(int argc, char **argv) { |
| 32 | cl::ParseCommandLineOptions(argc, argv, " llvm profile dump decoder\n"); |
Chris Lattner | 6f82d07 | 2003-10-28 19:16:35 +0000 | [diff] [blame] | 33 | |
Chris Lattner | e436779 | 2003-10-28 20:13:07 +0000 | [diff] [blame^] | 34 | // Read in the bytecode file... |
| 35 | std::string ErrorMessage; |
| 36 | Module *Result = ParseBytecodeFile(BytecodeFile, &ErrorMessage); |
| 37 | if (Result == 0) { |
| 38 | std::cerr << argv[0] << ": " << BytecodeFile << ": " << ErrorMessage |
| 39 | << "\n"; |
| 40 | return 1; |
| 41 | } |
Chris Lattner | 6f82d07 | 2003-10-28 19:16:35 +0000 | [diff] [blame] | 42 | |
Chris Lattner | e436779 | 2003-10-28 20:13:07 +0000 | [diff] [blame^] | 43 | // Read the profiling information |
| 44 | ProfileInfo PI(argv[0], ProfileDataFile); |
Chris Lattner | 6f82d07 | 2003-10-28 19:16:35 +0000 | [diff] [blame] | 45 | |
| 46 | return 0; |
| 47 | } |