diff options
author | Chris Lattner <sabre@nondot.org> | 2004-07-18 08:12:57 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-07-18 08:12:57 +0000 |
commit | da6cdfa9e885ab8e1eb53b984c0ee77d0d64cd5e (patch) | |
tree | 3c5682df984f68064a685b505add14a6e6db0b86 | |
parent | 67910e1eb024bb78cab2f4ffb48c3a79b5647f64 (diff) |
Fix infinite loop gccld'ing povray
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14962 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/VMCore/Globals.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/VMCore/Globals.cpp b/lib/VMCore/Globals.cpp index 0e8227bdeb..e35d801f8a 100644 --- a/lib/VMCore/Globals.cpp +++ b/lib/VMCore/Globals.cpp @@ -17,7 +17,6 @@ #include "llvm/Module.h" #include "llvm/SymbolTable.h" #include "Support/LeakDetector.h" - using namespace llvm; //===----------------------------------------------------------------------===// @@ -28,21 +27,20 @@ using namespace llvm; /// there are no non-constant uses of this GlobalValue. If there aren't then /// this and the transitive closure of the constants can be deleted. See the /// destructor for details. -namespace { -bool removeDeadConstantUsers(Constant* C) { - while (!C->use_empty()) { +static bool removeDeadConstantUsers(Constant* C) { + if (isa<GlobalValue>(C)) return false; // Cannot remove this + + while (!C->use_empty()) if (Constant *User = dyn_cast<Constant>(C->use_back())) { if (!removeDeadConstantUsers(User)) return false; // Constant wasn't dead } else { return false; // Non-constant usage; } - } - if (!isa<GlobalValue>(C)) - C->destroyConstant(); + + 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 |