[llvm-commits] [llvm] r50382 - in /llvm/trunk: include/llvm/LinkAllPasses.h include/llvm/Transforms/Scalar.h lib/Transforms/Scalar/DeadLoopElimination.cpp
Owen Anderson
resistor at mac.com
Tue Apr 29 13:22:59 PDT 2008
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.
--Owen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20080429/4eb09e7f/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4260 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20080429/4eb09e7f/attachment.bin>
More information about the llvm-commits
mailing list