[llvm] r224177 - Go bindings: introduce Metadata.ReplaceAllUsesWith.

Peter Collingbourne peter at pcc.me.uk
Fri Dec 12 18:25:51 PST 2014


Author: pcc
Date: Fri Dec 12 20:25:51 2014
New Revision: 224177

URL: http://llvm.org/viewvc/llvm-project?rev=224177&view=rev
Log:
Go bindings: introduce Metadata.ReplaceAllUsesWith.

Modified:
    llvm/trunk/bindings/go/llvm/IRBindings.cpp
    llvm/trunk/bindings/go/llvm/IRBindings.h
    llvm/trunk/bindings/go/llvm/ir.go

Modified: llvm/trunk/bindings/go/llvm/IRBindings.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/IRBindings.cpp?rev=224177&r1=224176&r2=224177&view=diff
==============================================================================
--- llvm/trunk/bindings/go/llvm/IRBindings.cpp (original)
+++ llvm/trunk/bindings/go/llvm/IRBindings.cpp Fri Dec 12 20:25:51 2014
@@ -75,6 +75,12 @@ void LLVMSetMetadata2(LLVMValueRef Inst,
   unwrap<Instruction>(Inst)->setMetadata(KindID, N);
 }
 
+void LLVMMetadataReplaceAllUsesWith(LLVMMetadataRef MD, LLVMMetadataRef New) {
+  auto *Node = unwrap<MDNodeFwdDecl>(MD);
+  Node->replaceAllUsesWith(unwrap<MDNode>(New));
+  MDNode::deleteTemporary(Node);
+}
+
 void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Bref, unsigned Line,
                                   unsigned Col, LLVMMetadataRef Scope,
                                   LLVMMetadataRef InlinedAt) {

Modified: llvm/trunk/bindings/go/llvm/IRBindings.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/IRBindings.h?rev=224177&r1=224176&r2=224177&view=diff
==============================================================================
--- llvm/trunk/bindings/go/llvm/IRBindings.h (original)
+++ llvm/trunk/bindings/go/llvm/IRBindings.h Fri Dec 12 20:25:51 2014
@@ -45,6 +45,8 @@ void LLVMAddNamedMetadataOperand2(LLVMMo
                                   LLVMMetadataRef Val);
 void LLVMSetMetadata2(LLVMValueRef Inst, unsigned KindID, LLVMMetadataRef MD);
 
+void LLVMMetadataReplaceAllUsesWith(LLVMMetadataRef MD, LLVMMetadataRef New);
+
 void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Bref, unsigned Line,
                                   unsigned Col, LLVMMetadataRef Scope,
                                   LLVMMetadataRef InlinedAt);

Modified: llvm/trunk/bindings/go/llvm/ir.go
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/go/llvm/ir.go?rev=224177&r1=224176&r2=224177&view=diff
==============================================================================
--- llvm/trunk/bindings/go/llvm/ir.go (original)
+++ llvm/trunk/bindings/go/llvm/ir.go Fri Dec 12 20:25:51 2014
@@ -1827,3 +1827,11 @@ func (pm PassManager) FinalizeFunc() boo
 // the module provider.
 // See llvm::PassManagerBase::~PassManagerBase.
 func (pm PassManager) Dispose() { C.LLVMDisposePassManager(pm.C) }
+
+//-------------------------------------------------------------------------
+// llvm.Metadata
+//-------------------------------------------------------------------------
+
+func (md Metadata) ReplaceAllUsesWith(new Metadata) {
+	C.LLVMMetadataReplaceAllUsesWith(md.C, new.C)
+}





More information about the llvm-commits mailing list