SectionMemoryManager shouldn't be a JITMemoryManager. Previously, the

EngineBuilder interface required a JITMemoryManager even if it was being used 
to construct an MCJIT. But the MCJIT actually wants a RTDyldMemoryManager. 
Consequently, the SectionMemoryManager, which is meant for MCJIT, derived 
from the JITMemoryManager and then stubbed out a bunch of JITMemoryManager 
methods that weren't relevant to the MCJIT.

This patch fixes the situation: it teaches the EngineBuilder that 
RTDyldMemoryManager is a supertype of JITMemoryManager, and that it's 
appropriate to pass a RTDyldMemoryManager instead of a JITMemoryManager if 
we're using the MCJIT. This allows us to remove the stub methods from 
SectionMemoryManager, and make SectionMemoryManager a direct subtype of 
RTDyldMemoryManager.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181820 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Filip Pizlo
2013-05-14 19:29:00 +00:00
parent a29a8965e2
commit 13a3cf1928
7 changed files with 57 additions and 74 deletions

View File

@ -16,7 +16,7 @@
#define LLVM_EXECUTIONENGINE_SECTIONMEMORYMANAGER_H
#include "llvm/ADT/SmallVector.h"
#include "llvm/ExecutionEngine/JITMemoryManager.h"
#include "llvm/ExecutionEngine/RuntimeDyld.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Memory.h"
@ -35,7 +35,7 @@ namespace llvm {
/// in the JITed object. Permissions can be applied either by calling
/// MCJIT::finalizeObject or by calling SectionMemoryManager::applyPermissions
/// directly. Clients of MCJIT should call MCJIT::finalizeObject.
class SectionMemoryManager : public JITMemoryManager {
class SectionMemoryManager : public RTDyldMemoryManager {
SectionMemoryManager(const SectionMemoryManager&) LLVM_DELETED_FUNCTION;
void operator=(const SectionMemoryManager&) LLVM_DELETED_FUNCTION;
@ -108,54 +108,6 @@ private:
MemoryGroup CodeMem;
MemoryGroup RWDataMem;
MemoryGroup RODataMem;
public:
///
/// Functions below are not used by MCJIT or RuntimeDyld, but must be
/// implemented because they are declared as pure virtuals in the base class.
///
virtual void setMemoryWritable() {
llvm_unreachable("Unexpected call!");
}
virtual void setMemoryExecutable() {
llvm_unreachable("Unexpected call!");
}
virtual void setPoisonMemory(bool poison) {
llvm_unreachable("Unexpected call!");
}
virtual void AllocateGOT() {
llvm_unreachable("Unexpected call!");
}
virtual uint8_t *getGOTBase() const {
llvm_unreachable("Unexpected call!");
return 0;
}
virtual uint8_t *startFunctionBody(const Function *F,
uintptr_t &ActualSize){
llvm_unreachable("Unexpected call!");
return 0;
}
virtual uint8_t *allocateStub(const GlobalValue *F, unsigned StubSize,
unsigned Alignment) {
llvm_unreachable("Unexpected call!");
return 0;
}
virtual void endFunctionBody(const Function *F, uint8_t *FunctionStart,
uint8_t *FunctionEnd) {
llvm_unreachable("Unexpected call!");
}
virtual uint8_t *allocateSpace(intptr_t Size, unsigned Alignment) {
llvm_unreachable("Unexpected call!");
return 0;
}
virtual uint8_t *allocateGlobal(uintptr_t Size, unsigned Alignment) {
llvm_unreachable("Unexpected call!");
return 0;
}
virtual void deallocateFunctionBody(void *Body) {
llvm_unreachable("Unexpected call!");
}
};
}