[PATCH] Fixup PHI nodes in LowerSwitch

David Blaikie dblaikie at gmail.com
Tue Jul 8 07:39:04 PDT 2014


On Jul 8, 2014 5:56 AM, "Pete" <peter_cooper at apple.com> wrote:
>
> ================
> Comment at: lib/Transforms/Utils/LowerSwitch.cpp:137
> @@ +136,3 @@
> +                    BasicBlock *NewNode) {
> + for (BasicBlock::iterator I = Succ->begin(), E = Succ->getFirstNonPHI();
> +      I != E; ++I) {
> ----------------
> I don't think this will work when debugging is enabled as phi's aren't
always the first instructions in a BB, or even contiguous.

That doesn't sound right. The IR spec says this about phis:

" There must be no non-phi instructions between the start of a basic block
and the PHI instructions: i.e. PHI instructions must be first in a basic
block."

> I think you'll need getFirstNonPHIOrDbgOrLifetime(),

I believe the dbg and lifetime intrinsics still have to come after the
phi's. This aggressor is useful when iterating the 'real' instructions so
the dbg and lifetime intrinsics can be skipped, I don't think it's
relevant/necessary when looking for phis.

> and then to have the loop skip anything which isn't a phi.
>
> http://reviews.llvm.org/D4298
>
>
>
> _______________________________________________
> 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/20140708/d4288033/attachment.html>


More information about the llvm-commits mailing list