Sanitize MCJIT remote execution

MCJIT remote execution (ChildTarget+RemoteTargetExternal) protocol was in
dire need of refactoring. It was fail-prone, had no error reporting and
implemented the same message logic on every single function.

This patch rectifies it, and makes it work on ARM, where it was randomly
failing. Other architectures shall profit from this change as well, making
their buildbots and releases more reliable.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199261 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Renato Golin
2014-01-14 22:43:43 +00:00
parent 0445dc203b
commit 83ece7a499
9 changed files with 450 additions and 165 deletions

View File

@@ -129,7 +129,7 @@ void RemoteMemoryManager::notifyObjectLoaded(ExecutionEngine *EE,
// Allocate space in the remote target.
uint64_t RemoteAddr;
if (Target->allocateSpace(CurOffset, MaxAlign, RemoteAddr))
if (!Target->allocateSpace(CurOffset, MaxAlign, RemoteAddr))
report_fatal_error(Target->getErrorMsg());
// Map the section addresses so relocations will get updated in the local
@@ -155,13 +155,13 @@ bool RemoteMemoryManager::finalizeMemory(std::string *ErrMsg) {
uint64_t RemoteAddr = I->first;
const Allocation &Section = I->second;
if (Section.IsCode) {
Target->loadCode(RemoteAddr, Section.MB.base(), Section.MB.size());
if (!Target->loadCode(RemoteAddr, Section.MB.base(), Section.MB.size()))
report_fatal_error(Target->getErrorMsg());
DEBUG(dbgs() << " loading code: " << Section.MB.base()
<< " to remote: 0x" << format("%llx", RemoteAddr) << "\n");
} else {
Target->loadData(RemoteAddr, Section.MB.base(), Section.MB.size());
if (!Target->loadData(RemoteAddr, Section.MB.base(), Section.MB.size()))
report_fatal_error(Target->getErrorMsg());
DEBUG(dbgs() << " loading data: " << Section.MB.base()
<< " to remote: 0x" << format("%llx", RemoteAddr) << "\n");
}