[PATCH] D56279: [LLVM-C] Allow For Creating a BasicBlock without a Parent Function
Robert Widmann via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 3 10:27:51 PST 2019
CodaFi created this revision.
CodaFi added reviewers: whitequark, deadalnix.
Herald added a subscriber: llvm-commits.
Add a utility function for creating a basic block without a parent function. A useful operation for compilers that need to synthesize and conditionally insert code without having to bother with appending and immediately unlinking a block.
Repository:
rL LLVM
https://reviews.llvm.org/D56279
Files:
include/llvm-c/Core.h
lib/IR/Core.cpp
Index: lib/IR/Core.cpp
===================================================================
--- lib/IR/Core.cpp
+++ lib/IR/Core.cpp
@@ -2533,6 +2533,12 @@
return wrap(&*--I);
}
+LLVMBasicBlockRef LLVMCreateBasicBlockInContext(LLVMContextRef C,
+ const char *Name,
+ unsigned NameLen) {
+ return wrap(llvm::BasicBlock::Create(*unwrap(C), StringRef(Name, NameLen)));
+}
+
LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
LLVMValueRef FnRef,
const char *Name) {
Index: include/llvm-c/Core.h
===================================================================
--- include/llvm-c/Core.h
+++ include/llvm-c/Core.h
@@ -2806,6 +2806,15 @@
*/
LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn);
+/**
+ * Create a new basic block without inserting it into a function.
+ *
+ * @see llvm::BasicBlock::Create()
+ */
+LLVMBasicBlockRef LLVMCreateBasicBlockInContext(LLVMContextRef C,
+ const char *Name,
+ unsigned NameLen);
+
/**
* Append a basic block to the end of a function.
*
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56279.180095.patch
Type: text/x-patch
Size: 1295 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190103/07ea4d6e/attachment.bin>
More information about the llvm-commits
mailing list