Add a way to replace a field inside a metadata node. This can be
authorEric Christopher <echristo@apple.com>
Wed, 15 Feb 2012 09:09:29 +0000 (09:09 +0000)
committerEric Christopher <echristo@apple.com>
Wed, 15 Feb 2012 09:09:29 +0000 (09:09 +0000)
used to incrementally update a created node without needing a
temporary node and RAUW.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150571 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Metadata.h
lib/VMCore/Metadata.cpp

index 9466a5791ccbd2c92b590dba51e58f1ec15ea7c5..29458ef34613aa6f63176b8500f6d993c13ec0a9 100644 (file)
@@ -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;
index 5d6eb144c3e7ac619bbe3a51d031d9db0233cd1b..0fc2a2534d207fedc578d90faca07e70ad0a6ecf 100644 (file)
@@ -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();