[LLVMdev] LICM ilist question.

Gabor Greif gabor at mac.com
Tue Jan 12 07:22:42 PST 2010


Hi Gang-Ryung!

Your reverse iteration of instructions in the BB

>    * for (BasicBlock::iterator II = BB->end(); II != BB->begin(); ) *{
> 
>                Instruction &I = *--II;
> 
>                if (isLoopInvariantInst(I) && canSinkOrHoistInst(I) &&
>                     isSafeToExecuteUnconditionally(I))
>                    * hoist(I);*
>     }

looks perfectly valid.

If I remember correctly, the (operator--) on Instruction has a buggy
assert, but that should not trigger in your case. (Adding unit tests for
reverse iteration is on my TODO list.)

I suspect that your "hoist(I)" call removes the instruction "I" from the
BB and puts it into the first position of another basic block. This could
mess up the "II != BB->begin()" test.

Hope this helps!

Cheers,

	Gabor



More information about the llvm-dev mailing list