24 #define DEBUG_TYPE "simplifycfg"
41 STATISTIC(NumSimpl,
"Number of blocks simplified");
66 return new CFGSimplifyPass();
82 if (Ret == 0)
continue;
86 if (Ret != &BB.
front()) {
91 while (isa<DbgInfoIntrinsic>(I) && I != BB.
begin())
93 if (!isa<DbgInfoIntrinsic>(I) &&
94 (!isa<PHINode>(
I) || I != BB.
begin() ||
114 cast<ReturnInst>(RetBlock->
getTerminator())->getOperand(0)) {
122 if (RetBlockPHI == 0) {
126 std::distance(PB, PE),
"merge",
149 bool Changed =
false;
150 bool LocalChange =
true;
151 while (LocalChange) {
162 Changed |= LocalChange;
170 bool CFGSimplifyPass::runOnFunction(
Function &
F) {
172 const DataLayout *
TD = getAnalysisIfAvailable<DataLayout>();
178 if (!EverChanged)
return false;
191 }
while (EverChanged);
void addIncoming(Value *V, BasicBlock *BB)
static PassRegistry * getPassRegistry()
enable_if_c<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
unsigned getNumOperands() const
const Instruction & front() const
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
static BranchInst * Create(BasicBlock *IfTrue, Instruction *InsertBefore=0)
This file contains the simple types necessary to represent the attributes associated with functions a...
ID
LLVM Calling Convention Representation.
STATISTIC(NumSimpl,"Number of blocks simplified")
void replaceAllUsesWith(Value *V)
bool SimplifyCFG(BasicBlock *BB, const TargetTransformInfo &TTI, const DataLayout *TD=0)
LLVM Basic Block Representation.
Interval::pred_iterator pred_begin(Interval *I)
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", Instruction *InsertBefore=0)
Value * getOperand(unsigned i) const
Interval::pred_iterator pred_end(Interval *I)
#define INITIALIZE_AG_DEPENDENCY(depName)
void eraseFromParent()
Unlink 'this' from the containing function and delete it.
void setOperand(unsigned i, Value *Val)
static bool iterativelySimplifyCFG(Function &F, const TargetTransformInfo &TTI, const DataLayout *TD)
FunctionPass * createCFGSimplificationPass()
TerminatorInst * getTerminator()
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
INITIALIZE_PASS_BEGIN(CFGSimplifyPass,"simplifycfg","Simplify the CFG", false, false) INITIALIZE_PASS_END(CFGSimplifyPass
static bool mergeEmptyReturnBlocks(Function &F)
void initializeCFGSimplifyPassPass(PassRegistry &)
LLVM Value Representation.
bool removeUnreachableBlocks(Function &F)
Remove all blocks that can not be reached from the function's entry.
INITIALIZE_PASS(GlobalMerge,"global-merge","Global Merge", false, false) bool GlobalMerge const DataLayout * TD