summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-rtdyld
diff options
context:
space:
mode:
authorDavide Italiano <davide@freebsd.org>2015-10-15 00:05:32 +0000
committerDavide Italiano <davide@freebsd.org>2015-10-15 00:05:32 +0000
commit89151a08fccfc088ec0aa49308129439ceb9942e (patch)
treeff432fdf0130e5bd18876aac95c32907579525cc /llvm/tools/llvm-rtdyld
parent1cea644114e367c7ed3a4ea3d2da571ec3ed56f7 (diff)
downloadbcm5719-llvm-89151a08fccfc088ec0aa49308129439ceb9942e.tar.gz
bcm5719-llvm-89151a08fccfc088ec0aa49308129439ceb9942e.zip
[JIT] TrivialMemoryManager: Fail if we can't allocate memory.
TrivialMemoryManager currently doesn't check the return type of AllocateRWX -- and returns a 'null' MemoryBlock to its caller. As pointed out by Lang, this exposes some serious issues with the MemoryManager interface. There's, in fact, no way to report back an error to clients rather than aborting in case memory can't be allocated. Eventually the interface will grow to support this, but for now, fail sooner rather than later. Differential Revision: http://reviews.llvm.org/D13627 llvm-svn: 250350
Diffstat (limited to 'llvm/tools/llvm-rtdyld')
-rw-r--r--llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp b/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
index 1bcd8900a27..0d68918d5be 100644
--- a/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
+++ b/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
@@ -181,7 +181,10 @@ uint8_t *TrivialMemoryManager::allocateCodeSection(uintptr_t Size,
unsigned Alignment,
unsigned SectionID,
StringRef SectionName) {
- sys::MemoryBlock MB = sys::Memory::AllocateRWX(Size, nullptr, nullptr);
+ std::string Err;
+ sys::MemoryBlock MB = sys::Memory::AllocateRWX(Size, nullptr, &Err);
+ if (!MB.base())
+ report_fatal_error("MemoryManager allocation failed: " + Err);
FunctionMemory.push_back(MB);
return (uint8_t*)MB.base();
}
@@ -191,7 +194,10 @@ uint8_t *TrivialMemoryManager::allocateDataSection(uintptr_t Size,
unsigned SectionID,
StringRef SectionName,
bool IsReadOnly) {
- sys::MemoryBlock MB = sys::Memory::AllocateRWX(Size, nullptr, nullptr);
+ std::string Err;
+ sys::MemoryBlock MB = sys::Memory::AllocateRWX(Size, nullptr, &Err);
+ if (!MB.base())
+ report_fatal_error("MemoryManager allocation failed: " + Err);
DataMemory.push_back(MB);
return (uint8_t*)MB.base();
}
OpenPOWER on IntegriCloud