llvm::InlineFunction

Inline the callee of CB into its caller's basic block.

Synopsis

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

InlineResult
InlineFunction(
    CallBase& CB,
    InlineFunctionInfo& IFI,
    bool MergeAttributes = false,
    AAResults* CalleeAAR = nullptr,
    bool InsertLifetime = true,
    bool TrackInlineHistory = false,
    Function* ForwardVarArgsTo = nullptr,
    OptimizationRemarkEmitter* ORE = nullptr);

Description

This function inlines the called function into the basic block of the caller. This returns false if it is not possible to inline this call. The program is still in a well defined state if this occurs though.

Note that this only does one level of inlining. For example, if the instruction 'call B' is inlined, and 'B' calls 'C', then the call to 'C' now exists in the instruction stream. Similarly this will inline a recursive function by one level.

Note that while this routine is allowed to cleanup and optimize the inlined code to minimize the actual inserted code, it must not delete code in the caller as users of this routine may have pointers to instructions in the caller that need to remain stable.

If ForwardVarArgsTo is passed, inlining a function with varargs is allowed and all varargs at the callsite will be passed to any calls to ForwardVarArgsTo. The caller of InlineFunction has to make sure any varargs are only used by ForwardVarArgsTo.

The callee's function attributes are merged into the callers' if MergeAttributes is set to true.

Return Value

Success if the call was inlined, otherwise a failure reason.

Parameters

NameDescription
CBCall site whose callee should be inlined.
IFIInlining context and result collector.
MergeAttributesWhether to merge callee attributes into the caller.
CalleeAAROptional alias-analysis results for the callee.
InsertLifetimeWhether to insert lifetime markers for inlined allocas.
TrackInlineHistoryWhether to record inline history metadata.
ForwardVarArgsToIf set, forward varargs from the callsite to calls to this function.
OREOptional optimization-remark emitter for diagnostics.