| OLD | NEW |
| 1 //===-- pnacl-benchmark.cpp -----------------------------------------------===// | 1 //===-- pnacl-benchmark.cpp -----------------------------------------------===// |
| 2 // | 2 // |
| 3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 // | 9 // |
| 10 // pnacl-benchmark: various benchmarking tools for the PNaCl LLVM toolchain. | 10 // pnacl-benchmark: various benchmarking tools for the PNaCl LLVM toolchain. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 using namespace llvm; | 39 using namespace llvm; |
| 40 | 40 |
| 41 | 41 |
| 42 static cl::opt<std::string> | 42 static cl::opt<std::string> |
| 43 InputFilename(cl::Positional, cl::desc("<input bitcode>"), cl::init("-")); | 43 InputFilename(cl::Positional, cl::desc("<input bitcode>"), cl::init("-")); |
| 44 | 44 |
| 45 static cl::opt<unsigned> | 45 static cl::opt<unsigned> |
| 46 NumRuns("num-runs", cl::desc("Number of runs"), cl::init(1)); | 46 NumRuns("num-runs", cl::desc("Number of runs"), cl::init(1)); |
| 47 | 47 |
| 48 static cl::opt<bool> |
| 49 VerboseErrors( |
| 50 "verbose-parse-errors", |
| 51 cl::desc("Print out more descriptive PNaCl bitcode parse errors"), |
| 52 cl::init(false)); |
| 53 |
| 48 /// Used in a lexical block to measure and report the block's execution time. | 54 /// Used in a lexical block to measure and report the block's execution time. |
| 49 /// | 55 /// |
| 50 /// \param N block name | 56 /// \param N block name |
| 51 /// \param InputSize optional size of input operated upon. If given, the | 57 /// \param InputSize optional size of input operated upon. If given, the |
| 52 /// throughput will be reported as well in MB/sec. | 58 /// throughput will be reported as well in MB/sec. |
| 53 class TimingOperationBlock { | 59 class TimingOperationBlock { |
| 54 public: | 60 public: |
| 55 TimingOperationBlock(StringRef N, size_t InputSize=0) | 61 TimingOperationBlock(StringRef N, size_t InputSize=0) |
| 56 : InputSize(InputSize) { | 62 : InputSize(InputSize) { |
| 57 outs() << "Timing: " << N << "... "; | 63 outs() << "Timing: " << N << "... "; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 TimingOperationBlock T("Running bitcode analysis", BufSize); | 201 TimingOperationBlock T("Running bitcode analysis", BufSize); |
| 196 | 202 |
| 197 AnalysisDumpOptions DumpOptions; | 203 AnalysisDumpOptions DumpOptions; |
| 198 AnalyzeBitcodeInBuffer(FileBuf, nulls(), DumpOptions); | 204 AnalyzeBitcodeInBuffer(FileBuf, nulls(), DumpOptions); |
| 199 } | 205 } |
| 200 | 206 |
| 201 // Actual LLVM IR parsing and formation from the bitcode | 207 // Actual LLVM IR parsing and formation from the bitcode |
| 202 { | 208 { |
| 203 TimingOperationBlock T("LLVM IR parsing", BufSize); | 209 TimingOperationBlock T("LLVM IR parsing", BufSize); |
| 204 SMDiagnostic Err; | 210 SMDiagnostic Err; |
| 211 raw_ostream *Verbose = VerboseErrors ? &errs() : nullptr; |
| 205 Module *M = NaClParseIRFile(InputFilename, PNaClFormat, | 212 Module *M = NaClParseIRFile(InputFilename, PNaClFormat, |
| 206 Err, getGlobalContext()); | 213 Err, Verbose, getGlobalContext()); |
| 207 | 214 |
| 208 if (!M) { | 215 if (!M) { |
| 209 report_fatal_error("Unable to NaClParseIRFile"); | 216 report_fatal_error("Unable to NaClParseIRFile"); |
| 210 } | 217 } |
| 211 } | 218 } |
| 212 } | 219 } |
| 213 | 220 |
| 214 int main(int argc, char **argv) { | 221 int main(int argc, char **argv) { |
| 215 sys::PrintStackTraceOnErrorSignal(); | 222 sys::PrintStackTraceOnErrorSignal(); |
| 216 PrettyStackTraceProgram X(argc, argv); | 223 PrettyStackTraceProgram X(argc, argv); |
| 217 | 224 |
| 218 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. | 225 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. |
| 219 cl::ParseCommandLineOptions(argc, argv, "pnacl-benchmark\n"); | 226 cl::ParseCommandLineOptions(argc, argv, "pnacl-benchmark\n"); |
| 220 | 227 |
| 221 for (unsigned i = 0; i < NumRuns; i++) { | 228 for (unsigned i = 0; i < NumRuns; i++) { |
| 222 BenchmarkIRParsing(); | 229 BenchmarkIRParsing(); |
| 223 } | 230 } |
| 224 | 231 |
| 225 return 0; | 232 return 0; |
| 226 } | 233 } |
| OLD | NEW |