[LLVMdev] Extending FunctionType

Frits van Bommel fvbommel at gmail.com
Mon Feb 28 08:10:33 PST 2011


On Mon, Feb 28, 2011 at 5:04 PM, Frits van Bommel <fvbommel at gmail.com> wrote:
> Gabriel: look at Function::getBasicBlockList() and
> iplist<>::splice(iterator, iplist). Something like
>  Function *NewF = Function::Create(NewFnType, OldF->getLinkage());
>  NewF->getBasicBlockList().splice(NewF->begin(), OldF->getBasicBlockList());
>  NewF->takeName(OldF);
>  OldF->eraseFromParent();
> is probably what you're looking for.
> (Note: completely untested)

Well, of course you may want to also make sure no uses of the old
function remain before erasing it. Since we're talking about main(),
*probably* the only uses you have to worry about are blockaddresses.
You probably should still check for other uses though, just in case
the program is doing something weird (and not supported by the C & C++
standards IIRC).




More information about the llvm-dev mailing list