1 //===-- Local.h - Functions to perform local transformations -----*- C++ -*--=//
3 // This family of functions perform various local transformations to the
6 //===----------------------------------------------------------------------===//
8 #ifndef LLVM_TRANSFORMS_UTILS_LOCAL_H
9 #define LLVM_TRANSFORMS_UTILS_LOCAL_H
11 #include "llvm/Function.h"
12 #include "llvm/BasicBlock.h"
14 //===----------------------------------------------------------------------===//
15 // Local constant propogation...
18 // doConstantPropogation - Constant prop a specific instruction. Returns true
19 // and potentially moves the iterator if constant propogation was performed.
21 bool doConstantPropogation(BasicBlock *BB, BasicBlock::iterator &I);
23 // ConstantFoldTerminator - If a terminator instruction is predicated on a
24 // constant value, convert it into an unconditional branch to the constant
25 // destination. This is a nontrivial operation because the successors of this
26 // basic block must have their PHI nodes updated.
28 bool ConstantFoldTerminator(BasicBlock *BB);
31 //===----------------------------------------------------------------------===//
32 // Local dead code elimination...
35 // isInstructionTriviallyDead - Return true if the result produced by the
36 // instruction is not used, and the instruction has no side effects.
38 bool isInstructionTriviallyDead(Instruction *I);
41 // dceInstruction - Inspect the instruction at *BBI and figure out if it
42 // isTriviallyDead. If so, remove the instruction and update the iterator to
43 // point to the instruction that immediately succeeded the original instruction.
45 bool dceInstruction(BasicBlock::InstListType &BBIL, BasicBlock::iterator &BBI);
48 //===----------------------------------------------------------------------===//
49 // Control Flow Graph Restructuring...
52 // SimplifyCFG - This function is used to do simplification of a CFG. For
53 // example, it adjusts branches to branches to eliminate the extra hop, it
54 // eliminates unreachable basic blocks, and does other "peephole" optimization
55 // of the CFG. It returns true if a modification was made, and returns an
56 // iterator that designates the first element remaining after the block that
59 // WARNING: The entry node of a method may not be simplified.
61 bool SimplifyCFG(Function::iterator &BBIt);