Fixed alignment of code sections in the JIT mode. Added a test to the JITMemoryManager.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185421 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Elena Demikhovsky
2013-07-02 12:24:22 +00:00
parent 5bce67a95f
commit e5cb25f860
2 changed files with 30 additions and 2 deletions

View File

@ -468,7 +468,11 @@ namespace {
// Grow the required block size to account for the block header
Size += sizeof(*CurBlock);
// FIXME: Alignement handling.
// Alignment handling.
if (!Alignment)
Alignment = 16;
Size += Alignment - 1;
FreeRangeHeader* candidateBlock = FreeMemoryList;
FreeRangeHeader* head = FreeMemoryList;
FreeRangeHeader* iter = head->Next;
@ -500,7 +504,8 @@ namespace {
FreeMemoryList = candidateBlock->AllocateBlock();
// Release the memory at the end of this block that isn't needed.
FreeMemoryList = CurBlock->TrimAllocationToSize(FreeMemoryList, Size);
return (uint8_t *)(CurBlock + 1);
uintptr_t unalignedAddr = (uintptr_t)CurBlock + sizeof(*CurBlock);
return (uint8_t*)RoundUpToAlignment((uint64_t)unalignedAddr, Alignment);
}
/// allocateDataSection - Allocate memory for a data section.