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/Action.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/Action.cpp')
-rw-r--r-- | llvm/lib/CompilerDriver/Action.cpp | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/llvm/lib/CompilerDriver/Action.cpp b/llvm/lib/CompilerDriver/Action.cpp index 5fd63eefc52..7bcd30a8e0e 100644 --- a/llvm/lib/CompilerDriver/Action.cpp +++ b/llvm/lib/CompilerDriver/Action.cpp @@ -13,9 +13,13 @@ #include "llvm/CompilerDriver/Action.h" #include "llvm/CompilerDriver/BuiltinOptions.h" + #include "llvm/Support/raw_ostream.h" #include "llvm/System/Program.h" +#include "llvm/System/TimeValue.h" + #include <stdexcept> +#include <string> using namespace llvm; using namespace llvmc; @@ -60,14 +64,31 @@ namespace { } } +namespace llvmc { + void AppendToGlobalTimeLog(const std::string& cmd, double time); +} + int llvmc::Action::Execute() const { if (DryRun || VerboseMode) { errs() << Command_ << " "; std::for_each(Args_.begin(), Args_.end(), print_string); errs() << '\n'; } - if (DryRun) - return 0; - else - return ExecuteProgram(Command_, Args_); + if (!DryRun) { + if (Time) { + sys::TimeValue now = sys::TimeValue::now(); + int ret = ExecuteProgram(Command_, Args_); + sys::TimeValue now2 = sys::TimeValue::now(); + now2 -= now; + double elapsed = now2.seconds() + now2.microseconds() / 1000000.0; + AppendToGlobalTimeLog(Command_, elapsed); + + return ret; + } + else { + return ExecuteProgram(Command_, Args_); + } + } + + return 0; } |