[PATCH] D54189: [HotColdSplitting] Ensure PHIs have unique incoming values

Aditya Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 13 05:42:50 PST 2018


hiraditya added inline comments.


================
Comment at: llvm/lib/Transforms/IPO/HotColdSplitting.cpp:411
+          // Ignore successor PHIs without an incoming value from BB.
+          int BBIndex = SuccPhi.getBasicBlockIndex(&BB);
+          if (BBIndex == -1)
----------------
vsk wrote:
> vsk wrote:
> > vsk wrote:
> > > hiraditya wrote:
> > > > When can we have a case where PHI does not have incoming value from immediate predecessor?
> > > When the successor block has no uses of values defined in the predecessor. A special case of this is when the successor block just contains a terminator:
> > > 
> > > ```
> > > foo:
> > >   %sink = ...
> > >   br label %bar
> > > bar:
> > >   br label %baz
> > > ```
> > Sorry, that example is incorrect because there isn't a phi there at all. How about:
> > ```
> > foo:
> >   %sink = ...
> >   br label %bar
> > bar:
> >   %phi = phi [ 0, %p1 ], [ 1, %p2 ]
> >   br i1 undef, label %p1, label %p2
> > p1:
> >   br i1 undef, label %bar, %p1
> > p2:
> >   br i1 undef, label %bar, %p2
> > ```
> > 
> > I think foo dominates bar here, but bar has a phi without an incoming value from foo.
> No, my example is wrong again. A phi has to have an incoming value from each of its parent's predecessor blocks.
:)


https://reviews.llvm.org/D54189





More information about the llvm-commits mailing list