Adjust to changes in the User class.
[oota-llvm.git] / include / llvm / GlobalValue.h
index d97c3677a471394bea525fe4cc9778091f5b3f56..60176c588d37a4fd66d6cbecb935f1b3f7a28afe 100644 (file)
@@ -32,17 +32,20 @@ public:
     LinkOnceLinkage,   // Keep one copy of named function when linking (inline)
     WeakLinkage,       // Keep one copy of named function when linking (weak)
     AppendingLinkage,  // Special purpose, only applies to global arrays
-    InternalLinkage    // Rename collisions when linking (static functions)
+    InternalLinkage,   // Rename collisions when linking (static functions)
+    GhostLinkage       // Stand-in functions for streaming fns from BC files
   };
 protected:
-  GlobalValue(const Type *Ty, ValueTy vty, LinkageTypes linkage,
-             const std::string &name = "")
-    : Constant(Ty, vty, name), Linkage(linkage), Parent(0) { }
+  GlobalValue(const Type *Ty, ValueTy vty, Use *Ops, unsigned NumOps,
+              LinkageTypes linkage, const std::string &name = "")
+    : Constant(Ty, vty, Ops, NumOps, name), Linkage(linkage), Parent(0) { }
 
   LinkageTypes Linkage;   // The linkage of this global
   Module *Parent;
 public:
-  virtual ~GlobalValue();
+  ~GlobalValue() {
+    removeDeadConstantUsers();   // remove any dead constants using this.
+  }
 
   /// If the usage is empty (except transitively dead constants), then this
   /// global value can can be safely deleted since the destructor will 
@@ -64,8 +67,15 @@ public:
   void setLinkage(LinkageTypes LT) { Linkage = LT; }
   LinkageTypes getLinkage() const { return Linkage; }
 
-  /// Override from Constant class. No GlobalValue's have null values so
-  /// this always returns false.
+  /// hasNotBeenReadFromBytecode - If a module provider is being used to lazily
+  /// stream in functions from disk, this method can be used to check to see if
+  /// the function has been read in yet or not.  Unless you are working on the
+  /// JIT or something else that streams stuff in lazily, you don't need to
+  /// worry about this.
+  bool hasNotBeenReadFromBytecode() const { return Linkage == GhostLinkage; }
+
+  /// Override from Constant class. No GlobalValue's are null values so this
+  /// always returns false.
   virtual bool isNullValue() const { return false; }
 
   /// Override from Constant class.
@@ -85,10 +95,10 @@ public:
   /// that want to check to see if a global is unused, but don't want to deal
   /// with potentially dead constants hanging off of the globals.
   ///
-  /// This function returns true if the global value is now dead.  If all 
-  /// users of this global are not dead, this method may return false and
-  /// leave some of them around.
-  bool removeDeadConstantUsers();
+  /// This method tries to make the global dead.  If it detects a user that
+  /// would prevent it from becoming completely dead, it gives up early,
+  /// potentially leaving some dead constant users around.
+  void removeDeadConstantUsers();
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const GlobalValue *T) { return true; }