[llvm-commits] [llvm] r168829 - /llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp

Nick Lewycky nlewycky at google.com
Wed Dec 5 16:23:07 PST 2012


On 28 November 2012 15:23, Bill Wendling <isanbard at gmail.com> wrote:

> Author: void
> Date: Wed Nov 28 17:23:48 2012
> New Revision: 168829
>
> URL: http://llvm.org/viewvc/llvm-project?rev=168829&view=rev
> Log:
> When we delete a dead basic block, see if any of its successors are dead
> and
> delete those as well.
>
> Modified:
>     llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp
>
> Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=168829&r1=168828&r2=168829&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Wed Nov 28
> 17:23:48 2012
> @@ -194,9 +194,19 @@
>            WorkList.insert(*II);
>      }
>
> -    for (SmallPtrSet<BasicBlock*, 8>::iterator
> -           I = WorkList.begin(), E = WorkList.end(); I != E; ++I)
> -      DeleteDeadBlock(*I);
> +    // Delete the dead blocks and any of their dead successors.
> +    while (!WorkList.empty()) {
> +      BasicBlock *BB = *WorkList.begin();
> +      WorkList.erase(BB);
> +      SmallVector<BasicBlock*, 2> Successors(succ_begin(BB),
> succ_end(BB));
> +
> +      DeleteDeadBlock(BB);
>

I think you need to set MadeChange = true here. I think this bug could
actually manifest because we use MadeChange later on to decide whether we
need to recalculate the domtree.

+
> +      for (SmallVectorImpl<BasicBlock*>::iterator
> +             II = Successors.begin(), IE = Successors.end(); II != IE;
> ++II)
> +        if (pred_begin(*II) == pred_end(*II))
>

What if the block includes a branch to itself?

Nick


> +          WorkList.insert(*II);
> +    }
>
>      // Merge pairs of basic blocks with unconditional branches, connected
> by
>      // a single edge.
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121205/8f5785b8/attachment.html>


More information about the llvm-commits mailing list