llvm::simplifyCFG

Simplify the CFG around a basic block with peephole optimizations.

Synopsis

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

bool
simplifyCFG(
    BasicBlock* BB,
    TargetTransformInfo const& TTI,
    DomTreeUpdater* DTU = nullptr,
    SimplifyCFGOptions const& Options = {},
    ArrayRef<WeakVH> LoopHeaders = {});

Description

This function is used to do simplification of a CFG. For example, it adjusts branches to branches to eliminate the extra hop, it eliminates unreachable basic blocks, and does other peephole optimization of the CFG. It returns true if a modification was made, possibly deleting the basic block that was pointed to. LoopHeaders is an optional input parameter providing the set of loop headers that SimplifyCFG should not eliminate.

Return Value

True if any CFG modification was made.

Parameters

NameDescription
BBBasic block to simplify.
TTITarget transform info used for cost decisions.
DTUOptional dominator-tree updater for CFG changes.
OptionsExtra SimplifyCFG knobs.
LoopHeadersOptional loop headers that must not be eliminated.