Reputation: 655
If I have a set of basic blocks and edges and I need to create for them a new function with new entry and end points.
Could I create this directly in LLVM , just like createFunction(F)
then F.insert(bb, edges)
which bb is a basic block and edges is the new edges for the new function.
Thanks
Upvotes: 6
Views: 8793
Reputation: 273716
You can create a new function with Function::Create
. See this snippet from the LLVM tutorial for example:
Function *PrototypeAST::Codegen() {
// Make the function type: double(double,double) etc.
std::vector<Type*> Doubles(Args.size(),
Type::getDoubleTy(getGlobalContext()));
FunctionType *FT = FunctionType::get(Type::getDoubleTy(getGlobalContext()),
Doubles, false);
Function *F = Function::Create(FT, Function::ExternalLinkage, Name, TheModule);
Upvotes: 6
Reputation: 87
The function create: http://llvm.org/docs/doxygen/html/classllvm_1_1Function.html#a162a63c89ac118c8ffef75b3a892efa0
How to use the create function in the source code of llvm: http://llvm.org/docs/doxygen/html/CloneFunction_8cpp_source.html#l00162
Upvotes: -2