Remove unused GlobalVariable::replaceUsesOfWithOnConstant. NFC.
authorPete Cooper <peter_cooper@apple.com>
Wed, 24 Jun 2015 00:05:07 +0000 (00:05 +0000)
committerPete Cooper <peter_cooper@apple.com>
Wed, 24 Jun 2015 00:05:07 +0000 (00:05 +0000)
The only caller of this method is Value::replaceAllUsesWith which
explicitly checks that we are not a GlobalValue.  So replace the
body with an unreachable to ensure that we never call it.

The unreachable itself is moved to GlobalValue not GlobalVariable
as that is the base class of all the globals we don't want to call
this method on.

Note, this patch is short lived as i'll soon refactor all callers
of this method.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240486 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/GlobalValue.h
include/llvm/IR/GlobalVariable.h
lib/IR/Globals.cpp

index c2a9d7e47550f21d2708d87a730dbe4d5896e2ef..4bca80edb4d319e38c29b7b997ca6e27393ff2b5 100644 (file)
@@ -92,6 +92,7 @@ private:
 
   friend class Constant;
   void destroyConstantImpl();
+  void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U) override;
 
 protected:
   /// \brief The intrinsic ID for this subclass (which must be a Function).
index 126bebbdcb15743e79ca0d0554999959199ae8b5..7b291605d45b813f012d2f686382a95322ade4ce 100644 (file)
@@ -166,10 +166,6 @@ public:
   ///
   void eraseFromParent() override;
 
-  /// Override Constant's implementation of this method so we can
-  /// replace constant initializers.
-  void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U) override;
-
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const Value *V) {
     return V->getValueID() == Value::GlobalVariableVal;
index a431b5c61007129197f0e3af3babe364474ff480..49ac236778cf6b3bfd3cf6ce1dccd6501825f6a7 100644 (file)
@@ -48,6 +48,10 @@ void GlobalValue::destroyConstantImpl() {
   llvm_unreachable("You can't GV->destroyConstantImpl()!");
 }
 
+void GlobalValue::replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U) {
+  llvm_unreachable("You can't GV->replaceUsesOfWithOnConstant()!");
+}
+
 /// copyAttributesFrom - copy all additional attributes (those not needed to
 /// create a GlobalValue) from the GlobalValue Src to this one.
 void GlobalValue::copyAttributesFrom(const GlobalValue *Src) {
@@ -191,26 +195,6 @@ void GlobalVariable::eraseFromParent() {
   getParent()->getGlobalList().erase(this);
 }
 
-void GlobalVariable::replaceUsesOfWithOnConstant(Value *From, Value *To,
-                                                 Use *U) {
-  // If you call this, then you better know this GVar has a constant
-  // initializer worth replacing. Enforce that here.
-  assert(getNumOperands() == 1 &&
-         "Attempt to replace uses of Constants on a GVar with no initializer");
-
-  // And, since you know it has an initializer, the From value better be
-  // the initializer :)
-  assert(getOperand(0) == From &&
-         "Attempt to replace wrong constant initializer in GVar");
-
-  // And, you better have a constant for the replacement value
-  assert(isa<Constant>(To) &&
-         "Attempt to replace GVar initializer with non-constant");
-
-  // Okay, preconditions out of the way, replace the constant initializer.
-  this->setOperand(0, cast<Constant>(To));
-}
-
 void GlobalVariable::setInitializer(Constant *InitVal) {
   if (!InitVal) {
     if (hasInitializer()) {