[llvm-commits] [llvm] r41078 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp

Owen Anderson resistor at mac.com
Tue Aug 14 11:04:12 PDT 2007


Author: resistor
Date: Tue Aug 14 13:04:11 2007
New Revision: 41078

URL: http://llvm.org/viewvc/llvm-project?rev=41078&view=rev
Log:
Make GVN iterative.

Modified:
    llvm/trunk/lib/Transforms/Scalar/GVN.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=41078&r1=41077&r2=41078&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Tue Aug 14 13:04:11 2007
@@ -671,6 +671,7 @@
                             DenseMap<BasicBlock*, Value*> &Phis,
                             bool top_level = false);
     void dump(DenseMap<BasicBlock*, Value*>& d);
+    bool iterateOnFunction(Function &F);
   };
   
   char GVN::ID = 0;
@@ -944,7 +945,21 @@
 // GVN::runOnFunction - This is the main transformation entry point for a
 // function.
 //
-bool GVN::runOnFunction(Function &F) {
+bool GVN::runOnFunction(Function& F) {
+  bool changed = false;
+  bool shouldContinue = true;
+  
+  while (shouldContinue) {
+    shouldContinue = iterateOnFunction(F);
+    changed |= shouldContinue;
+  }
+  
+  return changed;
+}
+
+
+// GVN::iterateOnFunction - Executes one iteration of GVN
+bool GVN::iterateOnFunction(Function &F) {
   // Clean out global sets from any previous functions
   VN.clear();
   availableOut.clear();





More information about the llvm-commits mailing list