From: Ted Kremenek Date: Thu, 28 Apr 2011 20:34:18 +0000 (+0000) Subject: Add MemoryBuffer::getBufferKind() to report whether a memory buffer uses malloc'ed... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=5d86759e0ff44e07ead4982673fe10abec50f765;p=oota-llvm.git Add MemoryBuffer::getBufferKind() to report whether a memory buffer uses malloc'ed or mmap'ed memory. This is for performance analysis. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130432 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Support/MemoryBuffer.h b/include/llvm/Support/MemoryBuffer.h index 9a2aff04c7f..d912e86c8b4 100644 --- a/include/llvm/Support/MemoryBuffer.h +++ b/include/llvm/Support/MemoryBuffer.h @@ -119,6 +119,21 @@ public: static error_code getFileOrSTDIN(const char *Filename, OwningPtr &result, int64_t FileSize = -1); + + + //===--------------------------------------------------------------------===// + // Provided for performance analysis. + //===--------------------------------------------------------------------===// + + /// The kind of memory backing used to support the MemoryBuffer. + enum BufferKind { + MemoryBuffer_Malloc, + MemoryBuffer_MMap + }; + + /// Return information on the memory mechanism used to support the + /// MemoryBuffer. + virtual BufferKind getBufferKind() const = 0; }; } // end namespace llvm diff --git a/lib/Support/MemoryBuffer.cpp b/lib/Support/MemoryBuffer.cpp index ea72720b7f0..e2b5b7a5852 100644 --- a/lib/Support/MemoryBuffer.cpp +++ b/lib/Support/MemoryBuffer.cpp @@ -86,6 +86,10 @@ public: // The name is stored after the class itself. return reinterpret_cast(this + 1); } + + virtual BufferKind getBufferKind() const { + return MemoryBuffer_Malloc; + } }; } @@ -191,6 +195,10 @@ public: sys::Path::UnMapFilePages(reinterpret_cast(RealStart), RealSize); } + + virtual BufferKind getBufferKind() const { + return MemoryBuffer_MMap; + } }; }