[llvm] r250350 - [JIT] TrivialMemoryManager: Fail if we can't allocate memory.

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 30 11:34:14 PDT 2015


Thanks David!

- Lang.

On Wed, Oct 14, 2015 at 5:05 PM, Davide Italiano via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: davide
> Date: Wed Oct 14 19:05:32 2015
> New Revision: 250350
>
> URL: http://llvm.org/viewvc/llvm-project?rev=250350&view=rev
> Log:
> [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
>
> Modified:
>     llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp
>
> Modified: llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp?rev=250350&r1=250349&r2=250350&view=diff
>
> ==============================================================================
> --- llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp (original)
> +++ llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp Wed Oct 14 19:05:32 2015
> @@ -181,7 +181,10 @@ uint8_t *TrivialMemoryManager::allocateC
>                                                     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::allocateD
>                                                     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();
>  }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151030/3429ffde/attachment.html>


More information about the llvm-commits mailing list