1 //===-- Transform/Utils/BasicBlockUtils.h - BasicBlock Utils ----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This family of functions perform manipulations on basic blocks, and
11 // instructions contained within basic blocks.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_TRANSFORMS_UTILS_BASICBLOCK_H
16 #define LLVM_TRANSFORMS_UTILS_BASICBLOCK_H
18 // FIXME: Move to this file: BasicBlock::removePredecessor, BB::splitBasicBlock
20 #include "llvm/BasicBlock.h"
23 // ReplaceInstWithValue - Replace all uses of an instruction (specified by BI)
24 // with a value, then remove and delete the original instruction.
26 void ReplaceInstWithValue(BasicBlock::InstListType &BIL,
27 BasicBlock::iterator &BI, Value *V);
29 // ReplaceInstWithInst - Replace the instruction specified by BI with the
30 // instruction specified by I. The original instruction is deleted and BI is
31 // updated to point to the new instruction.
33 void ReplaceInstWithInst(BasicBlock::InstListType &BIL,
34 BasicBlock::iterator &BI, Instruction *I);
36 // ReplaceInstWithInst - Replace the instruction specified by From with the
37 // instruction specified by To.
39 void ReplaceInstWithInst(Instruction *From, Instruction *To);
42 // RemoveSuccessor - Change the specified terminator instruction such that its
43 // successor #SuccNum no longer exists. Because this reduces the outgoing
44 // degree of the current basic block, the actual terminator instruction itself
45 // may have to be changed. In the case where the last successor of the block is
46 // deleted, a return instruction is inserted in its place which can cause a
47 // suprising change in program behavior if it is not expected.
49 void RemoveSuccessor(TerminatorInst *TI, unsigned SuccNum);