[PATCH] D39263: [support] remove tautological comparison in Support/Windows/Path.inc

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 24 17:07:32 PDT 2017


zturner added a comment.

Let me know if this is correct.  I think we can actually get (potentially very large) savings from this.



================
Comment at: llvm/lib/Support/Windows/Path.inc:741-742
       ::CreateFileMappingW(FileHandle, 0, flprotect,
                            (Offset + Size) >> 32,
                            (Offset + Size) & 0xffffffff,
                            0);
----------------
I don't think we need `Offset` as part of this calculation.  If we want to map 32 bytes starting at offset 32, the current code will create a file mapping object with a maximum size of 64.  This doesn't seem necessary.  It should be creating a file mapping object of exactly 32 bytes, just like we requested.  So, I propose changing this line to:  `CreateFileMappingW(FileHandle, 0, flprotect, Size >> 32, Size & 0xFFFFFFFF);`


================
Comment at: llvm/lib/Support/Windows/Path.inc:755-759
   Mapping = ::MapViewOfFile(FileMappingHandle,
                             dwDesiredAccess,
                             Offset >> 32,
                             Offset & 0xffffffff,
                             Size);
----------------
This part does not need to be changed.  because the "View" is a disconnected entity from the "Mapping", This will map `Size` bytes from file offset `Offset` into offset 0 of the mapping object.

This is no different from what happened before, except that before our mapping object would just get a ton of unnecessary bytes allocated at the end of it.


https://reviews.llvm.org/D39263





More information about the llvm-commits mailing list