//===- PRE.cpp - Partial Redundancy Elimination ---------------------------===//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
+//
//===----------------------------------------------------------------------===//
//
// This file implements the well-known Partial Redundancy Elimination
AvailableBlocksTy AvailableBlocks;
bool ProcessBlock(BasicBlock *BB);
-
+
// Anticipatibility calculation...
void MarkPostDominatingBlocksAnticipatible(PostDominatorTree::Node *N,
std::vector<char> &AntBlocks,
RegisterOpt<PRE> Z("pre", "Partial Redundancy Elimination");
}
+FunctionPass* llvm::createPREPass() { return new PRE(); }
bool PRE::runOnFunction(Function &F) {
VN = &getAnalysis<ValueNumbering>();
bool PRE::ProcessBlock(BasicBlock *BB) {
bool Changed = false;
+ // DISABLED: This pass invalidates iterators and then uses them.
+ return false;
+
// PRE expressions first defined in this block...
- Instruction *PrevInst = 0;
for (BasicBlock::iterator I = BB->begin(); I != BB->end(); )
- if (ProcessExpression(I)) {
- // The current instruction may have been deleted, make sure to back up to
- // PrevInst instead.
- if (PrevInst)
- I = PrevInst;
- else
- I = BB->begin();
+ if (ProcessExpression(I++))
Changed = true;
- } else {
- PrevInst = I++;
- }
return Changed;
}
// active definition...
if (ExistingAvailableVal == 0) {
ExistingAvailableVal = NewOcc;
-
+
for (DominatorTree::Node::iterator I = N->begin(), E = N->end(); I != E;++I)
ReplaceDominatedAvailableOccurrencesWith(NewOcc, *I);
} else {
for (df_iterator<DominatorTree::Node*> DI = df_begin(N), E = df_end(N);
DI != E; ++DI)
AvailableBlocks[(*DI)->getBlock()] = NewOcc;
- }
+ }
}
if (AnticipatibleBlocks[i])
std::cerr << BlockMapping[i]->getName() <<" ";
std::cerr << "\n";);
-
+
// AvailabilityFrontier - Calculates the availability frontier for the current
AnyNotAvailable = true;
break;
}
-
+
// If any predecessor blocks are not available, add the node to
// the current expression dominance frontier.
if (AnyNotAvailable) {
++NumRedundant;
DEBUG(std::cerr << " PHI replaces available value: %"
<< OldVal->getName() << "\n");
-
+
// Loop over all of the blocks dominated by this PHI node, and change
// the AvailableBlocks entries to be the PHI node instead of the old
// instruction.
MarkOccurrenceAvailableInAllDominatedBlocks(PN, AFBlock);
-
+
AFBlock->getInstList().erase(OldVal); // Delete old instruction!
// The resultant PHI node is a new definition of the value!
// region (occurs when hoisting loop invariants, f.e.). In this case,
// the PHI node should actually just be removed.
assert(PN->use_empty() && "No uses should exist for dead PHI node!");
- PN->getParent()->getInstList().erase(PN);
+ PN->getParent()->getInstList().erase(PN);
}
} else {
// The resultant PHI node is a new definition of the value!