[llvm-commits] CVS: llvm/lib/VMCore/Function.cpp

LLVM llvm at cs.uiuc.edu
Sat Jul 17 16:50:29 PDT 2004



Changes in directory llvm/lib/VMCore:

Function.cpp updated: 1.75 -> 1.76

---
Log message:

bug 122: http://llvm.cs.uiuc.edu/PR122 :
- Move GlobalValue and GlobalVariable implementations to Globals.cpp


---
Diffs of the changes:  (+3 -72)

Index: llvm/lib/VMCore/Function.cpp
diff -u llvm/lib/VMCore/Function.cpp:1.75 llvm/lib/VMCore/Function.cpp:1.76
--- llvm/lib/VMCore/Function.cpp:1.75	Mon Jul 12 15:27:31 2004
+++ llvm/lib/VMCore/Function.cpp	Sat Jul 17 18:50:19 2004
@@ -68,7 +68,7 @@
 void Argument::setName(const std::string &name, SymbolTable *ST) {
   Function *P;
   assert((ST == 0 || (!getParent() || ST == &getParent()->getSymbolTable())) &&
-	 "Invalid symtab argument!");
+         "Invalid symtab argument!");
   if ((P = getParent()) && hasName()) P->getSymbolTable().remove(this);
   Value::setName(name);
   if (P && hasName()) P->getSymbolTable().insert(this);
@@ -82,42 +82,6 @@
     LeakDetector::removeGarbageObject(this);
 }
 
-static bool removeDeadConstantUsers(Constant *C) {
-  while (!C->use_empty()) {
-    if (Constant *CU = dyn_cast<Constant>(C->use_back())) {
-      if (!removeDeadConstantUsers(CU))
-        return false;  // Constant wasn't dead.
-    } else {
-      return false;    // Nonconstant user of the global.
-    }
-  }
-
-  C->destroyConstant();
-  return true;
-}
-
-
-/// removeDeadConstantUsers - If there are any dead constant users dangling
-/// off of this global value, remove them.  This method is useful for clients
-/// 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 GlobalValue::removeDeadConstantUsers() {
-  while (!use_empty()) {
-    if (Constant *C = dyn_cast<Constant>(use_back())) {
-      if (!::removeDeadConstantUsers(C))
-        return false;  // Constant wasn't dead.
-    } else {
-      return false;    // Nonconstant user of the global.
-    }
-  }
-  return true;
-}
-
-
 //===----------------------------------------------------------------------===//
 // Function Implementation
 //===----------------------------------------------------------------------===//
@@ -161,7 +125,7 @@
 void Function::setName(const std::string &name, SymbolTable *ST) {
   Module *P;
   assert((ST == 0 || (!getParent() || ST == &getParent()->getSymbolTable())) &&
-	 "Invalid symtab argument!");
+         "Invalid symtab argument!");
   if ((P = getParent()) && hasName()) P->getSymbolTable().remove(this);
   Value::setName(name);
   if (P && hasName()) P->getSymbolTable().insert(this);
@@ -294,37 +258,4 @@
 }
 
 
-//===----------------------------------------------------------------------===//
-// GlobalVariable Implementation
-//===----------------------------------------------------------------------===//
-
-GlobalVariable::GlobalVariable(const Type *Ty, bool constant, LinkageTypes Link,
-			       Constant *Initializer,
-			       const std::string &Name, Module *ParentModule)
-  : GlobalValue(PointerType::get(Ty), Value::GlobalVariableVal, Link, Name),
-    isConstantGlobal(constant) {
-  if (Initializer) Operands.push_back(Use((Value*)Initializer, this));
-
-  LeakDetector::addGarbageObject(this);
-
-  if (ParentModule)
-    ParentModule->getGlobalList().push_back(this);
-}
-
-void GlobalVariable::setParent(Module *parent) {
-  if (getParent())
-    LeakDetector::addGarbageObject(this);
-  Parent = parent;
-  if (getParent())
-    LeakDetector::removeGarbageObject(this);
-}
-
-// Specialize setName to take care of symbol table majik
-void GlobalVariable::setName(const std::string &name, SymbolTable *ST) {
-  Module *P;
-  assert((ST == 0 || (!getParent() || ST == &getParent()->getSymbolTable())) &&
-	 "Invalid symtab argument!");
-  if ((P = getParent()) && hasName()) P->getSymbolTable().remove(this);
-  Value::setName(name);
-  if (P && hasName()) P->getSymbolTable().insert(this);
-}
+// vim: sw=2 ai





More information about the llvm-commits mailing list