[llvm-commits] [llvm] r85701 - /llvm/trunk/lib/VMCore/Constants.cpp

Chris Lattner sabre at nondot.org
Sat Oct 31 20:03:04 PDT 2009


Author: lattner
Date: Sat Oct 31 22:03:03 2009
New Revision: 85701

URL: http://llvm.org/viewvc/llvm-project?rev=85701&view=rev
Log:
Fix BlockAddress::replaceUsesOfWithOnConstant to correctly 
maintain the block use count in SubclassData.

Modified:
    llvm/trunk/lib/VMCore/Constants.cpp

Modified: llvm/trunk/lib/VMCore/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=85701&r1=85700&r2=85701&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Constants.cpp (original)
+++ llvm/trunk/lib/VMCore/Constants.cpp Sat Oct 31 22:03:03 2009
@@ -7,7 +7,7 @@
 //
 //===----------------------------------------------------------------------===//
 //
-// This file implements the Constant* classes...
+// This file implements the Constant* classes.
 //
 //===----------------------------------------------------------------------===//
 
@@ -1043,8 +1043,8 @@
 BlockAddress::BlockAddress(Function *F, BasicBlock *BB)
 : Constant(Type::getInt8PtrTy(F->getContext()), Value::BlockAddressVal,
            &Op<0>(), 2) {
-  Op<0>() = F;
-  Op<1>() = BB;
+  setOperand(0, F);
+  setOperand(1, BB);
   BB->AdjustBlockAddressRefCount(1);
 }
 
@@ -1074,13 +1074,16 @@
   BlockAddress *&NewBA =
     getContext().pImpl->BlockAddresses[std::make_pair(NewF, NewBB)];
   if (NewBA == 0) {
+    getBasicBlock()->AdjustBlockAddressRefCount(-1);
+    
     // Remove the old entry, this can't cause the map to rehash (just a
     // tombstone will get added).
     getContext().pImpl->BlockAddresses.erase(std::make_pair(getFunction(),
                                                             getBasicBlock()));
     NewBA = this;
-    Op<0>() = NewF;
-    Op<1>() = NewBB;
+    setOperand(0, NewF);
+    setOperand(1, NewBB);
+    getBasicBlock()->AdjustBlockAddressRefCount(1);
     return;
   }
 





More information about the llvm-commits mailing list