Morten Ofstad
2005-Jan-17 15:12 UTC
[LLVMdev] CloneBasicBlock doesn't change parent of cloned instructions
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? m.
Chris Lattner
2005-Jan-17 16:19 UTC
[LLVMdev] CloneBasicBlock doesn't change parent of cloned instructions
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/
Morten Ofstad
2005-Jan-17 16:56 UTC
[LLVMdev] CloneBasicBlock doesn't change parent of cloned instructions
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.