Splits a module into parts by transitive reachability from entry points.
Declared in <llvm/Transforms/Utils/SplitModuleByCategory.h>
Error
splitModuleTransitiveFromEntryPoints(
std::unique_ptr<Module> M,
function_ref<std::optional<int>(Function const&)> EntryPointCategorizer,
function_ref<Error(std::unique_ptr<Module>)> Callback);
Splits the given module M into parts. Each output part is passed to Callback for further possible processing. Each part corresponds to a subset of the module that is transitively reachable from some entry point group. Each entry point group is defined by EntryPointCategorizer (EPC) as follows: 1) If the function is not an entry point, then the Categorizer returns std::nullopt. Therefore, the function doesn't belong to any group. However, the function and global objects can still be associated with some output parts if they are transitively used from some entry points. 2) If the function belongs to an entry point group, then EPC returns an integer which is an identifier of the group. If two entry points belong to one group, then EPC returns the same identifier for both of them.
Let A and B be global objects in the module. The transitive dependency relation is defined such that: If global object A is used by global object B in any way (e.g., store, bitcast, phi node, call), then "A" -> "B". Transitivity is defined such that: If "A" -> "B" and "B" -> "C", then "A" -> "C". Examples of dependencies:
Function FA calls function FB
Function FA uses global variable GA
Global variable GA references (is initialized with) function FB
Function FA stores the address of function FB somewhere
The following cases are treated as dependencies between global objects: 1. Global object A is used by global object B in any way (store, bitcast, phi node, call, etc.): an "A" -> "B" edge will be added to the graph; 2. Function A performs an indirect call of a function with signature S, and there is a function B with signature S. An "A" -> "B" edge will be added to the graph;
Recursion and other cycles in the input Module (e.g. directly or mutually recursive functions, or self-referencing global variables) are supported.
Success, or an error propagated from Callback.
| Name | Description |
|---|---|
| M | Module to split. |
| EntryPointCategorizer | Maps each function to an entry-point group id, or std::nullopt if the function is not an entry point. |
| Callback | Invoked once per output part with that part's module. |