1 //===-- Metadata.cpp - Implement Metadata classes -------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the Metadata classes.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/IR/Metadata.h"
15 #include "LLVMContextImpl.h"
16 #include "SymbolTableListTraitsImpl.h"
17 #include "llvm/ADT/DenseMap.h"
18 #include "llvm/ADT/STLExtras.h"
19 #include "llvm/ADT/SmallSet.h"
20 #include "llvm/ADT/SmallString.h"
21 #include "llvm/ADT/StringMap.h"
22 #include "llvm/IR/ConstantRange.h"
23 #include "llvm/IR/Instruction.h"
24 #include "llvm/IR/LLVMContext.h"
25 #include "llvm/IR/LeakDetector.h"
26 #include "llvm/IR/Module.h"
27 #include "llvm/IR/ValueHandle.h"
30 //===----------------------------------------------------------------------===//
31 // MDString implementation.
34 void MDString::anchor() { }
36 MDString::MDString(LLVMContext &C)
37 : Value(Type::getMetadataTy(C), Value::MDStringVal) {}
39 MDString *MDString::get(LLVMContext &Context, StringRef Str) {
40 LLVMContextImpl *pImpl = Context.pImpl;
41 StringMapEntry<Value*> &Entry =
42 pImpl->MDStringCache.GetOrCreateValue(Str);
43 Value *&S = Entry.getValue();
44 if (!S) S = new MDString(Context);
45 S->setValueName(&Entry);
46 return cast<MDString>(S);
49 //===----------------------------------------------------------------------===//
50 // MDNodeOperand implementation.
53 // Use CallbackVH to hold MDNode operands.
55 class MDNodeOperand : public CallbackVH {
57 MDNodeOperand *Cur = this;
59 while (Cur->getValPtrInt() != 1)
62 assert(Cur->getValPtrInt() == 1 &&
63 "Couldn't find the beginning of the operand list!");
64 return reinterpret_cast<MDNode*>(Cur) - 1;
68 MDNodeOperand(Value *V) : CallbackVH(V) {}
69 virtual ~MDNodeOperand();
72 unsigned IsFirst = this->getValPtrInt();
74 this->setAsFirstOperand(IsFirst);
77 /// setAsFirstOperand - Accessor method to mark the operand as the first in
79 void setAsFirstOperand(unsigned V) { this->setValPtrInt(V); }
81 void deleted() override;
82 void allUsesReplacedWith(Value *NV) override;
84 } // end namespace llvm.
86 // Provide out-of-line definition to prevent weak vtable.
87 MDNodeOperand::~MDNodeOperand() {}
89 void MDNodeOperand::deleted() {
90 getParent()->replaceOperand(this, 0);
93 void MDNodeOperand::allUsesReplacedWith(Value *NV) {
94 getParent()->replaceOperand(this, NV);
97 //===----------------------------------------------------------------------===//
98 // MDNode implementation.
101 /// getOperandPtr - Helper function to get the MDNodeOperand's coallocated on
102 /// the end of the MDNode.
103 static MDNodeOperand *getOperandPtr(MDNode *N, unsigned Op) {
104 // Use <= instead of < to permit a one-past-the-end address.
105 assert(Op <= N->getNumOperands() && "Invalid operand number");
106 return reinterpret_cast<MDNodeOperand*>(N + 1) + Op;
109 void MDNode::replaceOperandWith(unsigned i, Value *Val) {
110 MDNodeOperand *Op = getOperandPtr(this, i);
111 replaceOperand(Op, Val);
114 MDNode::MDNode(LLVMContext &C, ArrayRef<Value*> Vals, bool isFunctionLocal)
115 : Value(Type::getMetadataTy(C), Value::MDNodeVal) {
116 NumOperands = Vals.size();
119 setValueSubclassData(getSubclassDataFromValue() | FunctionLocalBit);
121 // Initialize the operand list, which is co-allocated on the end of the node.
123 for (MDNodeOperand *Op = getOperandPtr(this, 0), *E = Op+NumOperands;
124 Op != E; ++Op, ++i) {
125 new (Op) MDNodeOperand(Vals[i]);
127 // Mark the first MDNodeOperand as being the first in the list of operands.
129 Op->setAsFirstOperand(1);
133 /// ~MDNode - Destroy MDNode.
135 assert((getSubclassDataFromValue() & DestroyFlag) != 0 &&
136 "Not being destroyed through destroy()?");
137 LLVMContextImpl *pImpl = getType()->getContext().pImpl;
138 if (isNotUniqued()) {
139 pImpl->NonUniquedMDNodes.erase(this);
141 pImpl->MDNodeSet.RemoveNode(this);
144 // Destroy the operands.
145 for (MDNodeOperand *Op = getOperandPtr(this, 0), *E = Op+NumOperands;
147 Op->~MDNodeOperand();
150 static const Function *getFunctionForValue(Value *V) {
152 if (Instruction *I = dyn_cast<Instruction>(V)) {
153 BasicBlock *BB = I->getParent();
154 return BB ? BB->getParent() : 0;
156 if (Argument *A = dyn_cast<Argument>(V))
157 return A->getParent();
158 if (BasicBlock *BB = dyn_cast<BasicBlock>(V))
159 return BB->getParent();
160 if (MDNode *MD = dyn_cast<MDNode>(V))
161 return MD->getFunction();
166 static const Function *assertLocalFunction(const MDNode *N) {
167 if (!N->isFunctionLocal()) return 0;
169 // FIXME: This does not handle cyclic function local metadata.
170 const Function *F = 0, *NewF = 0;
171 for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
172 if (Value *V = N->getOperand(i)) {
173 if (MDNode *MD = dyn_cast<MDNode>(V))
174 NewF = assertLocalFunction(MD);
176 NewF = getFunctionForValue(V);
181 assert((NewF == 0 || F == NewF) &&"inconsistent function-local metadata");
187 // getFunction - If this metadata is function-local and recursively has a
188 // function-local operand, return the first such operand's parent function.
189 // Otherwise, return null. getFunction() should not be used for performance-
190 // critical code because it recursively visits all the MDNode's operands.
191 const Function *MDNode::getFunction() const {
193 return assertLocalFunction(this);
195 if (!isFunctionLocal()) return NULL;
196 for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
197 if (const Function *F = getFunctionForValue(getOperand(i)))
203 // destroy - Delete this node. Only when there are no uses.
204 void MDNode::destroy() {
205 setValueSubclassData(getSubclassDataFromValue() | DestroyFlag);
206 // Placement delete, then free the memory.
211 /// isFunctionLocalValue - Return true if this is a value that would require a
212 /// function-local MDNode.
213 static bool isFunctionLocalValue(Value *V) {
214 return isa<Instruction>(V) || isa<Argument>(V) || isa<BasicBlock>(V) ||
215 (isa<MDNode>(V) && cast<MDNode>(V)->isFunctionLocal());
218 MDNode *MDNode::getMDNode(LLVMContext &Context, ArrayRef<Value*> Vals,
219 FunctionLocalness FL, bool Insert) {
220 LLVMContextImpl *pImpl = Context.pImpl;
222 // Add all the operand pointers. Note that we don't have to add the
223 // isFunctionLocal bit because that's implied by the operands.
224 // Note that if the operands are later nulled out, the node will be
225 // removed from the uniquing map.
227 for (Value *V : Vals)
231 MDNode *N = pImpl->MDNodeSet.FindNodeOrInsertPos(ID, InsertPoint);
236 bool isFunctionLocal = false;
239 for (Value *V : Vals) {
241 if (isFunctionLocalValue(V)) {
242 isFunctionLocal = true;
248 isFunctionLocal = false;
251 isFunctionLocal = true;
255 // Coallocate space for the node and Operands together, then placement new.
256 void *Ptr = malloc(sizeof(MDNode) + Vals.size() * sizeof(MDNodeOperand));
257 N = new (Ptr) MDNode(Context, Vals, isFunctionLocal);
259 // Cache the operand hash.
260 N->Hash = ID.ComputeHash();
262 // InsertPoint will have been set by the FindNodeOrInsertPos call.
263 pImpl->MDNodeSet.InsertNode(N, InsertPoint);
268 MDNode *MDNode::get(LLVMContext &Context, ArrayRef<Value*> Vals) {
269 return getMDNode(Context, Vals, FL_Unknown);
272 MDNode *MDNode::getWhenValsUnresolved(LLVMContext &Context,
273 ArrayRef<Value*> Vals,
274 bool isFunctionLocal) {
275 return getMDNode(Context, Vals, isFunctionLocal ? FL_Yes : FL_No);
278 MDNode *MDNode::getIfExists(LLVMContext &Context, ArrayRef<Value*> Vals) {
279 return getMDNode(Context, Vals, FL_Unknown, false);
282 MDNode *MDNode::getTemporary(LLVMContext &Context, ArrayRef<Value*> Vals) {
284 (MDNode *)malloc(sizeof(MDNode) + Vals.size() * sizeof(MDNodeOperand));
285 N = new (N) MDNode(Context, Vals, FL_No);
286 N->setValueSubclassData(N->getSubclassDataFromValue() |
288 LeakDetector::addGarbageObject(N);
292 void MDNode::deleteTemporary(MDNode *N) {
293 assert(N->use_empty() && "Temporary MDNode has uses!");
294 assert(!N->getContext().pImpl->MDNodeSet.RemoveNode(N) &&
295 "Deleting a non-temporary uniqued node!");
296 assert(!N->getContext().pImpl->NonUniquedMDNodes.erase(N) &&
297 "Deleting a non-temporary non-uniqued node!");
298 assert((N->getSubclassDataFromValue() & NotUniquedBit) &&
299 "Temporary MDNode does not have NotUniquedBit set!");
300 assert((N->getSubclassDataFromValue() & DestroyFlag) == 0 &&
301 "Temporary MDNode has DestroyFlag set!");
302 LeakDetector::removeGarbageObject(N);
306 /// getOperand - Return specified operand.
307 Value *MDNode::getOperand(unsigned i) const {
308 assert(i < getNumOperands() && "Invalid operand number");
309 return *getOperandPtr(const_cast<MDNode*>(this), i);
312 void MDNode::Profile(FoldingSetNodeID &ID) const {
313 // Add all the operand pointers. Note that we don't have to add the
314 // isFunctionLocal bit because that's implied by the operands.
315 // Note that if the operands are later nulled out, the node will be
316 // removed from the uniquing map.
317 for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
318 ID.AddPointer(getOperand(i));
321 void MDNode::setIsNotUniqued() {
322 setValueSubclassData(getSubclassDataFromValue() | NotUniquedBit);
323 LLVMContextImpl *pImpl = getType()->getContext().pImpl;
324 pImpl->NonUniquedMDNodes.insert(this);
327 // Replace value from this node's operand list.
328 void MDNode::replaceOperand(MDNodeOperand *Op, Value *To) {
331 // If is possible that someone did GV->RAUW(inst), replacing a global variable
332 // with an instruction or some other function-local object. If this is a
333 // non-function-local MDNode, it can't point to a function-local object.
334 // Handle this case by implicitly dropping the MDNode reference to null.
335 // Likewise if the MDNode is function-local but for a different function.
336 if (To && isFunctionLocalValue(To)) {
337 if (!isFunctionLocal())
340 const Function *F = getFunction();
341 const Function *FV = getFunctionForValue(To);
342 // Metadata can be function-local without having an associated function.
343 // So only consider functions to have changed if non-null.
344 if (F && FV && F != FV)
352 // Update the operand.
355 // If this node is already not being uniqued (because one of the operands
356 // already went to null), then there is nothing else to do here.
357 if (isNotUniqued()) return;
359 LLVMContextImpl *pImpl = getType()->getContext().pImpl;
361 // Remove "this" from the context map. FoldingSet doesn't have to reprofile
362 // this node to remove it, so we don't care what state the operands are in.
363 pImpl->MDNodeSet.RemoveNode(this);
365 // If we are dropping an argument to null, we choose to not unique the MDNode
366 // anymore. This commonly occurs during destruction, and uniquing these
367 // brings little reuse. Also, this means we don't need to include
368 // isFunctionLocal bits in FoldingSetNodeIDs for MDNodes.
374 // Now that the node is out of the folding set, get ready to reinsert it.
375 // First, check to see if another node with the same operands already exists
376 // in the set. If so, then this node is redundant.
380 if (MDNode *N = pImpl->MDNodeSet.FindNodeOrInsertPos(ID, InsertPoint)) {
381 replaceAllUsesWith(N);
386 // Cache the operand hash.
387 Hash = ID.ComputeHash();
388 // InsertPoint will have been set by the FindNodeOrInsertPos call.
389 pImpl->MDNodeSet.InsertNode(this, InsertPoint);
391 // If this MDValue was previously function-local but no longer is, clear
392 // its function-local flag.
393 if (isFunctionLocal() && !isFunctionLocalValue(To)) {
394 bool isStillFunctionLocal = false;
395 for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
396 Value *V = getOperand(i);
398 if (isFunctionLocalValue(V)) {
399 isStillFunctionLocal = true;
403 if (!isStillFunctionLocal)
404 setValueSubclassData(getSubclassDataFromValue() & ~FunctionLocalBit);
408 MDNode *MDNode::getMostGenericFPMath(MDNode *A, MDNode *B) {
412 APFloat AVal = cast<ConstantFP>(A->getOperand(0))->getValueAPF();
413 APFloat BVal = cast<ConstantFP>(B->getOperand(0))->getValueAPF();
414 if (AVal.compare(BVal) == APFloat::cmpLessThan)
419 static bool isContiguous(const ConstantRange &A, const ConstantRange &B) {
420 return A.getUpper() == B.getLower() || A.getLower() == B.getUpper();
423 static bool canBeMerged(const ConstantRange &A, const ConstantRange &B) {
424 return !A.intersectWith(B).isEmptySet() || isContiguous(A, B);
427 static bool tryMergeRange(SmallVectorImpl<Value *> &EndPoints, ConstantInt *Low,
429 ConstantRange NewRange(Low->getValue(), High->getValue());
430 unsigned Size = EndPoints.size();
431 APInt LB = cast<ConstantInt>(EndPoints[Size - 2])->getValue();
432 APInt LE = cast<ConstantInt>(EndPoints[Size - 1])->getValue();
433 ConstantRange LastRange(LB, LE);
434 if (canBeMerged(NewRange, LastRange)) {
435 ConstantRange Union = LastRange.unionWith(NewRange);
436 Type *Ty = High->getType();
437 EndPoints[Size - 2] = ConstantInt::get(Ty, Union.getLower());
438 EndPoints[Size - 1] = ConstantInt::get(Ty, Union.getUpper());
444 static void addRange(SmallVectorImpl<Value *> &EndPoints, ConstantInt *Low,
446 if (!EndPoints.empty())
447 if (tryMergeRange(EndPoints, Low, High))
450 EndPoints.push_back(Low);
451 EndPoints.push_back(High);
454 MDNode *MDNode::getMostGenericRange(MDNode *A, MDNode *B) {
455 // Given two ranges, we want to compute the union of the ranges. This
456 // is slightly complitade by having to combine the intervals and merge
457 // the ones that overlap.
465 // First, walk both lists in older of the lower boundary of each interval.
466 // At each step, try to merge the new interval to the last one we adedd.
467 SmallVector<Value*, 4> EndPoints;
470 int AN = A->getNumOperands() / 2;
471 int BN = B->getNumOperands() / 2;
472 while (AI < AN && BI < BN) {
473 ConstantInt *ALow = cast<ConstantInt>(A->getOperand(2 * AI));
474 ConstantInt *BLow = cast<ConstantInt>(B->getOperand(2 * BI));
476 if (ALow->getValue().slt(BLow->getValue())) {
477 addRange(EndPoints, ALow, cast<ConstantInt>(A->getOperand(2 * AI + 1)));
480 addRange(EndPoints, BLow, cast<ConstantInt>(B->getOperand(2 * BI + 1)));
485 addRange(EndPoints, cast<ConstantInt>(A->getOperand(2 * AI)),
486 cast<ConstantInt>(A->getOperand(2 * AI + 1)));
490 addRange(EndPoints, cast<ConstantInt>(B->getOperand(2 * BI)),
491 cast<ConstantInt>(B->getOperand(2 * BI + 1)));
495 // If we have more than 2 ranges (4 endpoints) we have to try to merge
496 // the last and first ones.
497 unsigned Size = EndPoints.size();
499 ConstantInt *FB = cast<ConstantInt>(EndPoints[0]);
500 ConstantInt *FE = cast<ConstantInt>(EndPoints[1]);
501 if (tryMergeRange(EndPoints, FB, FE)) {
502 for (unsigned i = 0; i < Size - 2; ++i) {
503 EndPoints[i] = EndPoints[i + 2];
505 EndPoints.resize(Size - 2);
509 // If in the end we have a single range, it is possible that it is now the
510 // full range. Just drop the metadata in that case.
511 if (EndPoints.size() == 2) {
512 ConstantRange Range(cast<ConstantInt>(EndPoints[0])->getValue(),
513 cast<ConstantInt>(EndPoints[1])->getValue());
514 if (Range.isFullSet())
518 return MDNode::get(A->getContext(), EndPoints);
521 //===----------------------------------------------------------------------===//
522 // NamedMDNode implementation.
525 static SmallVector<TrackingVH<MDNode>, 4> &getNMDOps(void *Operands) {
526 return *(SmallVector<TrackingVH<MDNode>, 4>*)Operands;
529 NamedMDNode::NamedMDNode(const Twine &N)
530 : Name(N.str()), Parent(0),
531 Operands(new SmallVector<TrackingVH<MDNode>, 4>()) {
534 NamedMDNode::~NamedMDNode() {
536 delete &getNMDOps(Operands);
539 /// getNumOperands - Return number of NamedMDNode operands.
540 unsigned NamedMDNode::getNumOperands() const {
541 return (unsigned)getNMDOps(Operands).size();
544 /// getOperand - Return specified operand.
545 MDNode *NamedMDNode::getOperand(unsigned i) const {
546 assert(i < getNumOperands() && "Invalid Operand number!");
547 return dyn_cast<MDNode>(&*getNMDOps(Operands)[i]);
550 /// addOperand - Add metadata Operand.
551 void NamedMDNode::addOperand(MDNode *M) {
552 assert(!M->isFunctionLocal() &&
553 "NamedMDNode operands must not be function-local!");
554 getNMDOps(Operands).push_back(TrackingVH<MDNode>(M));
557 /// eraseFromParent - Drop all references and remove the node from parent
559 void NamedMDNode::eraseFromParent() {
560 getParent()->eraseNamedMetadata(this);
563 /// dropAllReferences - Remove all uses and clear node vector.
564 void NamedMDNode::dropAllReferences() {
565 getNMDOps(Operands).clear();
568 /// getName - Return a constant reference to this named metadata's name.
569 StringRef NamedMDNode::getName() const {
570 return StringRef(Name);
573 //===----------------------------------------------------------------------===//
574 // Instruction Metadata method implementations.
577 void Instruction::setMetadata(StringRef Kind, MDNode *Node) {
578 if (Node == 0 && !hasMetadata()) return;
579 setMetadata(getContext().getMDKindID(Kind), Node);
582 MDNode *Instruction::getMetadataImpl(StringRef Kind) const {
583 return getMetadataImpl(getContext().getMDKindID(Kind));
586 void Instruction::dropUnknownMetadata(ArrayRef<unsigned> KnownIDs) {
587 SmallSet<unsigned, 5> KnownSet;
588 KnownSet.insert(KnownIDs.begin(), KnownIDs.end());
590 // Drop debug if needed
591 if (KnownSet.erase(LLVMContext::MD_dbg))
594 if (!hasMetadataHashEntry())
595 return; // Nothing to remove!
597 DenseMap<const Instruction *, LLVMContextImpl::MDMapTy> &MetadataStore =
598 getContext().pImpl->MetadataStore;
600 if (KnownSet.empty()) {
601 // Just drop our entry at the store.
602 MetadataStore.erase(this);
603 setHasMetadataHashEntry(false);
607 LLVMContextImpl::MDMapTy &Info = MetadataStore[this];
610 // Walk the array and drop any metadata we don't know.
611 for (I = 0, E = Info.size(); I != E;) {
612 if (KnownSet.count(Info[I].first)) {
617 Info[I] = Info.back();
621 assert(E == Info.size());
624 // Drop our entry at the store.
625 MetadataStore.erase(this);
626 setHasMetadataHashEntry(false);
630 /// setMetadata - Set the metadata of of the specified kind to the specified
631 /// node. This updates/replaces metadata if already present, or removes it if
633 void Instruction::setMetadata(unsigned KindID, MDNode *Node) {
634 if (Node == 0 && !hasMetadata()) return;
636 // Handle 'dbg' as a special case since it is not stored in the hash table.
637 if (KindID == LLVMContext::MD_dbg) {
638 DbgLoc = DebugLoc::getFromDILocation(Node);
642 // Handle the case when we're adding/updating metadata on an instruction.
644 LLVMContextImpl::MDMapTy &Info = getContext().pImpl->MetadataStore[this];
645 assert(!Info.empty() == hasMetadataHashEntry() &&
646 "HasMetadata bit is wonked");
648 setHasMetadataHashEntry(true);
650 // Handle replacement of an existing value.
652 if (P.first == KindID) {
658 // No replacement, just add it to the list.
659 Info.push_back(std::make_pair(KindID, Node));
663 // Otherwise, we're removing metadata from an instruction.
664 assert((hasMetadataHashEntry() ==
665 getContext().pImpl->MetadataStore.count(this)) &&
666 "HasMetadata bit out of date!");
667 if (!hasMetadataHashEntry())
668 return; // Nothing to remove!
669 LLVMContextImpl::MDMapTy &Info = getContext().pImpl->MetadataStore[this];
671 // Common case is removing the only entry.
672 if (Info.size() == 1 && Info[0].first == KindID) {
673 getContext().pImpl->MetadataStore.erase(this);
674 setHasMetadataHashEntry(false);
678 // Handle removal of an existing value.
679 for (unsigned i = 0, e = Info.size(); i != e; ++i)
680 if (Info[i].first == KindID) {
681 Info[i] = Info.back();
683 assert(!Info.empty() && "Removing last entry should be handled above");
686 // Otherwise, removing an entry that doesn't exist on the instruction.
689 MDNode *Instruction::getMetadataImpl(unsigned KindID) const {
690 // Handle 'dbg' as a special case since it is not stored in the hash table.
691 if (KindID == LLVMContext::MD_dbg)
692 return DbgLoc.getAsMDNode(getContext());
694 if (!hasMetadataHashEntry()) return 0;
696 LLVMContextImpl::MDMapTy &Info = getContext().pImpl->MetadataStore[this];
697 assert(!Info.empty() && "bit out of sync with hash table");
699 for (const auto &I : Info)
700 if (I.first == KindID)
705 void Instruction::getAllMetadataImpl(SmallVectorImpl<std::pair<unsigned,
706 MDNode*> > &Result) const {
709 // Handle 'dbg' as a special case since it is not stored in the hash table.
710 if (!DbgLoc.isUnknown()) {
711 Result.push_back(std::make_pair((unsigned)LLVMContext::MD_dbg,
712 DbgLoc.getAsMDNode(getContext())));
713 if (!hasMetadataHashEntry()) return;
716 assert(hasMetadataHashEntry() &&
717 getContext().pImpl->MetadataStore.count(this) &&
718 "Shouldn't have called this");
719 const LLVMContextImpl::MDMapTy &Info =
720 getContext().pImpl->MetadataStore.find(this)->second;
721 assert(!Info.empty() && "Shouldn't have called this");
723 Result.append(Info.begin(), Info.end());
725 // Sort the resulting array so it is stable.
726 if (Result.size() > 1)
727 array_pod_sort(Result.begin(), Result.end());
731 getAllMetadataOtherThanDebugLocImpl(SmallVectorImpl<std::pair<unsigned,
732 MDNode*> > &Result) const {
734 assert(hasMetadataHashEntry() &&
735 getContext().pImpl->MetadataStore.count(this) &&
736 "Shouldn't have called this");
737 const LLVMContextImpl::MDMapTy &Info =
738 getContext().pImpl->MetadataStore.find(this)->second;
739 assert(!Info.empty() && "Shouldn't have called this");
740 Result.append(Info.begin(), Info.end());
742 // Sort the resulting array so it is stable.
743 if (Result.size() > 1)
744 array_pod_sort(Result.begin(), Result.end());
747 /// clearMetadataHashEntries - Clear all hashtable-based metadata from
748 /// this instruction.
749 void Instruction::clearMetadataHashEntries() {
750 assert(hasMetadataHashEntry() && "Caller should check");
751 getContext().pImpl->MetadataStore.erase(this);
752 setHasMetadataHashEntry(false);