[llvm-commits] CVS: llvm/lib/Transforms/Scalar/GVNPRE.cpp
Owen Anderson
resistor at mac.com
Mon Jun 25 11:25:53 PDT 2007
Changes in directory llvm/lib/Transforms/Scalar:
GVNPRE.cpp updated: 1.57 -> 1.58
---
Log message:
Use the built-in postorder iterators rather than computing a postorder walk by hand.
---
Diffs of the changes: (+3 -35)
GVNPRE.cpp | 38 +++-----------------------------------
1 files changed, 3 insertions(+), 35 deletions(-)
Index: llvm/lib/Transforms/Scalar/GVNPRE.cpp
diff -u llvm/lib/Transforms/Scalar/GVNPRE.cpp:1.57 llvm/lib/Transforms/Scalar/GVNPRE.cpp:1.58
--- llvm/lib/Transforms/Scalar/GVNPRE.cpp:1.57 Mon Jun 25 00:41:12 2007
+++ llvm/lib/Transforms/Scalar/GVNPRE.cpp Mon Jun 25 13:25:31 2007
@@ -27,6 +27,7 @@
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DepthFirstIterator.h"
+#include "llvm/ADT/PostOrderIterator.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Support/CFG.h"
@@ -935,39 +936,6 @@
// Phase 1, Part 2: calculate ANTIC_IN
- DOUT << "Calculating walk\n";
- // Calculate a postorder CFG walk
- std::vector<BasicBlock*> walk;
- std::vector<BasicBlock*> walkStack;
- SmallPtrSet<BasicBlock*, 16> walkVisited;
- walkStack.push_back(&F.getEntryBlock());
- walkVisited.insert(&F.getEntryBlock());
-
- while (!walkStack.empty()) {
- BasicBlock* BB = walkStack.back();
- walkVisited.insert(BB);
-
- bool inserted = false;
- for (unsigned i = 0; i < BB->getTerminator()->getNumSuccessors(); ++i) {
- BasicBlock* succ = BB->getTerminator()->getSuccessor(i);
- if (walkVisited.count(succ) == 0) {
- walkStack.push_back(succ);
- inserted = true;
- }
- }
-
- if (inserted)
- continue;
- else {
- walk.push_back(BB);
- walkStack.pop_back();
- }
- }
-
- DOUT << "Finished calculating walk\n";
-
- // Perform the ANTIC_IN calculation
-
std::set<BasicBlock*> visited;
bool changed = true;
@@ -977,8 +945,8 @@
SmallPtrSet<Value*, 32> anticOut;
// Top-down walk of the postdominator tree
- for (std::vector<BasicBlock*>::iterator BBI = walk.begin(), BBE = walk.end();
- BBI != BBE; ++BBI) {
+ for (po_iterator<BasicBlock*> BBI = po_begin(&F.getEntryBlock()),
+ BBE = po_end(&F.getEntryBlock()); BBI != BBE; ++BBI) {
BasicBlock* BB = *BBI;
if (BB == 0)
continue;
More information about the llvm-commits
mailing list