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 | e4fd5ed056ccb82b509c52ee0d36e45d14c4787c (patch) | |
tree | 9e4947e1f5f6d73ed117863e8cbc77d1eed237a5 /llvm/lib/ExecutionEngine/JIT/JITMemoryManager.cpp | |
parent | 2fa2a727bb87896474793d725fa9c1b1f6429bf8 (diff) | |
download | bcm5719-llvm-e4fd5ed056ccb82b509c52ee0d36e45d14c4787c.tar.gz bcm5719-llvm-e4fd5ed056ccb82b509c52ee0d36e45d14c4787c.zip |
Fixed alignment of code sections in the JIT mode. Added a test to the JITMemoryManager.
llvm-svn: 185421
Diffstat (limited to 'llvm/lib/ExecutionEngine/JIT/JITMemoryManager.cpp')
-rw-r--r-- | llvm/lib/ExecutionEngine/JIT/JITMemoryManager.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/ExecutionEngine/JIT/JITMemoryManager.cpp b/llvm/lib/ExecutionEngine/JIT/JITMemoryManager.cpp index 6a1db16a6a1..94db2459877 100644 --- a/llvm/lib/ExecutionEngine/JIT/JITMemoryManager.cpp +++ b/llvm/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. |