llvm::SplitModule

Splits a module into multiple linkable partitions.

Synopsis

Declared in <llvm/Transforms/Utils/SplitModule.h>

void
SplitModule(
    Module& M,
    unsigned int N,
    function_ref<void(std::unique_ptr<Module>)> ModuleCallback,
    bool PreserveLocals = false,
    bool RoundRobin = false);

Description

ModuleCallback is called N times, passing each individual partition as the MPart argument.

FIXME: This function does not deal with the somewhat subtle symbol visibility issues around module splitting, including (but not limited to):

  • Internal symbols should not collide with symbols defined outside the module.

  • Internal symbols defined in module-level inline asm should be visible to each partition.

Parameters

NameDescription
MModule to split.
NNumber of linkable partitions to produce.
ModuleCallbackCallback invoked once per partition with that partition.
PreserveLocalsIf true, split without externalizing locals.
RoundRobinIf true, use round-robin distribution of functions to modules instead of the default name-hash-based one.