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

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 2 18:19:04 PDT 2019


efriedma added a comment.

> Teach instcombine or another general cleanup pass to turn an inalloca alloca static if there are no inalloca calls anywhere in the current function

Given an arbitrary alloca in a function with no inalloca calls, hoisting the alloca to the entry block requires proving that the allocation's lifetime doesn't overlap itself.  For example, we have to make sure we don't miscompile `for (int i = 0; i < n; i++) foo(alloca(1));`.  So you have to track stacksave + stackrestore levels anyway.

That said, a general alloca hoisting transform might be useful in other contexts, and analyzing the whole function at once is probably the most efficient way to handle it.


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