mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 22:24:54 +00:00
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
This commit is contained in:
@@ -31,16 +31,17 @@ using namespace llvm;
|
||||
|
||||
void MDString::anchor() { }
|
||||
|
||||
MDString::MDString(LLVMContext &C, StringRef S)
|
||||
: Value(Type::getMetadataTy(C), Value::MDStringVal), Str(S) {}
|
||||
MDString::MDString(LLVMContext &C)
|
||||
: Value(Type::getMetadataTy(C), Value::MDStringVal) {}
|
||||
|
||||
MDString *MDString::get(LLVMContext &Context, StringRef Str) {
|
||||
LLVMContextImpl *pImpl = Context.pImpl;
|
||||
StringMapEntry<MDString *> &Entry =
|
||||
StringMapEntry<Value*> &Entry =
|
||||
pImpl->MDStringCache.GetOrCreateValue(Str);
|
||||
MDString *&S = Entry.getValue();
|
||||
if (!S) S = new MDString(Context, Entry.getKey());
|
||||
return S;
|
||||
Value *&S = Entry.getValue();
|
||||
if (!S) S = new MDString(Context);
|
||||
S->setValueName(&Entry);
|
||||
return cast<MDString>(S);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
Reference in New Issue
Block a user