[llvm-commits] [llvm] r150571 - in /llvm/trunk: include/llvm/Metadata.h lib/VMCore/Metadata.cpp

Eric Christopher echristo at apple.com
Wed Feb 15 01:09:30 PST 2012


Author: echristo
Date: Wed Feb 15 03:09:29 2012
New Revision: 150571

URL: http://llvm.org/viewvc/llvm-project?rev=150571&view=rev
Log:
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.

Modified:
    llvm/trunk/include/llvm/Metadata.h
    llvm/trunk/lib/VMCore/Metadata.cpp

Modified: llvm/trunk/include/llvm/Metadata.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Metadata.h?rev=150571&r1=150570&r2=150571&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Metadata.h (original)
+++ llvm/trunk/include/llvm/Metadata.h Wed Feb 15 03:09:29 2012
@@ -135,6 +135,9 @@
   /// 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;

Modified: llvm/trunk/lib/VMCore/Metadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Metadata.cpp?rev=150571&r1=150570&r2=150571&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Metadata.cpp (original)
+++ llvm/trunk/lib/VMCore/Metadata.cpp Wed Feb 15 03:09:29 2012
@@ -87,6 +87,11 @@
   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();





More information about the llvm-commits mailing list