diff options
author | Bill Wendling <isanbard@gmail.com> | 2012-04-10 20:12:16 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2012-04-10 20:12:16 +0000 |
commit | 3ecb447f52d169dea6663b95b5b5b43e9bb5826b (patch) | |
tree | 2e5526e4b3fbb284b6753241cd0f87769c7732b3 /lib/VMCore/Value.cpp | |
parent | 7f1f1453895431f948abbb5d9bf09b4faf87926a (diff) | |
download | external_llvm-3ecb447f52d169dea6663b95b5b5b43e9bb5826b.zip external_llvm-3ecb447f52d169dea6663b95b5b5b43e9bb5826b.tar.gz external_llvm-3ecb447f52d169dea6663b95b5b5b43e9bb5826b.tar.bz2 |
The MDString class stored a StringRef to the string which was already in a
StringMap. This was redundant and unnecessarily bloated the MDString class.
Because the MDString class is a "Value" and will never have a "name", and
because the Name field in the Value class is a pointer to a StringMap entry, we
repurpose the Name field for an MDString. It stores the StringMap entry in the
Name field, and uses the normal methods to get the string (name) back.
PR12474
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154429 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Value.cpp')
-rw-r--r-- | lib/VMCore/Value.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp index 788f419..4006b2c 100644 --- a/lib/VMCore/Value.cpp +++ b/lib/VMCore/Value.cpp @@ -76,7 +76,7 @@ Value::~Value() { // If this value is named, destroy the name. This should not be in a symtab // at this point. - if (Name) + if (Name && SubclassID != MDStringVal) Name->Destroy(); // There should be no uses of this object anymore, remove it. @@ -170,6 +170,9 @@ StringRef Value::getName() const { } void Value::setName(const Twine &NewName) { + assert(SubclassID != MDStringVal && + "Cannot set the name of MDString with this method!"); + // Fast path for common IRBuilder case of setName("") when there is no name. if (NewName.isTriviallyEmpty() && !hasName()) return; @@ -228,6 +231,8 @@ void Value::setName(const Twine &NewName) { /// takeName - transfer the name from V to this value, setting V's name to /// empty. It is an error to call V->takeName(V). void Value::takeName(Value *V) { + assert(SubclassID != MDStringVal && "Cannot take the name of an MDString!"); + ValueSymbolTable *ST = 0; // If this value has a name, drop it. if (hasName()) { |