<div dir="ltr">Eli, I have to revert this. It completely breaks the layering of LLVM. It's not really your fault, but we can't actually add an implementation to IRReader without immediately causing essentially unsolvable layering issues.<div>
<br></div><div>Specifically, IRReader.h contains inline code that directly interfaces with interfaces in the AsmParser library and the BitcodeReader library. Including it into a source file in the Support library breaks many things.</div>
<div><br></div><div style>Should IRReader.h be in the Support library at all? Absolutely not. But currently we don't have a library that is really well suited to this -- it has to depend on IR, AsmParser, and BitcodeReader.</div>
<div style><br></div><div style>My best idea of how to fix this is to create a new library which exists in this slice of the library layering. If anyone has ideas about the name of that library, I'm all ears.</div></div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Mar 20, 2013 at 10:00 AM, Eli Bendersky <span dir="ltr"><<a href="mailto:eliben@google.com" target="_blank">eliben@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: eliben<br>
Date: Wed Mar 20 12:00:25 2013<br>
New Revision: 177543<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=177543&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=177543&view=rev</a><br>
Log:<br>
Add timing of the IR parsing code with a new -time-ir-parsing flag<br>
<br>
Added:<br>
    llvm/trunk/lib/Support/IRReader.cpp<br>
Modified:<br>
    llvm/trunk/include/llvm/Support/IRReader.h<br>
    llvm/trunk/lib/Support/CMakeLists.txt<br>
<br>
Modified: llvm/trunk/include/llvm/Support/IRReader.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRReader.h?rev=177543&r1=177542&r2=177543&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRReader.h?rev=177543&r1=177542&r2=177543&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/include/llvm/Support/IRReader.h (original)<br>
+++ llvm/trunk/include/llvm/Support/IRReader.h Wed Mar 20 12:00:25 2013<br>
@@ -25,6 +25,7 @@<br>
 #include "llvm/Support/MemoryBuffer.h"<br>
 #include "llvm/Support/SourceMgr.h"<br>
 #include "llvm/Support/system_error.h"<br>
+#include "llvm/Support/Timer.h"<br>
<br>
 namespace llvm {<br>
<br>
@@ -69,6 +70,10 @@ namespace llvm {<br>
     return getLazyIRModule(File.take(), Err, Context);<br>
   }<br>
<br>
+  extern const char *TimeIRParsingGroupName;<br>
+  extern const char *TimeIRParsingName;<br>
+  extern bool TimeIRParsingIsEnabled;<br>
+<br>
   /// If the given MemoryBuffer holds a bitcode image, return a Module<br>
   /// for it.  Otherwise, attempt to parse it as LLVM Assembly and return<br>
   /// a Module for it. This function *always* takes ownership of the given<br>
@@ -76,6 +81,8 @@ namespace llvm {<br>
   inline Module *ParseIR(MemoryBuffer *Buffer,<br>
                          SMDiagnostic &Err,<br>
                          LLVMContext &Context) {<br>
+    NamedRegionTimer T(TimeIRParsingName, TimeIRParsingGroupName,<br>
+                       TimeIRParsingIsEnabled);<br>
     if (isBitcode((const unsigned char *)Buffer->getBufferStart(),<br>
                   (const unsigned char *)Buffer->getBufferEnd())) {<br>
       std::string ErrMsg;<br>
<br>
Modified: llvm/trunk/lib/Support/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CMakeLists.txt?rev=177543&r1=177542&r2=177543&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CMakeLists.txt?rev=177543&r1=177542&r2=177543&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/Support/CMakeLists.txt (original)<br>
+++ llvm/trunk/lib/Support/CMakeLists.txt Wed Mar 20 12:00:25 2013<br>
@@ -27,6 +27,7 @@ add_llvm_library(LLVMSupport<br>
   IntEqClasses.cpp<br>
   IntervalMap.cpp<br>
   IntrusiveRefCntPtr.cpp<br>
+  IRReader.cpp<br>
   IsInf.cpp<br>
   IsNAN.cpp<br>
   Locale.cpp<br>
<br>
Added: llvm/trunk/lib/Support/IRReader.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/IRReader.cpp?rev=177543&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/IRReader.cpp?rev=177543&view=auto</a><br>

==============================================================================<br>
--- llvm/trunk/lib/Support/IRReader.cpp (added)<br>
+++ llvm/trunk/lib/Support/IRReader.cpp Wed Mar 20 12:00:25 2013<br>
@@ -0,0 +1,21 @@<br>
+//===- IRReader.cpp - Reader for LLVM IR files ----------------------------===//<br>
+//<br>
+//                     The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#include "llvm/Support/CommandLine.h"<br>
+#include "llvm/Support/IRReader.h"<br>
+using namespace llvm;<br>
+<br>
+const char *llvm::TimeIRParsingGroupName = "LLVM IR Parsing";<br>
+const char *llvm::TimeIRParsingName = "Parse IR";<br>
+<br>
+bool llvm::TimeIRParsingIsEnabled = false;<br>
+static cl::opt<bool,true><br>
+EnableTimeIRParsing("time-ir-parsing", cl::location(TimeIRParsingIsEnabled),<br>
+                    cl::desc("Measure the time IR parsing takes"));<br>
+<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>