diff options
author | Owen Anderson <resistor@mac.com> | 2009-07-16 22:11:26 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-07-16 22:11:26 +0000 |
commit | 69ab416d66fbf62e2f5b91b0814f4b7eab436c3d (patch) | |
tree | e5ce2ca69c74da05bfd8ed16556f0294cf912b0b /llvm/lib/VMCore/LLVMContextImpl.cpp | |
parent | 54c596465d9fd58df57b91651dbe93473f6332f2 (diff) | |
download | bcm5719-llvm-69ab416d66fbf62e2f5b91b0814f4b7eab436c3d.tar.gz bcm5719-llvm-69ab416d66fbf62e2f5b91b0814f4b7eab436c3d.zip |
Privatize the MDString uniquing table.
llvm-svn: 76113
Diffstat (limited to 'llvm/lib/VMCore/LLVMContextImpl.cpp')
-rw-r--r-- | llvm/lib/VMCore/LLVMContextImpl.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/llvm/lib/VMCore/LLVMContextImpl.cpp b/llvm/lib/VMCore/LLVMContextImpl.cpp index 4c6319ea92c..93b9e7d3a53 100644 --- a/llvm/lib/VMCore/LLVMContextImpl.cpp +++ b/llvm/lib/VMCore/LLVMContextImpl.cpp @@ -78,4 +78,23 @@ ConstantFP *LLVMContextImpl::getConstantFP(const APFloat &V) { } return Slot; -}
\ No newline at end of file +} + +MDString *LLVMContextImpl::getMDString(const char *StrBegin, + const char *StrEnd) { + sys::SmartScopedWriter<true> Writer(ConstantsLock); + StringMapEntry<MDString *> &Entry = MDStringCache.GetOrCreateValue( + StrBegin, StrEnd); + MDString *&S = Entry.getValue(); + if (!S) S = new MDString(Entry.getKeyData(), + Entry.getKeyData() + Entry.getKeyLength()); + + return S; +} + +// *** erase methods *** + +void LLVMContextImpl::erase(MDString *M) { + sys::SmartScopedWriter<true> Writer(ConstantsLock); + MDStringCache.erase(MDStringCache.find(M->StrBegin, M->StrEnd)); +} |