From d0ff1adbdb4b7b565b7f8f191aac0731e80aa1ef Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 4 Oct 2005 18:13:04 +0000 Subject: [PATCH] Change the signature of replaceUsesOfWithOnConstant. The bool was always true dynamically. Finally, pass the Use* that replaceAllUsesWith has into the method for future use. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23626 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/Constants.cpp | 44 +++++++++++----------------------------- lib/VMCore/Globals.cpp | 5 +---- lib/VMCore/Value.cpp | 2 +- 3 files changed, 14 insertions(+), 37 deletions(-) diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index c03d9526e05..0f0894bc53e 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -815,14 +815,6 @@ void ConstantAggregateZero::destroyConstant() { destroyConstantImpl(); } -void ConstantAggregateZero::replaceUsesOfWithOnConstant(Value *From, Value *To, - bool DisableChecking) { - assert(0 && "No uses!"); - abort(); -} - - - //---- ConstantArray::get() implementation... // namespace llvm { @@ -1395,7 +1387,7 @@ const char *ConstantExpr::getOpcodeName() const { // replaceUsesOfWithOnConstant implementations void ConstantArray::replaceUsesOfWithOnConstant(Value *From, Value *To, - bool DisableChecking) { + Use *U) { assert(isa(To) && "Cannot make Constant refer to non-constant!"); Constant *ToC = cast(To); @@ -1448,18 +1440,15 @@ void ConstantArray::replaceUsesOfWithOnConstant(Value *From, Value *To, // Otherwise, I do need to replace this with an existing value. assert(Replacement != this && "I didn't contain From!"); - // Everyone using this now uses the replacement... - if (DisableChecking) - uncheckedReplaceAllUsesWith(Replacement); - else - replaceAllUsesWith(Replacement); + // Everyone using this now uses the replacement. + uncheckedReplaceAllUsesWith(Replacement); // Delete the old constant! destroyConstant(); } void ConstantStruct::replaceUsesOfWithOnConstant(Value *From, Value *To, - bool DisableChecking) { + Use *U) { assert(isa(To) && "Cannot make Constant refer to non-constant!"); Constant *ToC = cast(To); @@ -1511,18 +1500,15 @@ void ConstantStruct::replaceUsesOfWithOnConstant(Value *From, Value *To, assert(Replacement != this && "I didn't contain From!"); - // Everyone using this now uses the replacement... - if (DisableChecking) - uncheckedReplaceAllUsesWith(Replacement); - else - replaceAllUsesWith(Replacement); + // Everyone using this now uses the replacement. + uncheckedReplaceAllUsesWith(Replacement); // Delete the old constant! destroyConstant(); } void ConstantPacked::replaceUsesOfWithOnConstant(Value *From, Value *To, - bool DisableChecking) { + Use *U) { assert(isa(To) && "Cannot make Constant refer to non-constant!"); std::vector Values; @@ -1536,18 +1522,15 @@ void ConstantPacked::replaceUsesOfWithOnConstant(Value *From, Value *To, Constant *Replacement = ConstantPacked::get(getType(), Values); assert(Replacement != this && "I didn't contain From!"); - // Everyone using this now uses the replacement... - if (DisableChecking) - uncheckedReplaceAllUsesWith(Replacement); - else - replaceAllUsesWith(Replacement); + // Everyone using this now uses the replacement. + uncheckedReplaceAllUsesWith(Replacement); // Delete the old constant! destroyConstant(); } void ConstantExpr::replaceUsesOfWithOnConstant(Value *From, Value *ToV, - bool DisableChecking) { + Use *U) { assert(isa(ToV) && "Cannot make Constant refer to non-constant!"); Constant *To = cast(ToV); @@ -1588,11 +1571,8 @@ void ConstantExpr::replaceUsesOfWithOnConstant(Value *From, Value *ToV, assert(Replacement != this && "I didn't contain From!"); - // Everyone using this now uses the replacement... - if (DisableChecking) - uncheckedReplaceAllUsesWith(Replacement); - else - replaceAllUsesWith(Replacement); + // Everyone using this now uses the replacement. + uncheckedReplaceAllUsesWith(Replacement); // Delete the old constant! destroyConstant(); diff --git a/lib/VMCore/Globals.cpp b/lib/VMCore/Globals.cpp index 87eca2a9954..be6c6eb0537 100644 --- a/lib/VMCore/Globals.cpp +++ b/lib/VMCore/Globals.cpp @@ -108,7 +108,7 @@ void GlobalVariable::eraseFromParent() { } void GlobalVariable::replaceUsesOfWithOnConstant(Value *From, Value *To, - bool DisableChecking) { + Use *U) { // If you call this, then you better know this GVar has a constant // initializer worth replacing. Enforce that here. assert(getNumOperands() == 1 && @@ -126,6 +126,3 @@ void GlobalVariable::replaceUsesOfWithOnConstant(Value *From, Value *To, // Okay, preconditions out of the way, replace the constant initializer. this->setOperand(0, cast(To)); } - -// vim: sw=2 ai - diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp index f59e8ef957e..1f0c4442de8 100644 --- a/lib/VMCore/Value.cpp +++ b/lib/VMCore/Value.cpp @@ -141,7 +141,7 @@ void Value::uncheckedReplaceAllUsesWith(Value *New) { // constant! if (Constant *C = dyn_cast(U.getUser())) { if (!isa(C)) - C->replaceUsesOfWithOnConstant(this, New, true); + C->replaceUsesOfWithOnConstant(this, New, &U); else U.set(New); } else {