[PATCH] D61461: When removing inalloca, convert to static alloca

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 2 18:01:25 PDT 2019


rnk added a comment.

In D61461#1488860 <https://reviews.llvm.org/D61461#1488860>, @efriedma wrote:

> For the multiple call case, we could maybe try to do some sort of control-flow based analysis, instead of trying to analyze uses of the pointer.  Essentially, take advantage of the rule that "the argument allocation must have been the most recent stack allocation that is still live".  But that's probably difficult to implement.


The control flow based idea could be stated as, is there any other call to inalloca reachable from this allocation that is not killed by another stack allocation? But, I guess it would have to track stacksave + stackrestore levels, and those are hard to analyze too.

In person over here, @inglorion and I felt that maybe this would be the best:

1. Teach clang to emit lifetime markers for inalloca packs (this should be easy)
2. Teach instcombine or another general cleanup pass to turn an inalloca alloca static if there are no inalloca calls anywhere in the current function. Don't try to insert lifetime markers, just assume the frontend did it if it cares.

Doing the whole-function analysis ignoring uses is much simpler, and it catches cases where the inalloca call site gets inlined, but the inalloca alloca doesn't get SROA'd.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61461





More information about the llvm-commits mailing list