Small bugfix, and const-ify some methods (Thanks, Bill).
authorOwen Anderson <resistor@mac.com>
Fri, 8 Jun 2007 01:52:45 +0000 (01:52 +0000)
committerOwen Anderson <resistor@mac.com>
Fri, 8 Jun 2007 01:52:45 +0000 (01:52 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37513 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/GVNPRE.cpp

index 2336be8901cdf6a96c1a6707fb82c9bdd02f307d..db8e7f0634ffeb811fc88bcc2e4a739709cbe5f0 100644 (file)
@@ -77,8 +77,8 @@ namespace {
   
     // Helper fuctions
     // FIXME: eliminate or document these better
-    void dump(std::set<Value*>& s);
-    void dump_unique(std::set<Value*, ExprLT>& s);
+    void dump(const std::set<Value*>& s) const;
+    void dump_unique(const std::set<Value*, ExprLT>& s) const;
     void clean(std::set<Value*, ExprLT>& set);
     bool add(Value* V, uint32_t number);
     Value* find_leader(std::set<Value*, ExprLT>& vals,
@@ -269,7 +269,7 @@ void GVNPRE::topo_sort(std::set<Value*, ExprLT>& set,
 }
 
 
-void GVNPRE::dump(std::set<Value*>& s) {
+void GVNPRE::dump(const std::set<Value*>& s) const {
   DOUT << "{ ";
   for (std::set<Value*>::iterator I = s.begin(), E = s.end();
        I != E; ++I) {
@@ -278,7 +278,7 @@ void GVNPRE::dump(std::set<Value*>& s) {
   DOUT << "}\n\n";
 }
 
-void GVNPRE::dump_unique(std::set<Value*, ExprLT>& s) {
+void GVNPRE::dump_unique(const std::set<Value*, ExprLT>& s) const {
   DOUT << "{ ";
   for (std::set<Value*>::iterator I = s.begin(), E = s.end();
        I != E; ++I) {
@@ -512,8 +512,8 @@ bool GVNPRE::runOnFunction(Function &F) {
           
           std::set<Value*, ExprLT>::iterator val = availOut.find(*I);
           if (val != availOut.end())
-            new_set.erase(val);
-          new_set.insert(*I);
+            availOut.erase(val);
+          availOut.insert(*I);
         }
       }