[llvm-commits] [patch] Enable simplifycfg in bb with only a lifetime intrinsic

Rafael Ávila de Espíndola rafael.espindola at gmail.com
Tue Jun 28 06:13:58 PDT 2011


> - while (PHINode *PN = dyn_cast<PHINode>(&BB->front())) {
> - if (Succ->getSinglePredecessor()) {
> - // BB is the only predecessor of Succ, so Succ will end up with exactly
> - // the same predecessors BB had.
> + if (Succ->getSinglePredecessor()) {
> + // BB is the only predecessor of Succ, so Succ will end up with exactly
> + // the same predecessors BB had.
> +
> + // Copy over any phi, debug or lifetime instruction.
> + BB->getTerminator()->eraseFromParent();
> + while (!BB->empty())
> Succ->getInstList().splice(Succ->begin(),
> BB->getInstList(), BB->begin());
> - } else {
> + } else {
> + while (PHINode *PN = dyn_cast<PHINode>(&BB->front())) {
>
> Wow, I'm impressed with how wrong this loop was. :) I mean, it had
> correct behaviour, but did N splices when it just needed to splice N
> items. Anyhow, thanks for fixing it!

Well, the original patch still had N splices, fixed on this one.

>
> Is there any reason not to copy the lifetime/debug intrinsics from this
> block to its successor when the successor has a single predecessor?
>
> /// TryToSimplifyUncondBranchFromEmptyBlock - BB is known to contain an
> /// unconditional branch, and contains no instructions other than PHI
> nodes,
> /// potential debug intrinsics and the branch. If possible, eliminate BB by
> /// rewriting all the predecessors to branch to the successor block and
> return
> /// true. If we can't transform, return false.
>
> Change "potential debug intrinsics" to "potential side-effect-free
> intrinsics"?

Done. Updated patch attached.

> Nick

Cheers,
Rafael

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: lifetime.patch
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110628/c7383b9e/attachment.ksh>


More information about the llvm-commits mailing list