forked from OSchip/llvm-project
Add timing of the IR parsing code with a new -time-ir-parsing flag
llvm-svn: 177543
This commit is contained in:
parent
2bb719f3a9
commit
83b359d4c8
|
@ -25,6 +25,7 @@
|
||||||
#include "llvm/Support/MemoryBuffer.h"
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
#include "llvm/Support/SourceMgr.h"
|
#include "llvm/Support/SourceMgr.h"
|
||||||
#include "llvm/Support/system_error.h"
|
#include "llvm/Support/system_error.h"
|
||||||
|
#include "llvm/Support/Timer.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
|
@ -69,6 +70,10 @@ namespace llvm {
|
||||||
return getLazyIRModule(File.take(), Err, Context);
|
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
|
/// If the given MemoryBuffer holds a bitcode image, return a Module
|
||||||
/// for it. Otherwise, attempt to parse it as LLVM Assembly and return
|
/// for it. Otherwise, attempt to parse it as LLVM Assembly and return
|
||||||
/// a Module for it. This function *always* takes ownership of the given
|
/// a Module for it. This function *always* takes ownership of the given
|
||||||
|
@ -76,6 +81,8 @@ namespace llvm {
|
||||||
inline Module *ParseIR(MemoryBuffer *Buffer,
|
inline Module *ParseIR(MemoryBuffer *Buffer,
|
||||||
SMDiagnostic &Err,
|
SMDiagnostic &Err,
|
||||||
LLVMContext &Context) {
|
LLVMContext &Context) {
|
||||||
|
NamedRegionTimer T(TimeIRParsingName, TimeIRParsingGroupName,
|
||||||
|
TimeIRParsingIsEnabled);
|
||||||
if (isBitcode((const unsigned char *)Buffer->getBufferStart(),
|
if (isBitcode((const unsigned char *)Buffer->getBufferStart(),
|
||||||
(const unsigned char *)Buffer->getBufferEnd())) {
|
(const unsigned char *)Buffer->getBufferEnd())) {
|
||||||
std::string ErrMsg;
|
std::string ErrMsg;
|
||||||
|
|
|
@ -27,6 +27,7 @@ add_llvm_library(LLVMSupport
|
||||||
IntEqClasses.cpp
|
IntEqClasses.cpp
|
||||||
IntervalMap.cpp
|
IntervalMap.cpp
|
||||||
IntrusiveRefCntPtr.cpp
|
IntrusiveRefCntPtr.cpp
|
||||||
|
IRReader.cpp
|
||||||
IsInf.cpp
|
IsInf.cpp
|
||||||
IsNAN.cpp
|
IsNAN.cpp
|
||||||
Locale.cpp
|
Locale.cpp
|
||||||
|
|
|
@ -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"));
|
||||||
|
|
Loading…
Reference in New Issue