mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-03 17:24:24 +00:00
Port lli bug fix from r166920 to MCJIT unit test.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167145 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9f74bc9e77
commit
a25ad19a23
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include "llvm/Config/config.h"
|
#include "llvm/Config/config.h"
|
||||||
#include "llvm/Support/DynamicLibrary.h"
|
#include "llvm/Support/DynamicLibrary.h"
|
||||||
|
#include "llvm/Support/MathExtras.h"
|
||||||
|
|
||||||
#include "SectionMemoryManager.h"
|
#include "SectionMemoryManager.h"
|
||||||
|
|
||||||
@ -34,9 +35,16 @@ uint8_t *SectionMemoryManager::allocateDataSection(uintptr_t Size,
|
|||||||
unsigned SectionID) {
|
unsigned SectionID) {
|
||||||
if (!Alignment)
|
if (!Alignment)
|
||||||
Alignment = 16;
|
Alignment = 16;
|
||||||
uint8_t *Addr = (uint8_t*)calloc((Size + Alignment - 1)/Alignment, Alignment);
|
// Ensure that enough memory is requested to allow aligning.
|
||||||
AllocatedDataMem.push_back(sys::MemoryBlock(Addr, Size));
|
size_t NumElementsAligned = 1 + (Size + Alignment - 1)/Alignment;
|
||||||
return Addr;
|
uint8_t *Addr = (uint8_t*)calloc(NumElementsAligned, Alignment);
|
||||||
|
|
||||||
|
// Honour the alignment requirement.
|
||||||
|
uint8_t *AlignedAddr = (uint8_t*)RoundUpToAlignment((uint64_t)Addr, Alignment);
|
||||||
|
|
||||||
|
// Store the original address from calloc so we can free it later.
|
||||||
|
AllocatedDataMem.push_back(sys::MemoryBlock(Addr, NumElementsAligned*Alignment));
|
||||||
|
return AlignedAddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *SectionMemoryManager::allocateCodeSection(uintptr_t Size,
|
uint8_t *SectionMemoryManager::allocateCodeSection(uintptr_t Size,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user