aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore/Constants.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-11-01 03:03:03 +0000
committerChris Lattner <sabre@nondot.org>2009-11-01 03:03:03 +0000
commitd0ec2352ae14acd4526ac04783e28c3280a26fb8 (patch)
tree3c4602a3213759b018e7b5a42b37fb823dafafef /lib/VMCore/Constants.cpp
parent2a749d36475bda8964e996725ea101aec3ee15cf (diff)
downloadexternal_llvm-d0ec2352ae14acd4526ac04783e28c3280a26fb8.zip
external_llvm-d0ec2352ae14acd4526ac04783e28c3280a26fb8.tar.gz
external_llvm-d0ec2352ae14acd4526ac04783e28c3280a26fb8.tar.bz2
Fix BlockAddress::replaceUsesOfWithOnConstant to correctly
maintain the block use count in SubclassData. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85701 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Constants.cpp')
-rw-r--r--lib/VMCore/Constants.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index 2d3d71b..fe4f90a 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This file implements the Constant* classes...
+// This file implements the Constant* classes.
//
//===----------------------------------------------------------------------===//
@@ -1043,8 +1043,8 @@ BlockAddress *BlockAddress::get(Function *F, BasicBlock *BB) {
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 @@ void BlockAddress::replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U) {
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;
}