Getting segmentation Fault while inserting cloned instrution in the original instruction before the original instrctuion

BB->getInstList().insert(&(*i),&(*j) );

here j is iterator of cloned instruction and i is iterator of original instruction.Since i am doing it on per basic block branch inclusion may not be problem.

Thanx
PRiyanka

There’s too little detail here to be helpful. If you haven’t already, make sure you’re using a Debug+Asserts build of LLVM; the asserts in LLVM may provide insight into the problem. A stack trace might also help. Make sure you’re not cloning the TerminatorInst at the end of the basic block (a basic block should only have one TerminatorInst), and check that your insertion point is valid. Regards, John Criswell