summaryrefslogtreecommitdiff
path: root/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp')
-rw-r--r--unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp b/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp
index 0061e30e7a541..7073a5265d62c 100644
--- a/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp
+++ b/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp
@@ -28,7 +28,7 @@ public:
virtual ~TestObjectCache() {
// Free any buffers we've allocated.
- SmallVector<MemoryBuffer *, 2>::iterator it, end;
+ SmallVectorImpl<MemoryBuffer *>::iterator it, end;
end = AllocatedBuffers.end();
for (it = AllocatedBuffers.begin(); it != end; ++it) {
delete *it;
@@ -45,6 +45,16 @@ public:
ObjMap[ModuleID] = copyBuffer(Obj);
}
+ virtual MemoryBuffer* getObject(const Module* M) {
+ const MemoryBuffer* BufferFound = getObjectInternal(M);
+ ModulesLookedUp.insert(M->getModuleIdentifier());
+ if (!BufferFound)
+ return NULL;
+ // Our test cache wants to maintain ownership of its object buffers
+ // so we make a copy here for the execution engine.
+ return MemoryBuffer::getMemBufferCopy(BufferFound->getBuffer());
+ }
+
// Test-harness-specific functions
bool wereDuplicatesInserted() { return DuplicateInserted; }
@@ -62,13 +72,6 @@ public:
return it->second;
}
-protected:
- virtual const MemoryBuffer* getObject(const Module* M) {
- const MemoryBuffer* BufferFound = getObjectInternal(M);
- ModulesLookedUp.insert(M->getModuleIdentifier());
- return BufferFound;
- }
-
private:
MemoryBuffer *copyBuffer(const MemoryBuffer *Buf) {
// Create a local copy of the buffer.
@@ -98,14 +101,13 @@ protected:
void compileAndRun(int ExpectedRC = OriginalRC) {
// This function shouldn't be called until after SetUp.
- ASSERT_TRUE(0 != TheJIT);
+ ASSERT_TRUE(TheJIT.isValid());
ASSERT_TRUE(0 != Main);
+ // We may be using a null cache, so ensure compilation is valid.
TheJIT->finalizeObject();
void *vPtr = TheJIT->getPointerToFunction(Main);
- static_cast<SectionMemoryManager*>(MM)->invalidateInstructionCache();
-
EXPECT_TRUE(0 != vPtr)
<< "Unable to get pointer to main() from JIT";