From 0a0193edf9152bdc47a49a1a513d6e9cbf723131 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 4 Aug 2009 04:31:02 +0000 Subject: [PATCH] switch ValueMap to using AssertingVH. This is an old patch I had laying around in a tree I forgot about. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78048 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Value.h | 2 +- include/llvm/ValueSymbolTable.h | 3 ++- lib/Bitcode/Writer/BitcodeWriter.cpp | 2 +- lib/VMCore/Value.cpp | 16 ++++++++-------- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/include/llvm/Value.h b/include/llvm/Value.h index b1db1ce3e1e..a7f8774e036 100644 --- a/include/llvm/Value.h +++ b/include/llvm/Value.h @@ -38,7 +38,7 @@ class TypeSymbolTable; template class StringMapEntry; template class AssertingVH; -typedef StringMapEntry ValueName; +typedef StringMapEntry > ValueName; class raw_ostream; class AssemblyAnnotationWriter; class ValueHandleBase; diff --git a/include/llvm/ValueSymbolTable.h b/include/llvm/ValueSymbolTable.h index 4f8ebe80017..9b4ccbaf8f3 100644 --- a/include/llvm/ValueSymbolTable.h +++ b/include/llvm/ValueSymbolTable.h @@ -17,6 +17,7 @@ #include "llvm/Value.h" #include "llvm/ADT/StringMap.h" #include "llvm/Support/DataTypes.h" +#include "llvm/Support/ValueHandle.h" namespace llvm { template @@ -44,7 +45,7 @@ class ValueSymbolTable { /// @{ public: /// @brief A mapping of names to values. - typedef StringMap ValueMap; + typedef StringMap > ValueMap; /// @brief An iterator over a ValueMap. typedef ValueMap::iterator iterator; diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp index 4b925163954..724e1aeb15c 100644 --- a/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -1083,7 +1083,7 @@ static void WriteValueSymbolTable(const ValueSymbolTable &VST, // VST_ENTRY: [valueid, namechar x N] // VST_BBENTRY: [bbid, namechar x N] unsigned Code; - if (isa(SI->getValue())) { + if (isa(*SI->getValue())) { Code = bitc::VST_CODE_BBENTRY; if (isChar6) AbbrevToUse = VST_BBENTRY_6_ABBREV; diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp index 2cdd55217cc..8710b9461e8 100644 --- a/lib/VMCore/Value.cpp +++ b/lib/VMCore/Value.cpp @@ -57,6 +57,14 @@ Value::Value(const Type *ty, unsigned scid) } Value::~Value() { + // If this value is named, destroy the name. This should not be in a symtab + // at this point. + if (Name) + Name->Destroy(); + + // There should be no uses of this object anymore, remove it. + LeakDetector::removeGarbageObject(this); + // Notify all ValueHandles (if present) that this value is going away. if (HasValueHandle) ValueHandleBase::ValueIsDeleted(this); @@ -76,14 +84,6 @@ Value::~Value() { } #endif assert(use_empty() && "Uses remain when a value is destroyed!"); - - // If this value is named, destroy the name. This should not be in a symtab - // at this point. - if (Name) - Name->Destroy(); - - // There should be no uses of this object anymore, remove it. - LeakDetector::removeGarbageObject(this); } /// hasNUses - Return true if this Value has exactly N users.