[llvm] r185421 - Fixed alignment of code sections in the JIT mode. Added a test to the JITMemoryManager.
Demikhovsky, Elena
elena.demikhovsky at intel.com
Tue Jul 2 23:57:09 PDT 2013
Hi David,
I'll set
svn:eol-style LF
it should resolve the problem of line endings.
As far as Clang compilation, I work on Windows. Can you suggest me something?
Thank you for fixing the issues.
- Elena
-----Original Message-----
From: David Blaikie [mailto:dblaikie at gmail.com]
Sent: Tuesday, July 02, 2013 19:51
To: Demikhovsky, Elena
Cc: llvm-commits at cs.uiuc.edu
Subject: Re: [llvm] r185421 - Fixed alignment of code sections in the JIT mode. Added a test to the JITMemoryManager.
On Tue, Jul 2, 2013 at 5:24 AM, Elena Demikhovsky <elena.demikhovsky at intel.com> wrote:
> Author: delena
> Date: Tue Jul 2 07:24:22 2013
> New Revision: 185421
>
> URL: http://llvm.org/viewvc/llvm-project?rev=185421&view=rev
> Log:
> Fixed alignment of code sections in the JIT mode. Added a test to the JITMemoryManager.
>
> Modified:
> llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp
> llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp
>
> Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT
> /JITMemoryManager.cpp?rev=185421&r1=185420&r2=185421&view=diff
> ======================================================================
> ========
> --- llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp (original)
> +++ llvm/trunk/lib/ExecutionEngine/JIT/JITMemoryManager.cpp Tue Jul 2
> +++ 07:24:22 2013
> @@ -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.
>
> Modified:
> llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngi
> ne/JIT/JITMemoryManagerTest.cpp?rev=185421&r1=185420&r2=185421&view=di
> ff
> ======================================================================
> ========
> --- llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp
> (original)
> +++ llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp
> +++ Tue Jul 2 07:24:22 2013
> @@ -277,4 +277,27 @@ TEST(JITMemoryManagerTest, TestManyStubs
> EXPECT_EQ(3U, MemMgr->GetNumStubSlabs()); }
>
> +// Check section allocation and alignment TEST(JITMemoryManagerTest,
> +AllocateSection) {
> + OwningPtr<JITMemoryManager> MemMgr(
> + JITMemoryManager::CreateDefaultMemManager());
> + uint8_t *code1 = MemMgr->allocateCodeSection(256, 0, 1);
> + uint8_t *data1 = MemMgr->allocateDataSection(256, 16, 2, true);
> + uint8_t *code2 = MemMgr->allocateCodeSection(257, 32, 3);
> + uint8_t *data2 = MemMgr->allocateDataSection(256, 64, 4, false);
> + uint8_t *code3 = MemMgr->allocateCodeSection(258, 64, 5);
> +
> + EXPECT_NE((uint8_t*)0, code1);
> + EXPECT_NE((uint8_t*)0, code2);
> + EXPECT_NE((uint8_t*)0, data1);
> + EXPECT_NE((uint8_t*)0, data2);
> +
> + // Check alignment
> + EXPECT_EQ((uint64_t)code1 & 0xf, 0);
> + EXPECT_EQ((uint64_t)code2 & 0x1f, 0);
> + EXPECT_EQ((uint64_t)code3 & 0x3f, 0);
> + EXPECT_EQ((uint64_t)data1 & 0xf, 0);
> + EXPECT_EQ((uint64_t)data2 & 0x3f, 0);
These EXPECTs caused -Werror build breaks with Clang due to -Wsign-compare. I've fixed them (& removed several windows-style line breaks introduced by this commit) in r185443. It's helpful to build with Clang and -Werror before committing as other people do in an effort to keep the build warning-clean. Also please check your svn configuration to ensure it doesn't commit windows-style line endings in the future.
- David
> +}
> +
> }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
---------------------------------------------------------------------
Intel Israel (74) Limited
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
More information about the llvm-commits
mailing list