[llvm-commits] [llvm] r130432 - in /llvm/trunk: include/llvm/Support/MemoryBuffer.h lib/Support/MemoryBuffer.cpp
Ted Kremenek
kremenek at apple.com
Thu Apr 28 13:34:18 PDT 2011
Author: kremenek
Date: Thu Apr 28 15:34:18 2011
New Revision: 130432
URL: http://llvm.org/viewvc/llvm-project?rev=130432&view=rev
Log:
Add MemoryBuffer::getBufferKind() to report whether a memory buffer uses malloc'ed or mmap'ed memory. This is for performance analysis.
Modified:
llvm/trunk/include/llvm/Support/MemoryBuffer.h
llvm/trunk/lib/Support/MemoryBuffer.cpp
Modified: llvm/trunk/include/llvm/Support/MemoryBuffer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MemoryBuffer.h?rev=130432&r1=130431&r2=130432&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/MemoryBuffer.h (original)
+++ llvm/trunk/include/llvm/Support/MemoryBuffer.h Thu Apr 28 15:34:18 2011
@@ -119,6 +119,21 @@
static error_code getFileOrSTDIN(const char *Filename,
OwningPtr<MemoryBuffer> &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
Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=130432&r1=130431&r2=130432&view=diff
==============================================================================
--- llvm/trunk/lib/Support/MemoryBuffer.cpp (original)
+++ llvm/trunk/lib/Support/MemoryBuffer.cpp Thu Apr 28 15:34:18 2011
@@ -86,6 +86,10 @@
// The name is stored after the class itself.
return reinterpret_cast<const char*>(this + 1);
}
+
+ virtual BufferKind getBufferKind() const {
+ return MemoryBuffer_Malloc;
+ }
};
}
@@ -191,6 +195,10 @@
sys::Path::UnMapFilePages(reinterpret_cast<const char*>(RealStart),
RealSize);
}
+
+ virtual BufferKind getBufferKind() const {
+ return MemoryBuffer_MMap;
+ }
};
}
More information about the llvm-commits
mailing list