[llvm-commits] [poolalloc] r58733 - /poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp

Andrew Lenharth alenhar2 at cs.uiuc.edu
Tue Nov 4 15:43:42 PST 2008


Author: alenhar2
Date: Tue Nov  4 17:43:42 2008
New Revision: 58733

URL: http://llvm.org/viewvc/llvm-project?rev=58733&view=rev
Log:
replaceUsesOfWith is not valid on constants, replaceAllUsesOfWith is though.  This might cover the constant case.  Alternate idea is to keep track of what shouldn't change and undo the change for those afterwards

Modified:
    poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp

Modified: poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp?rev=58733&r1=58732&r2=58733&view=diff

==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp Tue Nov  4 17:43:42 2008
@@ -194,8 +194,17 @@
             continue;
       }
 
-      User->replaceUsesOfWith (F, ConstantExpr::getPointerCast(I->second,
-                                                               F->getType()));
+      Constant* CEnew = ConstantExpr::getPointerCast(I->second, F->getType());
+
+      // Must handle Constants specially, we cannot call replaceUsesOfWith on a
+      // constant because they are uniqued.
+      if (Constant *C = dyn_cast<Constant>(User)) {
+        if (!isa<GlobalValue>(C)) {
+          C->replaceUsesOfWithOnConstant(F, CEnew, User->op_begin());
+          continue;
+        }
+      }
+      User->replaceUsesOfWith (F, CEnew);
     }
   }
 





More information about the llvm-commits mailing list