Improve compatibility with aCC on HPUX. Patch by Duraid Madina
[oota-llvm.git] / include / llvm / GlobalValue.h
index f72c4740ce39f5228cf9ff5fa8a3587669d6856e..12863a2c139efb401f4c06588de4b85699279e5c 100644 (file)
@@ -32,7 +32,8 @@ 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,
@@ -42,12 +43,14 @@ protected:
   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 wll 
+  /// global value can can be safely deleted since the destructor will 
   /// delete the dead constants as well.
-  /// @brief Determine if theusage of this global value is empty except 
+  /// @brief Determine if the usage of this global value is empty except 
   /// for transitively dead constants.
   bool use_empty_except_constants();
 
@@ -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; }