This is an archive of the discontinued LLVM Phabricator instance.

[JIT] TrivialMemoryManager: Fail if we can't allocate memory
ClosedPublic

Authored by davide on Oct 10 2015, 9:29 PM.

Details

Summary

TrivialMemoryManager currently doesn't check the return type of AllocateRWX -- and returns a 'null' MemoryBlock to its caller.
I would like to change the behavior, and check for errors inside the memory manager, so that If AllocateRWX fails, we can get an human readable error message that explains why the allocation failed, rather than printing a generic failure message. Also, if we check for memory allocation failures in the MemoryManager, we can guarantee the following invariant: if the memory manager returns, the buffer returned is valid. Therefore the clients can convert error handling into asserts.
Please let me know what you think.

Diff Detail

Event Timeline

davide updated this revision to Diff 37043.Oct 10 2015, 9:29 PM
davide retitled this revision from to [JIT] TrivialMemoryManager: Fail if we can't allocate memory.
davide updated this object.
davide added a reviewer: lhames.
davide added a subscriber: llvm-commits.
lhames accepted this revision.Oct 13 2015, 10:50 PM
lhames edited edge metadata.

This points to some serious issues with the MemoryManager interface: We should really have a way to report this kind of failure back to users, rather than crashing.

That said, this looks good for now.

This revision is now accepted and ready to land.Oct 13 2015, 10:50 PM
This revision was automatically updated to reflect the committed changes.

Thanks for your review, Lang. I opened a bug so that we can track/don't forget about the interface changes. https://llvm.org/bugs/show_bug.cgi?id=25187