[LLVM-C] Add LLVMInstructionClone.
authorPeter Zotov <whitequark@whitequark.org>
Fri, 17 Oct 2014 01:02:34 +0000 (01:02 +0000)
committerPeter Zotov <whitequark@whitequark.org>
Fri, 17 Oct 2014 01:02:34 +0000 (01:02 +0000)
llvm-svn: 220007

llvm/include/llvm-c/Core.h
llvm/lib/IR/Core.cpp

index bfbc632..4f9da09 100644 (file)
@@ -2409,6 +2409,16 @@ LLVMOpcode   LLVMGetInstructionOpcode(LLVMValueRef Inst);
 LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst);
 
 /**
+ * Create a copy of 'this' instruction that is identical in all ways
+ * except the following:
+ *   * The instruction has no parent
+ *   * The instruction has no name
+ *
+ * @see llvm::Instruction::clone()
+ */
+LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst);
+
+/**
  * @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
  *
  * Functions in this group apply to instructions that refer to call
index acf63a3..f1e1342 100644 (file)
@@ -1888,6 +1888,12 @@ LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst) {
   return (LLVMOpcode)0;
 }
 
+LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst) {
+  if (Instruction *C = dyn_cast<Instruction>(unwrap(Inst)))
+    return wrap(C->clone());
+  return nullptr;
+}
+
 /*--.. Call and invoke instructions ........................................--*/
 
 unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr) {