[LLVMdev] CloneBasicBlock doesn't change parent of cloned instructions

Chris Lattner sabre at nondot.org
Mon Jan 17 08:19:03 PST 2005


On Mon, 17 Jan 2005, Morten Ofstad wrote:

> It seems the CloneBasicBlock function defined in Transforms/Utils/Cloning.h 
> doesn't change the parent BasicBlock of the contained instructions when it 
> has cloned them -- Is this a bug or a feature?

I'm not sure I understand.  This code:

     Instruction *NewInst = II->clone();
     ..
     NewBB->getInstList().push_back(NewInst);

Is enough to ensure that the 'Parent' field of NewInst points to NewBB. 
These links are automatically set when the instruction is inserted into 
the basic block (the push_back).

-Chris

-- 
http://nondot.org/sabre/
http://llvm.cs.uiuc.edu/




More information about the llvm-dev mailing list