[llvm-commits] [llvm] r50382 - in /llvm/trunk: include/llvm/LinkAllPasses.h include/llvm/Transforms/Scalar.h lib/Transforms/Scalar/DeadLoopElimination.cpp
Chris Lattner
clattner at apple.com
Tue Apr 29 14:40:30 PDT 2008
On Apr 29, 2008, at 1:22 PM, Owen Anderson wrote:
>
> On Apr 29, 2008, at 1:36 PM, Chris Lattner wrote:
>>> + for (Loop::block_iterator LI = L->block_begin(), LE = L-
>>>> block_end();
>>> + LI != LE; ++LI) {
>>> + for (BasicBlock::iterator BI = (*LI)->begin(), BE = (*LI)-
>>> >end();
>>> + BI != BE; ) {
>>> + Instruction* I = BI++;
>>> + I->eraseFromParent();
>>> + }
>>> +
>>> + (*LI)->eraseFromParent();
>>> + }
>>
>> You are incrementing LI after you erase *LI.
>
> I'm actually reasonably confident that this is safe. I'm iterating
> over the loop's block list, not over the function ilist. Erasing
> *LI doesn't remove LI from the loop's block list, it just makes it a
> pointer to freed memory. You'll note that the next step is to
> remove the blocks from LoopInfo, which does remove them from the
> loop's block list, and from the block lists of any parent loops as
> well.
You're right, thanks!
-Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20080429/92ead614/attachment.html>
More information about the llvm-commits
mailing list