Don't inline dynamic allocas that simplify to huge static allocas.
authorAmara Emerson <aemerson@apple.com>
Fri, 12 Jun 2020 17:19:28 +0000 (10:19 -0700)
committerAmara Emerson <aemerson@apple.com>
Thu, 25 Jun 2020 00:39:03 +0000 (17:39 -0700)
commit090c108d04e2c557047f1d798dd56afcabe99373
tree9115682c4359f832478707d491904a97f22bac86
parent7d1452d8373e5aaaa94b5d0d6c9a1dc4be457311
Don't inline dynamic allocas that simplify to huge static allocas.

Some sequences of optimizations can generate call sites which may never be
executed during runtime, and through constant propagation result in dynamic
allocas being converted to static allocas with very large allocation amounts.

The inliner tries to move these to the caller's entry block, resulting in the
stack limits being reached/bypassed. Avoid inlining functions if this would
result.

The threshold of 64k currently doesn't get triggered on the test suite with an
-Os LTO build on arm64, care should be taken in changing this in future to avoid
needlessly pessimising inlining behaviour.

Differential Revision: https://reviews.llvm.org/D81765
llvm/include/llvm/Analysis/InlineCost.h
llvm/lib/Analysis/InlineCost.cpp
llvm/test/Transforms/Inline/dynamic-alloca-simplified-large.ll [new file with mode: 0644]