<font style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" size="2">Hi<br><br>I have checked all blocks, each block have</font> a Terminator
instruction<font style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" size="2"> and
each blocks belongs to a function.<br><span style="font-family: arial,sans-serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span>I</span><span>'m</span><span> </span><span>really</span><span> </span><span>confused</span><span>.
</span></span><span style="font-family: arial,sans-serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span>I guess
the</span><span> </span><span>problem</span><span> </span><span>is</span><span> </span><span>caused
by</span><span> </span><span>the</span><span> </span><span>removal of</span><span> </span><span>the
Loop,The</span></span><span style="font-family: arial,sans-serif; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span></span><span>
</span><span>code</span><span> </span><span>is as follows</span><span>:<br><br><font size="1"><br style="background-color: rgb(255, 255, 102);"><i><span style="background-color: rgb(255, 255, 102);"> //every block to header (except the ones in the loop), will now redirect to newblock</span><br>
for (pred_iterator PI = pred_begin(header); PI != pred_end(header); ++PI) {<br> BasicBlock *pred = *PI;<br> if (L->contains(pred)) {<br> continue;<br> }<br> TerminatorInst *termInst = pred->getTerminator();<br>
<br> for (unsigned i = 0; i < termInst->getNumOperands(); i++) {<br> BasicBlock *bb = dyn_cast<BasicBlock> (termInst->getOperand(i));<br> if (bb == header) {<br> termInst->setOperand(i,newBlock);<br>
}<br> }<br> }</i><br><br><i><span style="background-color: rgb(255, 255, 0);"> cout << "begin to delete loop" << endl;</span><br> for (Loop::block_iterator bi = L->block_begin(), bi2; bi != L->block_end(); bi = bi2) <br>
{<br> bi2 = bi;<br> bi2++;<br> BasicBlock * BB = *bi;<br> for (BasicBlock::iterator ii = BB->begin(), ii2; ii != BB->end(); ii= ii2) <br> {<br> ii2 = ii;<br> ii2++;<br>
Instruction *inst = ii;<br> inst->replaceAllUsesWith(UndefValue::get(inst->getType()));<br> inst->eraseFromParent();<br> }<br> for (pred_iterator PI = pred_begin(BB); PI != pred_end(BB); ++PI) <br>
{<br> BasicBlock *pred = *PI;<br> if (!L->contains(pred)) <br> continue;<br> pred->getTerminator()->eraseFromParent();<br> }<br> BB->eraseFromParent();<br>
}<br></i></font><br></span></span></font><span dir="ltr" id=":3l">May this code be causing the problem?</span><br><br><span style="color: rgb(0, 0, 0); font-family: arial,sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; background-color: rgb(255, 255, 255);">Best regards<br>
<font color="#888888">neda</font></span><br>
<br>