diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2013-09-04 14:12:19 +0000 |
---|---|---|
committer | NAKAMURA Takumi <geek4civic@gmail.com> | 2013-09-04 14:12:19 +0000 |
commit | 65fc51bbe29d39a0aae860dc4f1f9e75a800e221 (patch) | |
tree | 8063a33f2c081c143936f6b07cf4aea3898613f0 /llvm/lib | |
parent | 9542678508a686ebe8df29419df9642ddc3ebf61 (diff) | |
download | bcm5719-llvm-65fc51bbe29d39a0aae860dc4f1f9e75a800e221.tar.gz bcm5719-llvm-65fc51bbe29d39a0aae860dc4f1f9e75a800e221.zip |
MemoryBuffer.cpp: Don't peek the next page if file is multiple of *physical* pagesize(4k) but is not multiple of AllocationGranularity(64k), when a null terminator is required, on cygwin and win32.
For example, r189780's SparcISelLowering.cpp has the size 98304. It crashed clang to touch a null terminator on cygwin.
FIXME: It's not good to hardcode 4096 here. dwPageSize shows 4096.
llvm-svn: 189939
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Support/MemoryBuffer.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Support/MemoryBuffer.cpp b/llvm/lib/Support/MemoryBuffer.cpp index 1134f5bb53e..e018ad4ecce 100644 --- a/llvm/lib/Support/MemoryBuffer.cpp +++ b/llvm/lib/Support/MemoryBuffer.cpp @@ -302,6 +302,15 @@ static bool shouldUseMmap(int FD, if (End != FileSize) return false; +#if defined(_WIN32) || defined(__CYGWIN__) + // Don't peek the next page if file is multiple of *physical* pagesize(4k) + // but is not multiple of AllocationGranularity(64k), + // when a null terminator is required. + // FIXME: It's not good to hardcode 4096 here. dwPageSize shows 4096. + if ((FileSize & (4096 - 1)) == 0) + return false; +#endif + // Don't try to map files that are exactly a multiple of the system page size // if we need a null terminator. if ((FileSize & (PageSize -1)) == 0) |