diff options
| author | Andrew Ng <anng.sw@gmail.com> | 2019-03-27 10:26:21 +0000 |
|---|---|---|
| committer | Andrew Ng <anng.sw@gmail.com> | 2019-03-27 10:26:21 +0000 |
| commit | 2fc69abf5be8b68f5b18c1c690cd185a4fdce472 (patch) | |
| tree | 2ec81ba0f0d8d57b560a8704d25b139b58e12584 /llvm/lib | |
| parent | ccb71b2985a2a5073cedd1d734fb0fc2712d68f0 (diff) | |
| download | bcm5719-llvm-2fc69abf5be8b68f5b18c1c690cd185a4fdce472.tar.gz bcm5719-llvm-2fc69abf5be8b68f5b18c1c690cd185a4fdce472.zip | |
[Support] MemoryBlock size should reflect the requested size
This patch mirrors the change made to the Unix equivalent in
r351916. This in turn fixes bugs related to the use of FileOutputBuffer
to output to "-", i.e. stdout, on Windows.
Differential Revision: https://reviews.llvm.org/D59663
llvm-svn: 357058
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Support/Windows/Memory.inc | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Support/Windows/Memory.inc b/llvm/lib/Support/Windows/Memory.inc index 0e961fdeaad..b1d68596f5c 100644 --- a/llvm/lib/Support/Windows/Memory.inc +++ b/llvm/lib/Support/Windows/Memory.inc @@ -135,8 +135,9 @@ MemoryBlock Memory::allocateMappedMemory(size_t NumBytes, DWORD Protect = getWindowsProtectionFlags(Flags); + size_t AllocSize = NumBlocks * Granularity; void *PA = ::VirtualAlloc(reinterpret_cast<void *>(Start), - NumBlocks * Granularity, AllocType, Protect); + AllocSize, AllocType, Protect); if (PA == NULL) { if (NearBlock || HugePages) { // Try again without the NearBlock hint and without large memory pages @@ -148,11 +149,11 @@ MemoryBlock Memory::allocateMappedMemory(size_t NumBytes, MemoryBlock Result; Result.Address = PA; - Result.Size = NumBlocks*Granularity; + Result.Size = NumBytes; Result.Flags = (Flags & ~MF_HUGE_HINT) | (HugePages ? MF_HUGE_HINT : 0); if (Flags & MF_EXEC) - Memory::InvalidateInstructionCache(Result.Address, Result.Size); + Memory::InvalidateInstructionCache(Result.Address, AllocSize); return Result; } |

