diff options
author | Mikhail Glushenkov <foldr@codedgers.com> | 2009-11-07 06:33:58 +0000 |
---|---|---|
committer | Mikhail Glushenkov <foldr@codedgers.com> | 2009-11-07 06:33:58 +0000 |
commit | 0fa9474836fb7d2a4bf7ad24c5868bad97e7feb8 (patch) | |
tree | c1cc56470af95ccaa924563a60bf13f8a52626f0 /llvm/lib/CompilerDriver/Main.cpp | |
parent | 358607dfa3f7d59f78024393828631bc34b2a94c (diff) | |
download | bcm5719-llvm-0fa9474836fb7d2a4bf7ad24c5868bad97e7feb8.tar.gz bcm5719-llvm-0fa9474836fb7d2a4bf7ad24c5868bad97e7feb8.zip |
llvmc: Add a '-time' option.
llvm-svn: 86348
Diffstat (limited to 'llvm/lib/CompilerDriver/Main.cpp')
-rw-r--r-- | llvm/lib/CompilerDriver/Main.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/llvm/lib/CompilerDriver/Main.cpp b/llvm/lib/CompilerDriver/Main.cpp index c581809d04b..3a3487a0a9c 100644 --- a/llvm/lib/CompilerDriver/Main.cpp +++ b/llvm/lib/CompilerDriver/Main.cpp @@ -19,6 +19,7 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/System/Path.h" +#include <sstream> #include <stdexcept> #include <string> @@ -28,6 +29,8 @@ using namespace llvmc; namespace { + std::stringstream* GlobalTimeLog; + sys::Path getTempDir() { sys::Path tempDir; @@ -81,6 +84,11 @@ namespace { namespace llvmc { +// Used to implement -time option. External linkage is intentional. +void AppendToGlobalTimeLog(const std::string& cmd, double time) { + *GlobalTimeLog << "# " << cmd << ' ' << time << '\n'; +} + // Sometimes plugins want to condition on the value in argv[0]. const char* ProgramName; @@ -122,7 +130,19 @@ int Main(int argc, char** argv) { throw std::runtime_error("no input files"); } - return BuildTargets(graph, langMap); + if (Time) { + GlobalTimeLog = new std::stringstream; + GlobalTimeLog->precision(2); + } + + int ret = BuildTargets(graph, langMap); + + if (Time) { + llvm::errs() << GlobalTimeLog->str(); + delete GlobalTimeLog; + } + + return ret; } catch(llvmc::error_code& ec) { return ec.code(); |