I am using LLVM 2.6 and I have a question on the use of the BasicBlock::iterator to hoist loop invariant instructions to the loop preheader. When I process the instructions backward as shown in the following code, I got the following error right after the "hoist(I)" is done. Can anyone advise whether I am misusing BasicBlock::iterator?<br>
<br><span style="color: rgb(102, 0, 0);">/opt/llvms/src/llvm_26/ include/llvm/ADT/ilist.h:213: llvm::ilist_iterator<NodeTy>& llvm::ilist_iterator<NodeTy>::operator--() [with NodeTy = llvm::Instruction]: Assertion `NodePtr && "--'d off the beginning of an ilist!"' failed.</span><br>
<br><br><b>LICM::HOistRegion(DomTreeNode *N)</b> <br>{<br>    assert(N != 0 && "Null dominator tree node?");<br>    BasicBlock *BB = N->getBlock();<br><br>    ...<br>            <br>   <b> for (BasicBlock::iterator II = BB->end(); II != BB->begin(); ) </b>{<br>
<br>               Instruction &I = *--II;<br>          <br>               if (isLoopInvariantInst(I) && canSinkOrHoistInst(I) &&<br>                    isSafeToExecuteUnconditionally(I)) <br>                   <b> hoist(I);</b><br>
    }<br>..<br>}<br><br><br>-- UGR<br><br>