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 /unittests | |
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 'unittests')
-rw-r--r-- | unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp b/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp index 21ca0d448c..c06b89cf43 100644 --- a/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp +++ b/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp @@ -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);
+} + } |