[JITLink] Add convenience methods for creating block readers / writers.
authorLang Hames <lhames@gmail.com>
Tue, 18 Oct 2022 17:53:25 +0000 (10:53 -0700)
committerLang Hames <lhames@gmail.com>
Tue, 18 Oct 2022 23:25:47 +0000 (16:25 -0700)
commit5f154795efc999cb0b6c15e82bbdf55ec15d1cac
tree30e88639494c86c1a68e314643f8b2366d21d2d6
parentb96cbbd901d4ad25d75d7c86f3abbcc545193b6d
[JITLink] Add convenience methods for creating block readers / writers.

This saves clients some boilerplate compared to setting up the readers and
writers manually.

To obtain a BinaryStreamWriter / BinaryStreamReader for a given block, B,
clients can now write:

auto Reader = G.getBlockContentReader(B);

and

auto Writer = G.getBlockContentWriter(B);

The latter will trigger a copy to mutable memory allocated on the graph's
allocator if the block is currently marked as backed by read-only memory.

This commit also introduces a new createMutableContentBlock overload that
creates a block with a given size and zero-filled content (by default --
passing false for the ZeroInitialize bypasses initialization entirely).
This overload is intended to be used with getBlockContentWriter above when
creating new content for the graph.
llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
llvm/unittests/ExecutionEngine/JITLink/LinkGraphTests.cpp