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

Morten Ofstad morten at hue.no
Mon Jan 17 08:56:42 PST 2005


Chris Lattner wrote:
> 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).

Hmmm, then there is a bug somewhere because I'm finding alloca 
instructions in a cloned BB which say the original BB is their parent... 
I will investigate.

m.




More information about the llvm-dev mailing list