[PATCH] D29916: [CGP] Split some critical edges coming out of indirect branches

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 13 18:00:00 PST 2017


efriedma added a comment.

> I don't really understand what you mean regarding splitting the other predecessors. I want to avoid having a phi on a block where one of the predecessor blocks on the phi is an indirectbr. I don't see how doing anything to the other incoming edges would help, you'll still end  with this phi, just change the other predecessors.

Err, sorry, that was a terrible explanation; I started out thinking one thing, and writing something different.

Anyway, suppose you have a block B with one indirectbr predecessor and some other non-indirectbr predecessors.  First, you split `B` before the first non-PHI instruction, making `B2`.  Then you clone `B`, making `B3`.  Then you change all the non-indirectbr predecessors of `B` point at `B3`.  (Then you fix up the PHI nodes.)  You now have exactly the same CFG as your code produces, without messing with the global variable.

> Regardless, I'd like to also extend this to split cases where we have several indirectbr predecessors (of this form).

clang doesn't generate code like that, even if a function has multiple indirect goto statements.  Have you seen this come up in practice?


https://reviews.llvm.org/D29916





More information about the llvm-commits mailing list