Hi, In my code generator, I need to prepare a block and add instructions to it, then insert this block in a function defined later (that is I cannot create the function at the beginning stage become some info are not available yet). I tried to create a block without any "parent" (BasicBlock::Create(getGlobalContext(), "init"), fill it, but how to link it with the created function? (i read about "moveBefore" and "moveAfter" but these methods are not usable in this context... Thanks Stéphane Letz
On Jun 13, 2010, at 2:12 AM, Stéphane Letz wrote:> Hi, > > In my code generator, I need to prepare a block and add instructions to it, then insert this block in a function defined later (that is I cannot create the function at the beginning stage become some info are not available yet). I tried to create a block without any "parent" (BasicBlock::Create(getGlobalContext(), "init"), fill it, but how to link it with the created function? (i read about "moveBefore" and "moveAfter" but these methods are not usable in this context...You can use Function::getBasicBlockList(). That list supports fully general list operations like "insert", so you can just plop it in wherever you'd like it. -Chris
Hi Chris,>> In my code generator, I need to prepare a block and add instructions to it, then insert this block in a function defined later (that is I cannot create the function at the beginning stage become some info are not available yet). I tried to create a block without any "parent" (BasicBlock::Create(getGlobalContext(), "init"), fill it, but how to link it with the created function? (i read about "moveBefore" and "moveAfter" but these methods are not usable in this context... > > You can use Function::getBasicBlockList(). That list supports fully general list operations like "insert", so you can just plop it in wherever you'd like it.methods like the basic block constructor or BasicBlock::setParent muck around with the LeakDetector. I don't know what the LeakDetector is - does Stéphane need to do something like this too? Ciao, Duncan.