[llvm] r177543 - Add timing of the IR parsing code with a new -time-ir-parsing flag

Chandler Carruth chandlerc at google.com
Thu Mar 21 19:16:58 PDT 2013


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.

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.

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.

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.


On Wed, Mar 20, 2013 at 10:00 AM, Eli Bendersky <eliben at google.com> wrote:

> Author: eliben
> Date: Wed Mar 20 12:00:25 2013
> New Revision: 177543
>
> URL: http://llvm.org/viewvc/llvm-project?rev=177543&view=rev
> Log:
> Add timing of the IR parsing code with a new -time-ir-parsing flag
>
> Added:
>     llvm/trunk/lib/Support/IRReader.cpp
> Modified:
>     llvm/trunk/include/llvm/Support/IRReader.h
>     llvm/trunk/lib/Support/CMakeLists.txt
>
> Modified: llvm/trunk/include/llvm/Support/IRReader.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRReader.h?rev=177543&r1=177542&r2=177543&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/Support/IRReader.h (original)
> +++ llvm/trunk/include/llvm/Support/IRReader.h Wed Mar 20 12:00:25 2013
> @@ -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;
>
> Modified: llvm/trunk/lib/Support/CMakeLists.txt
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CMakeLists.txt?rev=177543&r1=177542&r2=177543&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Support/CMakeLists.txt (original)
> +++ llvm/trunk/lib/Support/CMakeLists.txt Wed Mar 20 12:00:25 2013
> @@ -27,6 +27,7 @@ add_llvm_library(LLVMSupport
>    IntEqClasses.cpp
>    IntervalMap.cpp
>    IntrusiveRefCntPtr.cpp
> +  IRReader.cpp
>    IsInf.cpp
>    IsNAN.cpp
>    Locale.cpp
>
> Added: llvm/trunk/lib/Support/IRReader.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/IRReader.cpp?rev=177543&view=auto
>
> ==============================================================================
> --- llvm/trunk/lib/Support/IRReader.cpp (added)
> +++ llvm/trunk/lib/Support/IRReader.cpp Wed Mar 20 12:00:25 2013
> @@ -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"));
> +
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130321/38c18bf4/attachment.html>


More information about the llvm-commits mailing list