Embed bitcode and optional command‐line data as sections in M.

Synopsis

Declared in <llvm/Bitcode/BitcodeWriter.h>

void
embedBitcodeInModule(
    Module& M,
    MemoryBufferRef Buf,
    bool EmbedBitcode,
    bool EmbedCmdline,
    std::vector<uint8_t> const& CmdArgs);

Description

If EmbedBitcode is set, save a copy of the LLVM IR as data in the __LLVM,__bitcode section (.llvmbc on non‐MacOS). If available, pass the serialized module via Buf. If not, pass an empty (default‐initialized) MemoryBufferRef, and the serialization will be handled by this API. The same behavior happens if the provided Buf is not bitcode (i.e. if it's invalid data or even textual LLVM assembly). If EmbedCmdline is set, the command line is also exported in the corresponding section (__LLVM,__cmdline / .llvmcmd) ‐ even if CmdArgs were empty.

Parameters

Name

Description

M

Module that receives the embedded data globals.

Buf

Serialized bitcode to embed, or an empty buffer to serialize M.

EmbedBitcode

If true, embed bitcode in the module's bitcode section.

EmbedCmdline

If true, embed CmdArgs in the command‐line section.

CmdArgs

Compiler command‐line bytes to embed when EmbedCmdline is true.

Created with MrDocs