the verifier shouldn't modify the IR.
authorChris Lattner <sabre@nondot.org>
Sun, 1 Nov 2009 18:11:50 +0000 (18:11 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 1 Nov 2009 18:11:50 +0000 (18:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85722 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/BasicBlock.h
include/llvm/Constant.h
lib/VMCore/Constants.cpp
lib/VMCore/Globals.cpp
lib/VMCore/Verifier.cpp

index 11afa4047787bedd986c9f5b651774eb26a391e9..ba4caeb96a529e1deda09e58ed0784e5d340a577 100644 (file)
@@ -241,9 +241,6 @@ public:
   /// other than direct branches, switches, etc. to it.
   bool hasAddressTaken() const { return SubclassData != 0; }
                      
-  /// removeDeadBlockAddress - If there is a blockaddress node for this basic
-  /// block, try to remove it and any dead constant users of it.
-  void removeDeadBlockAddress();
 private:
   /// AdjustBlockAddressRefCount - BasicBlock stores the number of BlockAddress
   /// objects using it.  This is almost always 0, sometimes one, possibly but
index bcaa56e3902b10e0ea8c6bd84eed3d4cd50c850c..8072fd9f498a1bbe6ba967bc28e638c5218533c7 100644 (file)
@@ -65,6 +65,10 @@ public:
   /// true for things like constant expressions that could divide by zero.
   bool canTrap() const;
 
+  /// isConstantUsed - Return true if the constant has users other than constant
+  /// exprs and other dangling things.
+  bool isConstantUsed() const;
+  
   enum PossibleRelocationsTy {
     NoRelocation = 0,
     LocalRelocation = 1,
index fe4f90af06da50bc92a92f50130e6c7a96586017..e2e5396da5f909b3c1c58f40b99189661cf8d3ae 100644 (file)
@@ -160,6 +160,21 @@ bool Constant::canTrap() const {
   }
 }
 
+/// isConstantUsed - Return true if the constant has users other than constant
+/// exprs and other dangling things.
+bool Constant::isConstantUsed() const {
+  for (use_const_iterator UI = use_begin(), E = use_end(); UI != E; ++UI) {
+    const Constant *UC = dyn_cast<Constant>(*UI);
+    if (UC == 0 || isa<GlobalValue>(UC))
+      return true;
+    
+    if (UC->isConstantUsed())
+      return true;
+  }
+  return false;
+}
+
+
 
 /// getRelocationInfo - This method classifies the entry according to
 /// whether or not it may generate a relocation entry.  This must be
index 763fc721e09b63986778d4b1e40c00f0709df7eb..03ceecb6f1aff3cbbae5473a90389e76fd2967ca 100644 (file)
@@ -75,13 +75,6 @@ void GlobalValue::removeDeadConstantUsers() const {
   }
 }
 
-/// removeDeadBlockAddress - If there is a blockaddress node for this basic
-/// block, try to remove it and any dead constant users of it.
-void BasicBlock::removeDeadBlockAddress() {
-  if (!hasAddressTaken()) return;
-  removeDeadUsersOfConstant(BlockAddress::get(this));
-}
-
 
 /// Override destroyConstant to make sure it doesn't get called on
 /// GlobalValue's because they shouldn't be treated like other constants.
index 6b10d69ac5ed0b286223693cefe46f73639d20dd..5990e481686c96231df856e662fa8e533a5a8a9d 100644 (file)
@@ -661,8 +661,7 @@ void Verifier::visitFunction(Function &F) {
     
     // The address of the entry block cannot be taken, unless it is dead.
     if (Entry->hasAddressTaken()) {
-      Entry->removeDeadBlockAddress();
-      Assert1(!Entry->hasAddressTaken(),
+      Assert1(!BlockAddress::get(Entry)->isConstantUsed(),
               "blockaddress may not be used with the entry block!", Entry);
     }
   }