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 | 6533afe349013821c76f244015cdfb5f189b2aa6 (patch) | |
tree | 8f51d6e44f6cedf247dee3f1f7268e3c7146689b /lib/CompilerDriver/Main.cpp | |
parent | c11e84d3e7a432449d453b51b567f2fc5db4e8c0 (diff) |
llvmc: Add a '-time' option.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86348 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CompilerDriver/Main.cpp')
-rw-r--r-- | lib/CompilerDriver/Main.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/CompilerDriver/Main.cpp b/lib/CompilerDriver/Main.cpp index c581809d04..3a3487a0a9 100644 --- a/lib/CompilerDriver/Main.cpp +++ b/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(); |