ΒΆllvm::Instruction* SplitBlockAndInsertIfThen(
    llvm::Value* Cond,
    llvm::Instruction* SplitBefore,
    bool Unreachable,
    llvm::MDNode* BranchWeights = nullptr,
    llvm::DomTreeUpdater* DTU = nullptr,
    llvm::LoopInfo* LI = nullptr,
    llvm::BasicBlock* ThenBlock = nullptr)

Description

Split the containing block at the specified instruction - everything before SplitBefore stays in the old basic block, and the rest of the instructions in the BB are moved to a new block. The two blocks are connected by a conditional branch (with value of Cmp being the condition). Before: Head SplitBefore Tail After: Head if (Cond) ThenBlock SplitBefore Tail If \p ThenBlock is not specified, a new block will be created for it. If \p Unreachable is true, the newly created block will end with UnreachableInst, otherwise it branches to Tail. Returns the NewBasicBlock's terminator. Updates DT and LI if given.

Declared at: llvm/include/llvm/Transforms/Utils/BasicBlockUtils.h:446

Parameters

llvm::Value* Cond
llvm::Instruction* SplitBefore
bool Unreachable
llvm::MDNode* BranchWeights = nullptr
llvm::DomTreeUpdater* DTU = nullptr
llvm::LoopInfo* LI = nullptr
llvm::BasicBlock* ThenBlock = nullptr