[llvm-commits] CVS: llvm/lib/Transforms/Scalar/GVNPRE.cpp

Owen Anderson resistor at mac.com
Sun Jun 17 21:42:51 PDT 2007



Changes in directory llvm/lib/Transforms/Scalar:

GVNPRE.cpp updated: 1.36 -> 1.37
---
Log message:

Cache the results of dependsOnInvoke()


---
Diffs of the changes:  (+18 -4)

 GVNPRE.cpp |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)


Index: llvm/lib/Transforms/Scalar/GVNPRE.cpp
diff -u llvm/lib/Transforms/Scalar/GVNPRE.cpp:1.36 llvm/lib/Transforms/Scalar/GVNPRE.cpp:1.37
--- llvm/lib/Transforms/Scalar/GVNPRE.cpp:1.36	Sun Jun 17 23:31:21 2007
+++ llvm/lib/Transforms/Scalar/GVNPRE.cpp	Sun Jun 17 23:42:29 2007
@@ -103,6 +103,7 @@
     
     std::map<BasicBlock*, std::set<Value*, ExprLT> > availableOut;
     std::map<BasicBlock*, std::set<Value*, ExprLT> > anticipatedIn;
+    std::map<User*, bool> invokeDep;
     
     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
       AU.setPreservesCFG();
@@ -135,6 +136,8 @@
                        std::map<BasicBlock*, std::set<Value*, ExprLT> > availOut);
     void cleanup();
     void elimination();
+    
+    bool dependsOnInvoke(Value* V);
   
   };
   
@@ -285,11 +288,15 @@
   }
 }
 
-bool dependsOnInvoke(Value* V) {
+bool GVNPRE::dependsOnInvoke(Value* V) {
   if (!isa<User>(V))
     return false;
     
   User* U = cast<User>(V);
+  std::map<User*, bool>::iterator I = invokeDep.find(U);
+  if (I != invokeDep.end())
+    return I->second;
+  
   std::vector<Value*> worklist(U->op_begin(), U->op_end());
   std::set<Value*> visited;
   
@@ -304,9 +311,15 @@
       return true;
     
     User* curr = cast<User>(current);
-    for (unsigned i = 0; i < curr->getNumOperands(); ++i)
-      if (visited.find(curr->getOperand(i)) == visited.end())
-        worklist.push_back(curr->getOperand(i));
+    std::map<User*, bool>::iterator CI = invokeDep.find(curr);
+    if (CI != invokeDep.end()) {
+      if (CI->second)
+        return true;
+    } else {
+      for (unsigned i = 0; i < curr->getNumOperands(); ++i)
+        if (visited.find(curr->getOperand(i)) == visited.end())
+          worklist.push_back(curr->getOperand(i));
+    }
   }
   
   return false;
@@ -593,6 +606,7 @@
   createdExpressions.clear();
   availableOut.clear();
   anticipatedIn.clear();
+  invokeDep.clear();
 
   std::map<BasicBlock*, std::set<Value*, ExprLT> > generatedExpressions;
   std::map<BasicBlock*, std::set<PHINode*> > generatedPhis;






More information about the llvm-commits mailing list