[llvm-commits] [patch] Enable simplifycfg in bb with only a lifetime intrinsic
Nick Lewycky
nicholas at mxc.ca
Mon Jun 27 21:54:27 PDT 2011
Rafael Ávila de Espíndola wrote:
> I noticed that simplify cfg would fail to simplify bbs like
>
> bb:
> call void @llvm.lifetime.end(i64 -1, i8* %a) nounwind
> br label %bb1
>
> The attached patch enables that. It can cause a llvm.lifetime.* to be lost,
> but if I understand the manual correctly, that is fine: the argument now
> has a larger life range.
- 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!
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"?
Nick
>
> Cheers,
> Rafael
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list