summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm-c/Core.h18
-rw-r--r--llvm/lib/IR/Core.cpp14
2 files changed, 32 insertions, 0 deletions
diff --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h
index 393250f7f8c..6adb4d80011 100644
--- a/llvm/include/llvm-c/Core.h
+++ b/llvm/include/llvm-c/Core.h
@@ -2917,6 +2917,24 @@ LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB);
LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
/**
+ * Insert the given basic block after the insertion point of the given builder.
+ *
+ * The insertion point must be valid.
+ *
+ * @see llvm::Function::BasicBlockListType::insertAfter()
+ */
+void LLVMInsertExistingBasicBlockAfterInsertBlock(LLVMBuilderRef Builder,
+ LLVMBasicBlockRef BB);
+
+/**
+ * Append the given basic block to the basic block list of the given function.
+ *
+ * @see llvm::Function::BasicBlockListType::push_back()
+ */
+void LLVMAppendExistingBasicBlock(LLVMValueRef Fn,
+ LLVMBasicBlockRef BB);
+
+/**
* Create a new basic block without inserting it into a function.
*
* @see llvm::BasicBlock::Create()
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp
index aa6bc542b4e..997f5330dec 100644
--- a/llvm/lib/IR/Core.cpp
+++ b/llvm/lib/IR/Core.cpp
@@ -2609,6 +2609,20 @@ LLVMBasicBlockRef LLVMCreateBasicBlockInContext(LLVMContextRef C,
return wrap(llvm::BasicBlock::Create(*unwrap(C), Name));
}
+void LLVMInsertExistingBasicBlockAfterInsertBlock(LLVMBuilderRef Builder,
+ LLVMBasicBlockRef BB) {
+ BasicBlock *ToInsert = unwrap(BB);
+ BasicBlock *CurBB = unwrap(Builder)->GetInsertBlock();
+ assert(CurBB && "current insertion point is invalid!");
+ CurBB->getParent()->getBasicBlockList().insertAfter(CurBB->getIterator(),
+ ToInsert);
+}
+
+void LLVMAppendExistingBasicBlock(LLVMValueRef Fn,
+ LLVMBasicBlockRef BB) {
+ unwrap<Function>(Fn)->getBasicBlockList().push_back(unwrap(BB));
+}
+
LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
LLVMValueRef FnRef,
const char *Name) {
OpenPOWER on IntegriCloud