[llvm] r214681 - MemoryBuffer: Don't use mmap when FileSize is multiple of 4k on Cygwin.

NAKAMURA Takumi geek4civic at gmail.com
Sun Aug 3 18:43:37 PDT 2014


Author: chapuni
Date: Sun Aug  3 20:43:37 2014
New Revision: 214681

URL: http://llvm.org/viewvc/llvm-project?rev=214681&view=rev
Log:
MemoryBuffer: Don't use mmap when FileSize is multiple of 4k on Cygwin.

On Cygwin, getpagesize() returns 64k(AllocationGranularity).

In r214580, the size of X86GenInstrInfo.inc became 1499136.

FIXME: We should reorganize again getPageSize() on Win32.
MapFile allocates address along AllocationGranularity but view is mapped by physical page.

Modified:
    llvm/trunk/lib/Support/MemoryBuffer.cpp

Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=214681&r1=214680&r2=214681&view=diff
==============================================================================
--- llvm/trunk/lib/Support/MemoryBuffer.cpp (original)
+++ llvm/trunk/lib/Support/MemoryBuffer.cpp Sun Aug  3 20:43:37 2014
@@ -305,6 +305,14 @@ static bool shouldUseMmap(int FD,
   if ((FileSize & (PageSize -1)) == 0)
     return false;
 
+#if defined(__CYGWIN__)
+  // Don't try to map files that are exactly a multiple of the physical page size
+  // if we need a null terminator.
+  // FIXME: We should reorganize again getPageSize() on Win32.
+  if ((FileSize & (4096 - 1)) == 0)
+    return false;
+#endif
+
   return true;
 }
 





More information about the llvm-commits mailing list