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

Vedant Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 6 17:20:44 PST 2018


vsk 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:
> 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.


https://reviews.llvm.org/D54189





More information about the llvm-commits mailing list