diff options
author | Elena Demikhovsky <elena.demikhovsky@intel.com> | 2013-07-02 12:24:22 +0000 |
---|---|---|
committer | Elena Demikhovsky <elena.demikhovsky@intel.com> | 2013-07-02 12:24:22 +0000 |
commit | e5cb25f860bb4ffe6908004e6a04c8d21b7d2a98 (patch) | |
tree | 00f740190ad1b479885620660783fbd6efccce31 /lib/ExecutionEngine/JIT | |
parent | 5bce67a95feb136389ca630cc5dd6a81e97ff1eb (diff) | |
download | llvm-e5cb25f860bb4ffe6908004e6a04c8d21b7d2a98.tar.gz llvm-e5cb25f860bb4ffe6908004e6a04c8d21b7d2a98.tar.bz2 llvm-e5cb25f860bb4ffe6908004e6a04c8d21b7d2a98.tar.xz |
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
Diffstat (limited to 'lib/ExecutionEngine/JIT')
-rw-r--r-- | lib/ExecutionEngine/JIT/JITMemoryManager.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/ExecutionEngine/JIT/JITMemoryManager.cpp b/lib/ExecutionEngine/JIT/JITMemoryManager.cpp index 6a1db16a6a..94db245987 100644 --- a/lib/ExecutionEngine/JIT/JITMemoryManager.cpp +++ b/lib/ExecutionEngine/JIT/JITMemoryManager.cpp @@ -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. |