1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-02-01 05:01:59 +01:00

Add MemoryBuffer::getBufferKind() to report whether a memory buffer uses malloc'ed or mmap'ed memory. This is for performance analysis.

llvm-svn: 130432
This commit is contained in:
Ted Kremenek 2011-04-28 20:34:18 +00:00
parent 5e9ca7876e
commit 16f206d185
2 changed files with 23 additions and 0 deletions

View File

@ -119,6 +119,21 @@ public:
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

View File

@ -86,6 +86,10 @@ public:
// 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 @@ public:
sys::Path::UnMapFilePages(reinterpret_cast<const char*>(RealStart),
RealSize);
}
virtual BufferKind getBufferKind() const {
return MemoryBuffer_MMap;
}
};
}