forked from OSchip/llvm-project
Add a way to replace a field inside a metadata node. This can be
used to incrementally update a created node without needing a temporary node and RAUW. llvm-svn: 150571
This commit is contained in:
parent
278c25f241
commit
24e51b7f29
|
@ -135,6 +135,9 @@ public:
|
|||
/// deleteTemporary - Deallocate a node created by getTemporary. The
|
||||
/// node must not have any users.
|
||||
static void deleteTemporary(MDNode *N);
|
||||
|
||||
/// replaceOperandWith - Replace a specific operand.
|
||||
void replaceOperandWith(unsigned i, Value *NewVal);
|
||||
|
||||
/// getOperand - Return specified operand.
|
||||
Value *getOperand(unsigned i) const;
|
||||
|
|
|
@ -87,6 +87,11 @@ static MDNodeOperand *getOperandPtr(MDNode *N, unsigned Op) {
|
|||
return reinterpret_cast<MDNodeOperand*>(N+1)+Op;
|
||||
}
|
||||
|
||||
void MDNode::replaceOperandWith(unsigned i, Value *Val) {
|
||||
MDNodeOperand *Op = getOperandPtr(this, i);
|
||||
replaceOperand(Op, Val);
|
||||
}
|
||||
|
||||
MDNode::MDNode(LLVMContext &C, ArrayRef<Value*> Vals, bool isFunctionLocal)
|
||||
: Value(Type::getMetadataTy(C), Value::MDNodeVal) {
|
||||
NumOperands = Vals.size();
|
||||
|
|
Loading…
Reference in New Issue