llvm.org GIT mirror llvm / a25ad19
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 Amara Emerson 7 years ago
1 changed file(s) with 11 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
1313
1414 #include "llvm/Config/config.h"
1515 #include "llvm/Support/DynamicLibrary.h"
16 #include "llvm/Support/MathExtras.h"
1617
1718 #include "SectionMemoryManager.h"
1819
3334 unsigned SectionID) {
3435 if (!Alignment)
3536 Alignment = 16;
36 uint8_t *Addr = (uint8_t*)calloc((Size + Alignment - 1)/Alignment, Alignment);
37 AllocatedDataMem.push_back(sys::MemoryBlock(Addr, Size));
38 return Addr;
37 // Ensure that enough memory is requested to allow aligning.
38 size_t NumElementsAligned = 1 + (Size + Alignment - 1)/Alignment;
39 uint8_t *Addr = (uint8_t*)calloc(NumElementsAligned, Alignment);
40
41 // Honour the alignment requirement.
42 uint8_t *AlignedAddr = (uint8_t*)RoundUpToAlignment((uint64_t)Addr, Alignment);
43
44 // Store the original address from calloc so we can free it later.
45 AllocatedDataMem.push_back(sys::MemoryBlock(Addr, NumElementsAligned*Alignment));
46 return AlignedAddr;
3947 }
4048
4149 uint8_t *SectionMemoryManager::allocateCodeSection(uintptr_t Size,