Adjust to LLVM JIT API change

Those wrapper functions seems not used by lldb... Removed

Reference for

replacing JITMemoryManager with SectionMemoryManager
replacing "llvm::JITMemoryManager::CreateDefaultMemManager()" with "new llvm::SectionMemoryManager()"
http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-jitlistener/llvm-jitlistener.cpp?r1=218316&r2=218315&pathrev=218316

Change by Tong Shen.

Tested:
Ubuntu 14.04 x86_64
MacOSX 10.9.5 with Xcode Version 6.1 (6A1030) (Beta)

llvm-svn: 218383
This commit is contained in:
Todd Fiala 2014-09-24 15:55:47 +00:00
parent 1ae8b476f4
commit d5635cdd7f
3 changed files with 6 additions and 266 deletions

View File

@ -30,8 +30,6 @@
#include "lldb/Symbol/TaggedASTType.h"
#include "lldb/Target/ExecutionContext.h"
#include "llvm/ExecutionEngine/JITMemoryManager.h"
namespace lldb_private
{

View File

@ -25,7 +25,7 @@
#include "lldb/lldb-private.h"
#include "lldb/Core/ClangForward.h"
#include "lldb/Core/DataBufferHeap.h"
#include "llvm/ExecutionEngine/JITMemoryManager.h"
#include "llvm/ExecutionEngine/SectionMemoryManager.h"
#include "lldb/Expression/ClangExpression.h"
#include "lldb/Expression/ClangExpressionParser.h"
#include "lldb/Expression/IRMemoryMap.h"
@ -56,7 +56,7 @@ class Error;
/// then be used as input to the IR interpreter, or the address of the
/// executable code can be passed to a thread plan to run in the target.
///
/// This class creates a subclass of LLVM's JITMemoryManager, because that is
/// This class creates a subclass of LLVM's SectionMemoryManager, because that is
/// how the JIT emits code. Because LLDB needs to move JIT-compiled code
/// into the target process, the IRExecutionUnit knows how to copy the
/// emitted code into the target process.
@ -207,101 +207,12 @@ private:
DisassembleFunction (Stream &stream,
lldb::ProcessSP &process_sp);
class MemoryManager : public llvm::JITMemoryManager
class MemoryManager : public llvm::SectionMemoryManager
{
public:
MemoryManager (IRExecutionUnit &parent);
virtual ~MemoryManager();
//------------------------------------------------------------------
/// Passthrough interface stub
//------------------------------------------------------------------
virtual void setMemoryWritable ();
//------------------------------------------------------------------
/// Passthrough interface stub
//------------------------------------------------------------------
virtual void setMemoryExecutable ();
//------------------------------------------------------------------
/// Passthrough interface stub
//------------------------------------------------------------------
virtual void setPoisonMemory (bool poison)
{
m_default_mm_ap->setPoisonMemory (poison);
}
//------------------------------------------------------------------
/// Passthrough interface stub
//------------------------------------------------------------------
virtual void AllocateGOT()
{
m_default_mm_ap->AllocateGOT();
}
//------------------------------------------------------------------
/// Passthrough interface stub
//------------------------------------------------------------------
virtual uint8_t *getGOTBase() const
{
return m_default_mm_ap->getGOTBase();
}
//------------------------------------------------------------------
/// Passthrough interface stub
//------------------------------------------------------------------
virtual uint8_t *startFunctionBody(const llvm::Function *F,
uintptr_t &ActualSize);
//------------------------------------------------------------------
/// Allocate room for a dyld stub for a lazy-referenced function,
/// and add it to the m_stubs map
///
/// @param[in] F
/// The function being referenced.
///
/// @param[in] StubSize
/// The size of the stub.
///
/// @param[in] Alignment
/// The required alignment of the stub.
///
/// @return
/// Allocated space for the stub.
//------------------------------------------------------------------
virtual uint8_t *allocateStub(const llvm::GlobalValue* F,
unsigned StubSize,
unsigned Alignment);
//------------------------------------------------------------------
/// Complete the body of a function, and add it to the m_functions map
///
/// @param[in] F
/// The function being completed.
///
/// @param[in] FunctionStart
/// The first instruction of the function.
///
/// @param[in] FunctionEnd
/// The last byte of the last instruction of the function.
//------------------------------------------------------------------
virtual void endFunctionBody(const llvm::Function *F,
uint8_t *FunctionStart,
uint8_t *FunctionEnd);
//------------------------------------------------------------------
/// Allocate space for an unspecified purpose, and add it to the
/// m_spaceBlocks map
///
/// @param[in] Size
/// The size of the area.
///
/// @param[in] Alignment
/// The required alignment of the area.
///
/// @return
/// Allocated space.
//------------------------------------------------------------------
virtual uint8_t *allocateSpace(intptr_t Size, unsigned Alignment);
//------------------------------------------------------------------
/// Allocate space for executable code, and add it to the
@ -346,22 +257,6 @@ private:
llvm::StringRef SectionName,
bool IsReadOnly);
//------------------------------------------------------------------
/// Allocate space for a global variable, and add it to the
/// m_spaceBlocks map
///
/// @param[in] Size
/// The size of the variable.
///
/// @param[in] Alignment
/// The required alignment of the variable.
///
/// @return
/// Allocated space for the global.
//------------------------------------------------------------------
virtual uint8_t *allocateGlobal(uintptr_t Size,
unsigned Alignment);
//------------------------------------------------------------------
/// Called when object loading is complete and section page
/// permissions can be applied. Currently unimplemented for LLDB.
@ -380,50 +275,6 @@ private:
return false;
}
//------------------------------------------------------------------
/// Passthrough interface stub
//------------------------------------------------------------------
virtual void deallocateFunctionBody(void *Body);
//------------------------------------------------------------------
/// Passthrough interface stub
//------------------------------------------------------------------
virtual size_t GetDefaultCodeSlabSize() {
return m_default_mm_ap->GetDefaultCodeSlabSize();
}
//------------------------------------------------------------------
/// Passthrough interface stub
//------------------------------------------------------------------
virtual size_t GetDefaultDataSlabSize() {
return m_default_mm_ap->GetDefaultDataSlabSize();
}
virtual size_t GetDefaultStubSlabSize() {
return m_default_mm_ap->GetDefaultStubSlabSize();
}
//------------------------------------------------------------------
/// Passthrough interface stub
//------------------------------------------------------------------
virtual unsigned GetNumCodeSlabs() {
return m_default_mm_ap->GetNumCodeSlabs();
}
//------------------------------------------------------------------
/// Passthrough interface stub
//------------------------------------------------------------------
virtual unsigned GetNumDataSlabs() {
return m_default_mm_ap->GetNumDataSlabs();
}
//------------------------------------------------------------------
/// Passthrough interface stub
//------------------------------------------------------------------
virtual unsigned GetNumStubSlabs() {
return m_default_mm_ap->GetNumStubSlabs();
}
virtual void registerEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size) {
return m_default_mm_ap->registerEHFrames(Addr, LoadAddr, Size);
}
@ -436,7 +287,7 @@ private:
return m_default_mm_ap->getPointerToNamedFunction(Name, AbortOnFailure);
}
private:
std::unique_ptr<JITMemoryManager> m_default_mm_ap; ///< The memory allocator to use in actually creating space. All calls are passed through to it.
std::unique_ptr<SectionMemoryManager> m_default_mm_ap; ///< The memory allocator to use in actually creating space. All calls are passed through to it.
IRExecutionUnit &m_parent; ///< The execution unit this is a proxy for.
};

View File

@ -300,7 +300,7 @@ IRExecutionUnit::GetRunnableInfo(Error &error,
builder.setEngineKind(llvm::EngineKind::JIT)
.setErrorStr(&error_string)
.setRelocationModel(relocModel)
.setJITMemoryManager(new MemoryManager(*this))
.setMCJITMemoryManager(new MemoryManager(*this))
.setCodeModel(codeModel)
.setOptLevel(llvm::CodeGenOpt::Less);
@ -423,7 +423,7 @@ IRExecutionUnit::~IRExecutionUnit ()
}
IRExecutionUnit::MemoryManager::MemoryManager (IRExecutionUnit &parent) :
m_default_mm_ap (llvm::JITMemoryManager::CreateDefaultMemManager()),
m_default_mm_ap (new llvm::SectionMemoryManager()),
m_parent (parent)
{
}
@ -431,60 +431,6 @@ IRExecutionUnit::MemoryManager::MemoryManager (IRExecutionUnit &parent) :
IRExecutionUnit::MemoryManager::~MemoryManager ()
{
}
void
IRExecutionUnit::MemoryManager::setMemoryWritable ()
{
m_default_mm_ap->setMemoryWritable();
}
void
IRExecutionUnit::MemoryManager::setMemoryExecutable ()
{
m_default_mm_ap->setMemoryExecutable();
}
uint8_t *
IRExecutionUnit::MemoryManager::startFunctionBody(const llvm::Function *F,
uintptr_t &ActualSize)
{
return m_default_mm_ap->startFunctionBody(F, ActualSize);
}
uint8_t *
IRExecutionUnit::MemoryManager::allocateStub(const llvm::GlobalValue* F,
unsigned StubSize,
unsigned Alignment)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
uint8_t *return_value = m_default_mm_ap->allocateStub(F, StubSize, Alignment);
m_parent.m_records.push_back(AllocationRecord((uintptr_t)return_value,
lldb::ePermissionsReadable | lldb::ePermissionsWritable,
GetSectionTypeFromSectionName (llvm::StringRef(), AllocationKind::Stub),
StubSize,
Alignment,
eSectionIDInvalid,
NULL));
if (log)
{
log->Printf("IRExecutionUnit::allocateStub (F=%p, StubSize=%u, Alignment=%u) = %p",
static_cast<const void*>(F), StubSize, Alignment,
static_cast<void*>(return_value));
}
return return_value;
}
void
IRExecutionUnit::MemoryManager::endFunctionBody(const llvm::Function *F,
uint8_t *FunctionStart,
uint8_t *FunctionEnd)
{
m_default_mm_ap->endFunctionBody(F, FunctionStart, FunctionEnd);
}
lldb::SectionType
IRExecutionUnit::GetSectionTypeFromSectionName (const llvm::StringRef &name, IRExecutionUnit::AllocationKind alloc_kind)
@ -595,30 +541,6 @@ IRExecutionUnit::GetSectionTypeFromSectionName (const llvm::StringRef &name, IRE
return sect_type;
}
uint8_t *
IRExecutionUnit::MemoryManager::allocateSpace(intptr_t Size, unsigned Alignment)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
uint8_t *return_value = m_default_mm_ap->allocateSpace(Size, Alignment);
m_parent.m_records.push_back(AllocationRecord((uintptr_t)return_value,
lldb::ePermissionsReadable | lldb::ePermissionsWritable,
GetSectionTypeFromSectionName (llvm::StringRef(), AllocationKind::Bytes),
Size,
Alignment,
eSectionIDInvalid,
NULL));
if (log)
{
log->Printf("IRExecutionUnit::allocateSpace(Size=%" PRIu64 ", Alignment=%u) = %p",
(uint64_t)Size, Alignment, return_value);
}
return return_value;
}
uint8_t *
IRExecutionUnit::MemoryManager::allocateCodeSection(uintptr_t Size,
unsigned Alignment,
@ -673,37 +595,6 @@ IRExecutionUnit::MemoryManager::allocateDataSection(uintptr_t Size,
return return_value;
}
uint8_t *
IRExecutionUnit::MemoryManager::allocateGlobal(uintptr_t Size,
unsigned Alignment)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
uint8_t *return_value = m_default_mm_ap->allocateGlobal(Size, Alignment);
m_parent.m_records.push_back(AllocationRecord((uintptr_t)return_value,
lldb::ePermissionsReadable | lldb::ePermissionsWritable,
GetSectionTypeFromSectionName (llvm::StringRef(), AllocationKind::Global),
Size,
Alignment,
eSectionIDInvalid,
NULL));
if (log)
{
log->Printf("IRExecutionUnit::allocateGlobal(Size=0x%" PRIx64 ", Alignment=%u) = %p",
(uint64_t)Size, Alignment, return_value);
}
return return_value;
}
void
IRExecutionUnit::MemoryManager::deallocateFunctionBody(void *Body)
{
m_default_mm_ap->deallocateFunctionBody(Body);
}
lldb::addr_t
IRExecutionUnit::GetRemoteAddressForLocal (lldb::addr_t local_address)
{