[llvm] r350608 - [LLVM-C] Allow For Creating a BasicBlock without a Parent Function
Robert Widmann via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 7 22:24:19 PST 2019
Author: codafi
Date: Mon Jan 7 22:24:19 2019
New Revision: 350608
URL: http://llvm.org/viewvc/llvm-project?rev=350608&view=rev
Log:
[LLVM-C] Allow For Creating a BasicBlock without a Parent Function
Summary: 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.
Reviewers: whitequark, deadalnix
Reviewed By: whitequark
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D56279
Modified:
llvm/trunk/include/llvm-c/Core.h
llvm/trunk/lib/IR/Core.cpp
Modified: llvm/trunk/include/llvm-c/Core.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=350608&r1=350607&r2=350608&view=diff
==============================================================================
--- llvm/trunk/include/llvm-c/Core.h (original)
+++ llvm/trunk/include/llvm-c/Core.h Mon Jan 7 22:24:19 2019
@@ -2807,6 +2807,15 @@ LLVMBasicBlockRef LLVMGetPreviousBasicBl
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,
+ size_t NameLen);
+
+/**
* Append a basic block to the end of a function.
*
* @see llvm::BasicBlock::Create()
Modified: llvm/trunk/lib/IR/Core.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Core.cpp?rev=350608&r1=350607&r2=350608&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Core.cpp (original)
+++ llvm/trunk/lib/IR/Core.cpp Mon Jan 7 22:24:19 2019
@@ -2532,6 +2532,12 @@ LLVMBasicBlockRef LLVMGetPreviousBasicBl
return wrap(&*--I);
}
+LLVMBasicBlockRef LLVMCreateBasicBlockInContext(LLVMContextRef C,
+ const char *Name,
+ size_t NameLen) {
+ return wrap(llvm::BasicBlock::Create(*unwrap(C), StringRef(Name, NameLen)));
+}
+
LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C,
LLVMValueRef FnRef,
const char *Name) {
More information about the llvm-commits
mailing list