LLVM API Documentation
#include "llvm/Transforms/Utils/Local.h"#include "llvm/Constants.h"#include "llvm/Instructions.h"#include "llvm/Type.h"#include "llvm/DerivedTypes.h"#include "llvm/Support/CFG.h"#include "llvm/Support/Debug.h"#include "llvm/Analysis/ConstantFolding.h"#include "llvm/Transforms/Utils/BasicBlockUtils.h"#include "llvm/ADT/SmallVector.h"#include "llvm/ADT/SmallPtrSet.h"#include "llvm/ADT/Statistic.h"#include <algorithm>#include <functional>#include <set>#include <map>Include dependency graph for SimplifyCFG.cpp:

Go to the source code of this file.
|
|
Definition at line 14 of file SimplifyCFG.cpp. |
|
||||||||||||||||
|
AddPredecessorToBlock - Update PHI nodes in Succ to indicate that there will now be entries in it from the 'NewPred' block. The values that will be flowing into the PHI nodes will be the same as those coming in from ExistPred, an existing predecessor of Succ. Definition at line 65 of file SimplifyCFG.cpp. References llvm::PHINode::addIncoming(), llvm::BasicBlock::begin(), llvm::PHINode::getIncomingValueForBlock(), llvm::succ_begin(), and llvm::succ_end(). Referenced by FoldBranchToCommonDest(), FoldValueComparisonIntoPredecessors(), and HoistThenElseCodeToIf(). |
|
|
BlockIsSimpleEnoughToThreadThrough - Return true if we can thread a branch across this block. Definition at line 1085 of file SimplifyCFG.cpp. References llvm::BasicBlock::begin(), llvm::Instruction::getParent(), llvm::BasicBlock::getTerminator(), and llvm::Value::use_iterator. Referenced by FoldCondBranchOnPHI(), and SimplifyCondBranchToCondBranch(). |
|
||||||||||||
|
Definition at line 82 of file SimplifyCFG.cpp. References llvm::BasicBlock::begin(), DOUT, llvm::PHINode::getIncomingValueForBlock(), llvm::Value::getNameStart(), llvm::Instruction::getParent(), llvm::pred_begin(), llvm::pred_end(), llvm::pred_iterator, and llvm::succ_begin(). Referenced by TryToSimplifyUncondBranchFromEmptyBlock(). |
|
||||||||||||||||
|
||||||||||||
|
Definition at line 575 of file SimplifyCFG.cpp. Referenced by SimplifyEqualityComparisonWithOnlyPredecessor(). |
|
|
ErasePossiblyDeadInstructionTree - If the specified instruction is dead and has no side effects, nuke it. If it uses any instructions that become dead because the instruction is now gone, nuke them too. Definition at line 500 of file SimplifyCFG.cpp. References llvm::SmallVectorImpl< T >::back(), llvm::SmallVectorImpl< T >::begin(), llvm::SmallVectorImpl< T >::empty(), llvm::SmallVectorImpl< T >::erase(), llvm::Instruction::eraseFromParent(), llvm::isInstructionTriviallyDead(), llvm::User::op_begin(), llvm::User::op_end(), llvm::User::op_iterator, llvm::SmallVectorImpl< T >::pop_back(), llvm::SmallVectorImpl< T >::push_back(), and llvm::SmallVectorImpl< T >::size(). Referenced by FoldValueComparisonIntoPredecessors(), llvm::SimplifyCFG(), SimplifyCondBranchToTwoReturns(), and SimplifyEqualityComparisonWithOnlyPredecessor(). |
|
|
FoldBranchToCommonDest - If this basic block is ONLY a setcc and a branch, and if a predecessor branches to us and one of our successors, fold the setcc into the predecessor and use logical operations to pick the right destination. Definition at line 1422 of file SimplifyCFG.cpp. References AddPredecessorToBlock(), llvm::Instruction::clone(), llvm::BinaryOperator::Create(), llvm::BinaryOperator::CreateNot(), llvm::BasicBlock::front(), llvm::BranchInst::getCondition(), llvm::BasicBlock::getInstList(), llvm::Value::getName(), llvm::Instruction::getParent(), llvm::BranchInst::getSuccessor(), llvm::BasicBlock::getTerminator(), llvm::Value::hasOneUse(), llvm::BranchInst::isUnconditional(), llvm::pred_begin(), llvm::pred_end(), llvm::pred_iterator, SafeToMergeTerminators(), llvm::BranchInst::setCondition(), llvm::Value::setName(), llvm::BranchInst::setSuccessor(), and llvm::Value::takeName(). Referenced by llvm::SimplifyCFG(). |
|
|
|
FoldTwoEntryPHINode - Given a BB that starts with the specified two-entry PHI node, see if we can eliminate it. Definition at line 1214 of file SimplifyCFG.cpp. References llvm::BasicBlock::begin(), llvm::SelectInst::Create(), DominatesMergePoint(), DOUT, GetIfCondition(), llvm::PHINode::getIncomingBlock(), llvm::PHINode::getIncomingValue(), llvm::BasicBlock::getInstList(), llvm::Value::getName(), llvm::Instruction::getParent(), llvm::BasicBlock::getTerminator(), llvm::Value::getType(), llvm::pred_begin(), llvm::Value::replaceAllUsesWith(), and llvm::Value::takeName(). Referenced by llvm::SimplifyCFG(). |
|
|
||||||||||||
|
Definition at line 429 of file SimplifyCFG.cpp. References llvm::Instruction::getOpcode(), and llvm::User::getOperand(). Referenced by GatherValueComparisons(). |
|
||||||||||||
|
Definition at line 453 of file SimplifyCFG.cpp. References llvm::Instruction::getOpcode(), and llvm::User::getOperand(). Referenced by GatherValueComparisons(). |
|
||||||||||||||||
|
GatherValueComparisons - If the specified Cond is an 'and' or 'or' of a bunch of comparisons of one value against constants, return the value and the constants being compared. Definition at line 479 of file SimplifyCFG.cpp. References GatherConstantSetEQs(), GatherConstantSetNEs(), and llvm::Instruction::getOpcode(). Referenced by llvm::SimplifyCFG(). |
|
||||||||||||||||
|
GetIfCondition - Given a basic block (BB) with two predecessors (and presumably PHI nodes in it), check to see if the merge at this block is due to an "if condition". If so, return the boolean condition that determines which entry into BB will be taken. Also, return by references the block that will be entered from if the condition is true, and the block that will be entered if the condition is false. Definition at line 266 of file SimplifyCFG.cpp. References llvm::BranchInst::getCondition(), llvm::BranchInst::getSuccessor(), llvm::BasicBlock::getTerminator(), llvm::BranchInst::isConditional(), llvm::pred_begin(), llvm::pred_end(), and std::swap(). Referenced by FoldTwoEntryPHINode(). |
|
||||||||||||
|
|
HoistThenElseCodeToIf - Given a conditional branch that goes to BB1 and BB2, hoist any common code in the two blocks up into the branch block. The caller of this function guarantees that BI's block dominates BB1 and BB2. Definition at line 879 of file SimplifyCFG.cpp. References AddPredecessorToBlock(), llvm::BasicBlock::begin(), llvm::Instruction::clone(), llvm::SelectInst::Create(), llvm::Instruction::eraseFromParent(), llvm::BranchInst::getCondition(), llvm::PHINode::getIncomingBlock(), llvm::PHINode::getIncomingValueForBlock(), llvm::BasicBlock::getInstList(), llvm::Value::getName(), llvm::PHINode::getNumIncomingValues(), llvm::Instruction::getOpcode(), llvm::Instruction::getParent(), llvm::BranchInst::getSuccessor(), llvm::Value::getType(), llvm::Instruction::isIdenticalTo(), llvm::Value::replaceAllUsesWith(), llvm::PHINode::setIncomingValue(), llvm::succ_begin(), llvm::succ_end(), llvm::succ_iterator, and llvm::Value::takeName(). Referenced by llvm::SimplifyCFG(). |
|
|
||||||||||||
|
SafeToMergeTerminators - Return true if it is safe to merge these two terminator instructions together. Definition at line 38 of file SimplifyCFG.cpp. References llvm::SmallPtrSet< PtrType, SmallSize >::count(), llvm::PHINode::getIncomingValueForBlock(), llvm::Instruction::getParent(), llvm::succ_begin(), llvm::succ_end(), and llvm::succ_iterator. Referenced by FoldBranchToCommonDest(), and FoldValueComparisonIntoPredecessors(). |
|
||||||||||||
|
|
SimplifyCondBranchToTwoReturns - If we found a conditional branch that goes to two returning blocks, try to merge them together into one return, introducing a select if the return values disagree. Definition at line 1332 of file SimplifyCFG.cpp. References llvm::BasicBlock::begin(), llvm::Constant::canTrap(), llvm::SelectInst::Create(), llvm::ReturnInst::Create(), DOUT, llvm::Instruction::eraseFromParent(), ErasePossiblyDeadInstructionTree(), llvm::BranchInst::getCondition(), llvm::PHINode::getIncomingValueForBlock(), llvm::User::getNumOperands(), llvm::Instruction::getParent(), llvm::ReturnInst::getReturnValue(), llvm::BranchInst::getSuccessor(), llvm::BasicBlock::getTerminator(), llvm::BranchInst::isConditional(), and llvm::BasicBlock::removePredecessor(). Referenced by llvm::SimplifyCFG(). |
|
||||||||||||
|
||||||||||||
|
||||||||||||
|
|
|
||||||||||||
|
TryToSimplifyUncondBranchFromEmptyBlock - BB contains an unconditional branch to Succ, and contains no instructions other than PHI nodes and the branch. If possible, eliminate BB. Definition at line 178 of file SimplifyCFG.cpp. References llvm::PHINode::addIncoming(), llvm::BasicBlock::begin(), CanPropagatePredecessorsForPHIs(), DOUT, llvm::BasicBlock::eraseFromParent(), llvm::Instruction::eraseFromParent(), llvm::PHINode::getIncomingBlock(), llvm::PHINode::getIncomingValue(), llvm::BasicBlock::getInstList(), llvm::PHINode::getNumIncomingValues(), llvm::Value::hasName(), llvm::pred_begin(), llvm::pred_end(), llvm::PHINode::removeIncomingValue(), llvm::Value::replaceAllUsesWith(), llvm::SmallVectorImpl< T >::size(), llvm::Value::takeName(), and llvm::Value::use_empty(). Referenced by llvm::SimplifyCFG(). |
|
||||||||||||
|
Definition at line 587 of file SimplifyCFG.cpp. References llvm::BasicBlock::size(), and std::swap(). Referenced by SimplifyEqualityComparisonWithOnlyPredecessor(). |