30 #define DEBUG_TYPE "lcssa"
45 STATISTIC(NumLCSSA,
"Number of live out of a loop variables");
82 assert(L->isLCSSAForm(*DT) &&
"LCSSA form not preserved!");
103 for (
unsigned i = 0, e = ExitBlocks.
size(); i != e; ++i)
115 DT = &getAnalysis<DominatorTree>();
116 LI = &getAnalysis<LoopInfo>();
117 SE = getAnalysisIfAvailable<ScalarEvolution>();
121 L->getExitBlocks(ExitBlocks);
123 if (ExitBlocks.empty())
128 bool MadeChange =
false;
144 if (
I->use_empty() ||
145 (
I->hasOneUse() &&
I->use_back()->getParent() == BB &&
146 !isa<PHINode>(
I->use_back())))
149 MadeChange |= ProcessInstruction(
I, ExitBlocks);
156 if (SE && MadeChange)
159 assert(L->isLCSSAForm(*DT));
168 for (
unsigned i = 0, e = ExitBlocks.
size(); i != e; ++i)
169 if (ExitBlocks[i] == BB)
187 if (
PHINode *PN = dyn_cast<PHINode>(U))
188 UserBB = PN->getIncomingBlock(UI);
190 if (InstBB != UserBB && !L->contains(UserBB))
195 if (UsesToRewrite.
empty())
return false;
204 if (
InvokeInst *Inv = dyn_cast<InvokeInst>(Inst))
205 DomBB = Inv->getNormalDest();
217 BBE = ExitBlocks.
end(); BBI != BBE; ++BBI) {
219 if (!DT->dominates(DomNode, DT->getNode(ExitBB)))
continue;
225 PredCache.GetNumPreds(ExitBB),
230 for (
BasicBlock **PI = PredCache.GetPreds(ExitBB); *PI; ++PI) {
236 if (!L->contains(*PI))
250 for (
unsigned i = 0, e = UsesToRewrite.
size(); i != e; ++i) {
257 if (
PHINode *PN = dyn_cast<PHINode>(User))
260 if (isa<PHINode>(UserBB->begin()) &&
263 if (UsesToRewrite[i]->
get()->hasValueHandle())
265 UsesToRewrite[i]->set(UserBB->begin());
274 for (
unsigned i = 0, e = AddedPHIs.
size(); i != e; ++i) {
275 if (AddedPHIs[i]->use_empty())
276 AddedPHIs[i]->eraseFromParent();
const Use & getOperandUse(unsigned i) const
void push_back(const T &Elt)
DomTreeNode * getNode(BasicBlock *BB) const
static bool BlockDominatesAnExit(BasicBlock *BB, const SmallVectorImpl< BasicBlock * > &ExitBlocks, DominatorTree *DT)
AnalysisUsage & addPreserved()
Helper class for SSA formation on a set of values defined in multiple blocks.
void addIncoming(Value *V, BasicBlock *BB)
static PassRegistry * getPassRegistry()
void Initialize(Type *Ty, StringRef Name)
Reset this object to get ready for a new set of SSA updates with type 'Ty'.
virtual void verifyAnalysis() const
void AddAvailableValue(BasicBlock *BB, Value *V)
Indicate that a rewritten value is available in the specified block with the specified value...
virtual void getAnalysisUsage(AnalysisUsage &) const
LoopInfoBase< BlockT, LoopT > * LI
StringRef getName() const
static unsigned getOperandNumForIncomingValue(unsigned i)
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
STATISTIC(NumLCSSA,"Number of live out of a loop variables")
ID
LLVM Calling Convention Representation.
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
AnalysisUsage & addPreservedID(const void *ID)
static void ValueIsRAUWd(Value *Old, Value *New)
unsigned getNumIncomingValues() const
LLVM Basic Block Representation.
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", Instruction *InsertBefore=0)
BasicBlock * getIncomingBlock(unsigned i) const
bool HasValueForBlock(BasicBlock *BB) const
Return true if the SSAUpdater already has a value for the specified block.
bool dominates(const DomTreeNode *A, const DomTreeNode *B) const
void initializeLCSSAPass(PassRegistry &)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
std::vector< BlockT * >::const_iterator block_iterator
static const Function * getParent(const Value *V)
static bool isExitBlock(BasicBlock *BB, const SmallVectorImpl< BasicBlock * > &ExitBlocks)
isExitBlock - Return true if the specified block is in the list.
void RewriteUse(Use &U)
Rewrite a use of the symbolic value.
const BasicBlock * getParent() const