Add timing of the IR parsing code with a new -time-ir-parsing flag
authorEli Bendersky <eliben@google.com>
Wed, 20 Mar 2013 17:00:25 +0000 (17:00 +0000)
committerEli Bendersky <eliben@google.com>
Wed, 20 Mar 2013 17:00:25 +0000 (17:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177543 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/IRReader.h
lib/Support/CMakeLists.txt
lib/Support/IRReader.cpp [new file with mode: 0644]

index 6d8a9b30ae1fd8bfee9f0c9b7f6bdceb765a2743..c3ee3ed3182dd4a8c648f418d790cf1146db99e0 100644 (file)
@@ -25,6 +25,7 @@
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/system_error.h"
+#include "llvm/Support/Timer.h"
 
 namespace llvm {
 
@@ -69,6 +70,10 @@ namespace llvm {
     return getLazyIRModule(File.take(), Err, Context);
   }
 
+  extern const char *TimeIRParsingGroupName;
+  extern const char *TimeIRParsingName;
+  extern bool TimeIRParsingIsEnabled;
+
   /// If the given MemoryBuffer holds a bitcode image, return a Module
   /// for it.  Otherwise, attempt to parse it as LLVM Assembly and return
   /// a Module for it. This function *always* takes ownership of the given
@@ -76,6 +81,8 @@ namespace llvm {
   inline Module *ParseIR(MemoryBuffer *Buffer,
                          SMDiagnostic &Err,
                          LLVMContext &Context) {
+    NamedRegionTimer T(TimeIRParsingName, TimeIRParsingGroupName,
+                       TimeIRParsingIsEnabled);
     if (isBitcode((const unsigned char *)Buffer->getBufferStart(),
                   (const unsigned char *)Buffer->getBufferEnd())) {
       std::string ErrMsg;
index 5ba69fc3c8c80173801973efdee2b5f09faa8b06..f661249c76edd7cc5a77122f8c9acfe07930e7d1 100644 (file)
@@ -27,6 +27,7 @@ add_llvm_library(LLVMSupport
   IntEqClasses.cpp
   IntervalMap.cpp
   IntrusiveRefCntPtr.cpp
+  IRReader.cpp
   IsInf.cpp
   IsNAN.cpp
   Locale.cpp
diff --git a/lib/Support/IRReader.cpp b/lib/Support/IRReader.cpp
new file mode 100644 (file)
index 0000000..1dc56dd
--- /dev/null
@@ -0,0 +1,21 @@
+//===- IRReader.cpp - Reader for LLVM IR files ----------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/IRReader.h"
+using namespace llvm;
+
+const char *llvm::TimeIRParsingGroupName = "LLVM IR Parsing";
+const char *llvm::TimeIRParsingName = "Parse IR";
+
+bool llvm::TimeIRParsingIsEnabled = false;
+static cl::opt<bool,true>
+EnableTimeIRParsing("time-ir-parsing", cl::location(TimeIRParsingIsEnabled),
+                    cl::desc("Measure the time IR parsing takes"));
+