- Context(C), TheTrueVal(0), TheFalseVal(0) { }
-
-MDString *LLVMContextImpl::getMDString(const char *StrBegin,
- unsigned StrLength) {
- sys::SmartScopedWriter<true> Writer(ConstantsLock);
- StringMapEntry<MDString *> &Entry =
- MDStringCache.GetOrCreateValue(StringRef(StrBegin, StrLength));
- MDString *&S = Entry.getValue();
- if (!S) S = new MDString(Entry.getKeyData(),
- Entry.getKeyLength());
-
- return S;
-}
-
-MDNode *LLVMContextImpl::getMDNode(Value*const* Vals, unsigned NumVals) {
- FoldingSetNodeID ID;
- for (unsigned i = 0; i != NumVals; ++i)
- ID.AddPointer(Vals[i]);
-
- ConstantsLock.reader_acquire();
- void *InsertPoint;
- MDNode *N = MDNodeSet.FindNodeOrInsertPos(ID, InsertPoint);
- ConstantsLock.reader_release();
-
- if (!N) {
- sys::SmartScopedWriter<true> Writer(ConstantsLock);
- N = MDNodeSet.FindNodeOrInsertPos(ID, InsertPoint);
- if (!N) {
- // InsertPoint will have been set by the FindNodeOrInsertPos call.
- N = new MDNode(Vals, NumVals);
- MDNodeSet.InsertNode(N, InsertPoint);
- }
- }
-
- return N;
-}
-
-// *** erase methods ***
-
-void LLVMContextImpl::erase(MDString *M) {
- sys::SmartScopedWriter<true> Writer(ConstantsLock);
- MDStringCache.erase(MDStringCache.find(M->getString()));
-}
-
-void LLVMContextImpl::erase(MDNode *M) {
- sys::SmartScopedWriter<true> Writer(ConstantsLock);
- MDNodeSet.RemoveNode(M);
-}