Built-in LLVM passes¶
The framework features a number of useful analysis/transformation passes that you can use in your own instances/passes. The passes are listed below, with the supported LLVM versions in parentheses.
-dump-ir (3.8.0/4.0.0): Dumps the current module IR of the program that is
being linked in human-readable bitcode file with the “.ll” extension. Prints the
location of the created file to
stderr. Optionally, the target filename can
be set by calling
DEBUG_MODULE_NAME("myname"); after including
dump-ir-helper.h from the built-in passes.
-custominline (3.8.0/4.0.0): Custom inliner for helper functions from
statically linked runtime libraries. Inlines calls to functions that have
__attribute__((always_inline)) and functions whose name starts with
-defer-global-init (3.8.0): Changes all global initializers to
zero-initializers and adds a global constructor function that initializes the
globals instead. In combination with
-expand-const-global-uses, this is
useful for instrumenting globals without having to deal with constant
expressions (but only with instructions).
-expand-const-global-uses (3.8.0): Expands all uses of constant expressions
ConstExpr) in functions to equivalent instructions. This limts edge cases
during instrumentation, and can be undone with
-expand-const-global-uses into a
-expand-constexprs pass that expands all constant expressions to
-sizeof-types (3.8.0): Finds allocated types for calls to
sizeof expression in the source code. Must be used in conjunction with
the accompanying compiler wrapper and compile-time pass. See header file
builtin/Common.h (3.8.0/4.0.0): Includes a bunch of much-used LLVM headers and
defines some helper functions.
builtin/Allocation.h (3.8.0/4.0.0): Helpers to populate an
struct with standardized information about any stack/heap allocations.
builtin/Allocation.h to an
-allocs analysis pass.
builtin/CustomFunctionPass.h (3.8.0/4.0.0): Defines the
class which serves as a drop-in replacement for LLVM’s
really is a
ModulePass. This is necessary because the link-time passes
plugin does not support function passes because of things and reasons.