[PATCH] D110901: [SimplifyCFG] Prevent SimplifyCFG from sinking indirect calls.

Joseph Huber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 11 06:30:38 PDT 2021


jhuber6 added a comment.

In D110901#3035809 <https://reviews.llvm.org/D110901#3035809>, @lebedev.ri wrote:

> It looks like what we need is a `invoke of select between functions  -->  if-then-else`

Looked at this problem again. There's already a way to promote indirect calls by versioning the call site, we could just add a pass that fully versions indirect calls that have `callee` metadata. If we do that for the code in the summary we'll get something like this https://godbolt.org/z/EP6n75far, then the versioning should be optimized out in cases like this with InstCombine, SimplifyCFG, and DCE leaving only conditional direct calls. Even in cases where this can't be optimized out, fully versioning out an indirect call whose callees are all known seems reasonable to me, maybe there's a reason we don't do this already that I'm not aware of. The downside is that fixing the code in the summary requires running the callee analysis after inlining, and then doing the versioning early enough that the other simplification passes will clean it up. I could make a patch for that if you think it's reasonable, but I'm not sure if it's worth the extra runtime in LLVM. The alternative is this patch which prevents this specific problem from showing up. What do you think @lebedev.ri?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110901/new/

https://reviews.llvm.org/D110901



More information about the llvm-commits mailing list