X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FVMCore%2FFunction.cpp;h=bf9c8b48bdeef7b1ed5837cad7ee21ee6f1b2b9b;hb=068758e518f0fe4ab67490f2eec0fd3b376a4d2c;hp=d12c4dd44f583b56320b2d709267f7b473519942;hpb=88e2b780cbac5b5902e1c2813f3e920286b6d9a8;p=oota-llvm.git diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index d12c4dd44f5..bf9c8b48bde 100644 --- a/lib/VMCore/Function.cpp +++ b/lib/VMCore/Function.cpp @@ -15,7 +15,7 @@ #include "llvm/Module.h" #include "llvm/Constant.h" #include "llvm/DerivedTypes.h" -#include "llvm/iOther.h" +#include "llvm/Instructions.h" #include "llvm/Intrinsics.h" #include "Support/LeakDetector.h" #include "SymbolTableListTraitsImpl.h" @@ -68,7 +68,7 @@ Argument::Argument(const Type *Ty, const std::string &Name, Function *Par) 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 @@ void Argument::setParent(Function *parent) { LeakDetector::removeGarbageObject(this); } -static bool removeDeadConstantUsers(Constant *C) { - while (!C->use_empty()) { - if (Constant *CU = dyn_cast(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(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 @@ Function::~Function() { 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 @@ unsigned Function::getIntrinsicID() const { } -//===----------------------------------------------------------------------===// -// 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