33 void MDString::anchor() { }
45 return cast<MDString>(S);
62 "Couldn't find the beginning of the operand list!");
63 return reinterpret_cast<MDNode*
>(Cur) - 1;
89 getParent()->replaceOperand(
this, 0);
93 getParent()->replaceOperand(
this, NV);
104 assert(Op <= N->getNumOperands() &&
"Invalid operand number");
110 replaceOperand(Op, Val);
115 NumOperands = Vals.
size();
123 Op != E; ++Op, ++i) {
128 Op->setAsFirstOperand(1);
135 "Not being destroyed through destroy()?");
137 if (isNotUniqued()) {
146 Op->~MDNodeOperand();
156 return A->getParent();
158 return BB->getParent();
159 if (
MDNode *MD = dyn_cast<MDNode>(V))
160 return MD->getFunction();
172 if (
MDNode *MD = dyn_cast<MDNode>(V))
180 assert((NewF == 0 || F == NewF) &&
"inconsistent function-local metadata");
203 void MDNode::destroy() {
213 return isa<Instruction>(V) || isa<Argument>(V) || isa<BasicBlock>(V) ||
214 (isa<MDNode>(V) && cast<MDNode>(V)->isFunctionLocal());
218 FunctionLocalness FL,
bool Insert) {
226 for (
unsigned i = 0; i != Vals.
size(); ++i)
235 bool isFunctionLocal =
false;
238 for (
unsigned i = 0; i != Vals.
size(); ++i) {
242 isFunctionLocal =
true;
248 isFunctionLocal =
false;
251 isFunctionLocal =
true;
257 N =
new (Ptr)
MDNode(Context, Vals, isFunctionLocal);
263 pImpl->
MDNodeSet.InsertNode(N, InsertPoint);
269 return getMDNode(Context, Vals, FL_Unknown);
274 bool isFunctionLocal) {
275 return getMDNode(Context, Vals, isFunctionLocal ? FL_Yes : FL_No);
279 return getMDNode(Context, Vals, FL_Unknown,
false);
285 N =
new (
N)
MDNode(Context, Vals, FL_No);
293 assert(N->
use_empty() &&
"Temporary MDNode has uses!");
295 "Deleting a non-temporary uniqued node!");
297 "Deleting a non-temporary non-uniqued node!");
299 "Temporary MDNode does not have NotUniquedBit set!");
301 "Temporary MDNode has DestroyFlag set!");
321 void MDNode::setIsNotUniqued() {
344 if (F && FV && F != FV)
357 if (isNotUniqued())
return;
380 if (
MDNode *N = pImpl->
MDNodeSet.FindNodeOrInsertPos(ID, InsertPoint)) {
389 pImpl->
MDNodeSet.InsertNode(
this, InsertPoint);
394 bool isStillFunctionLocal =
false;
399 isStillFunctionLocal =
true;
403 if (!isStillFunctionLocal)
430 unsigned Size = EndPoints.
size();
431 APInt LB = cast<ConstantInt>(EndPoints[Size - 2])->getValue();
432 APInt LE = cast<ConstantInt>(EndPoints[Size - 1])->getValue();
446 if (!EndPoints.
empty())
472 while (AI < AN && BI < BN) {
486 cast<ConstantInt>(A->
getOperand(2 * AI + 1)));
491 cast<ConstantInt>(B->
getOperand(2 * BI + 1)));
497 unsigned Size = EndPoints.
size();
502 for (
unsigned i = 0; i < Size - 2; ++i) {
503 EndPoints[i] = EndPoints[i + 2];
505 EndPoints.
resize(Size - 2);
511 if (EndPoints.
size() == 2) {
512 ConstantRange Range(cast<ConstantInt>(EndPoints[0])->getValue(),
513 cast<ConstantInt>(EndPoints[1])->getValue());
529 NamedMDNode::NamedMDNode(
const Twine &N)
530 :
Name(N.str()), Parent(0),
534 NamedMDNode::~NamedMDNode() {
541 return (
unsigned)
getNMDOps(Operands).size();
553 "NamedMDNode operands must not be function-local!");
583 return getMetadataImpl(
getContext().getMDKindID(Kind));
601 assert(!Info.
empty() == hasMetadataHashEntry() &&
602 "HasMetadata bit is wonked");
604 setHasMetadataHashEntry(
true);
607 for (
unsigned i = 0, e = Info.
size(); i != e; ++i)
608 if (Info[i].first == KindID) {
609 Info[i].second = Node;
615 Info.
push_back(std::make_pair(KindID, Node));
620 assert((hasMetadataHashEntry() ==
622 "HasMetadata bit out of date!");
623 if (!hasMetadataHashEntry())
628 if (Info.
size() == 1 && Info[0].first == KindID) {
630 setHasMetadataHashEntry(
false);
635 for (
unsigned i = 0, e = Info.
size(); i != e; ++i)
636 if (Info[i].first == KindID) {
637 Info[i] = Info.
back();
639 assert(!Info.
empty() &&
"Removing last entry should be handled above");
645 MDNode *Instruction::getMetadataImpl(
unsigned KindID)
const {
650 if (!hasMetadataHashEntry())
return 0;
653 assert(!Info.
empty() &&
"bit out of sync with hash table");
657 if (
I->first == KindID)
662 void Instruction::getAllMetadataImpl(
SmallVectorImpl<std::pair<
unsigned,
663 MDNode*> > &Result)
const {
670 if (!hasMetadataHashEntry())
return;
673 assert(hasMetadataHashEntry() &&
675 "Shouldn't have called this");
678 assert(!Info.empty() &&
"Shouldn't have called this");
680 Result.append(Info.begin(), Info.end());
683 if (Result.size() > 1)
688 getAllMetadataOtherThanDebugLocImpl(
SmallVectorImpl<std::pair<
unsigned,
689 MDNode*> > &Result)
const {
691 assert(hasMetadataHashEntry() &&
693 "Shouldn't have called this");
696 assert(!Info.empty() &&
"Shouldn't have called this");
697 Result.append(Info.begin(), Info.end());
700 if (Result.size() > 1)
706 void Instruction::clearMetadataHashEntries() {
707 assert(hasMetadataHashEntry() &&
"Caller should check");
709 setHasMetadataHashEntry(
false);
void AddPointer(const void *Ptr)
StringRef getName() const
getName - Return a constant reference to this named metadata's name.
void push_back(const T &Elt)
void replaceOperandWith(unsigned i, Value *NewVal)
replaceOperandWith - Replace a specific operand.
static void deleteTemporary(MDNode *N)
IntegerType * getType() const
static MDNode * getTemporary(LLVMContext &Context, ArrayRef< Value * > Vals)
const ValueTy & getValue() const
LLVM Argument representation.
enable_if_c<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
unsigned getNumOperands() const
getNumOperands - Return number of MDNode operands.
void addOperand(MDNode *M)
addOperand - Add metadata operand.
const Function * getParent() const
Return the enclosing method, or null if none.
MDNode * getAsMDNode(const LLVMContext &Ctx) const
MDNode - a tuple of other values.
static MDNode * get(LLVMContext &Context, ArrayRef< Value * > Vals)
Value * getOperand(unsigned i) const LLVM_READONLY
getOperand - Return specified operand.
bool isUnknown() const
isUnknown - Return true if this is an unknown location.
static void removeGarbageObject(void *Object)
const APInt & getValue() const
Return the constant's value.
void eraseNamedMetadata(NamedMDNode *NMD)
ID
LLVM Calling Convention Representation.
void setAsFirstOperand(unsigned V)
LLVMContext & getContext() const
getContext - Return the LLVMContext in which this type was uniqued.
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
ConstantRange unionWith(const ConstantRange &CR) const
void replaceAllUsesWith(Value *V)
size_t size() const
size - Get the array size.
virtual void allUsesReplacedWith(Value *NV)
A self-contained host- and target-independent arbitrary-precision floating-point software implementat...
static MDNode * getMostGenericRange(MDNode *A, MDNode *B)
void array_pod_sort(IteratorTy Start, IteratorTy End)
ConstantRange intersectWith(const ConstantRange &CR) const
cmpResult compare(const APFloat &) const
LLVM Basic Block Representation.
void Profile(FoldingSetNodeID &ID) const
FoldingSet< MDNode > MDNodeSet
DenseMap< const Instruction *, MDMapTy > MetadataStore
MDNode * getOperand(unsigned i) const
getOperand - Return specified operand.
SmallPtrSet< MDNode *, 1 > NonUniquedMDNodes
void setValueName(ValueName *VN)
LLVMContext & getContext() const
All values hold a context through their type.
void setMetadata(unsigned KindID, MDNode *Node)
LLVMContextImpl *const pImpl
static MDNode * getWhenValsUnresolved(LLVMContext &Context, ArrayRef< Value * > Vals, bool isFunctionLocal)
Class for constant integers.
bool slt(const APInt &RHS) const
Signed less than comparison.
static MDNode * getIfExists(LLVMContext &Context, ArrayRef< Value * > Vals)
const APInt & getLower() const
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
Class for arbitrary precision integers.
static void addGarbageObject(void *Object)
unsigned getValPtrInt() const
friend class MDNodeOperand
MapEntryTy & GetOrCreateValue(StringRef Key, InitTy Val)
bool isFunctionLocal() const
isFunctionLocal - Return whether MDNode is local to a function.
unsigned short getSubclassDataFromValue() const
void *malloc(size_t size);
StringMap< Value * > MDStringCache
unsigned ComputeHash() const
static DebugLoc getFromDILocation(MDNode *N)
getFromDILocation - Translate the DILocation quad into a DebugLoc.
const APInt & getUpper() const
LLVM Value Representation.
unsigned getNumOperands() const
getNumOperands - Return the number of NamedMDNode operands.
void dropAllReferences()
dropAllReferences - Remove all uses and clear node vector.
void setValPtrInt(unsigned K)
static MDNode * getMostGenericFPMath(MDNode *A, MDNode *B)
const Function * getFunction() const
Module * getParent()
getParent - Get the module that holds this named metadata collection.