[LLVMdev] L->isLoopInvariant giving wrong results?
Török Edwin
edwintorok at gmail.com
Mon Nov 22 12:37:13 PST 2010
On Thu, 18 Nov 2010 05:16:00 +0530
Sreeraj a <writetosrj at gmail.com> wrote:
> my changed code.
> for (BasicBlock::iterator i = lat->begin(), e = lat->end(); i != e;
> ++i){ Instruction* hijk= i;
> // find out if the statement is a branch or whatever.
> if(hijk->isSafeToSpeculativelyExecute()){
> if(isLoopInvariantInst(*hijk)){
> errs() << " " << *hijk << " is loop invariant\n";
> errs() << " hoisting to " << pre->getName() << "\n";
> // This is where all the trouble happens.
> hijk->moveBefore(pre->getTerminator());
So you move this instruction, and then keep iterating in the basicblock.
I don't think the iterator is safe to use after a removal, try
incrementing 'i' earlier, and then perform the erase.
Best regards
--Edwin
More information about the llvm-dev
mailing list