[LLVMdev] Is it valid to add parameters to a function once it is created
Frank Winter
fwinter at jlab.org
Tue May 21 12:19:08 PDT 2013
I create a function with an empty signature:
void llvm_start_new_function() {
llvm::outs() << "Staring new LLVM function ...\n";
Mod = new llvm::Module("module", llvm::getGlobalContext());
builder = new llvm::IRBuilder<>(llvm::getGlobalContext());
llvm::FunctionType *funcType =
llvm::FunctionType::get(builder->getVoidTy(), false);
mainFunc = llvm::Function::Create(funcType,
llvm::Function::ExternalLinkage, "main", Mod);
llvm::BasicBlock* entry =
llvm::BasicBlock::Create(llvm::getGlobalContext(), "entrypoint", mainFunc);
builder->SetInsertPoint(entry);
llvm_counters::param_counter = 0;
llvm_counters::label_counter = 0;
}
and then add parameters as needed with something like
llvm::Argument * u8 = new llvm::Argument(
llvm::Type::getInt8Ty(llvm::getGlobalContext()) , param_next() , mainFunc );
Is this valid?
More information about the llvm-dev
mailing list